mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 13:40:49 +00:00
Update implementation to calculate position of items for the flow layout. implementation of copyWithZone. Implementation of initWithCoder for flow layout
This commit is contained in:
parent
7fe30c6db2
commit
8948aecae5
4 changed files with 97 additions and 14 deletions
|
@ -22,7 +22,10 @@
|
|||
Boston, MA 02110 USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSIndexPath.h>
|
||||
|
||||
#import "AppKit/NSCollectionViewFlowLayout.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
|
||||
@implementation NSCollectionViewFlowLayoutInvalidationContext
|
||||
|
||||
|
@ -61,6 +64,27 @@
|
|||
|
||||
@implementation NSCollectionViewFlowLayout
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
_itemSize = [coder decodeSizeForKey: @"NSItemSize"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_itemSize = [coder decodeSize];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
}
|
||||
|
||||
- (CGFloat) minimumLineSpacing
|
||||
{
|
||||
return _minimumLineSpacing;
|
||||
|
@ -187,8 +211,28 @@
|
|||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
NSLog(@"Flow layout for index path = %@", indexPath);
|
||||
return nil;
|
||||
NSCollectionViewLayoutAttributes *attrs = [[NSCollectionViewLayoutAttributes alloc] init];
|
||||
NSSize sz = [self itemSize];
|
||||
NSInteger s = [indexPath section];
|
||||
NSInteger r = [indexPath item];
|
||||
CGFloat h = sz.height;
|
||||
CGFloat w = sz.width;
|
||||
NSRect f = NSMakeRect(r * w, s * h, h, w);
|
||||
|
||||
// NSLog(@"Flow layout for index path = %@", indexPath);
|
||||
|
||||
[attrs setFrame: f];
|
||||
[attrs setHidden: NO];
|
||||
[attrs setZIndex: 0];
|
||||
[attrs setSize: sz];
|
||||
|
||||
// NSLog(@"f = %@", NSStringFromRect(f));
|
||||
// NSLog(@"s = %@", NSStringFromSize(sz));
|
||||
// NSLog(@"self = %@", self);
|
||||
|
||||
AUTORELEASE(attrs);
|
||||
|
||||
return attrs;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue