mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Add all overriden methods in flow layout. In NSCollectionView set collectionView in layout. Minor code cleanup.
This commit is contained in:
parent
42a5f34095
commit
68f1444de3
4 changed files with 101 additions and 5 deletions
|
@ -94,6 +94,7 @@ NSCollectionViewSupplementaryElementKind NSCollectionElementKindInterItemGapIndi
|
|||
|
||||
- (NSCollectionElementCategory) representedElementCategory;
|
||||
- (NSString *) representedElementKind;
|
||||
|
||||
@end
|
||||
|
||||
enum
|
||||
|
@ -116,15 +117,16 @@ typedef NSInteger NSCollectionUpdateAction;
|
|||
- (NSIndexPath *) indexPathBeforeUpdate;
|
||||
- (NSIndexPath *) indexPathAfterUpdate;
|
||||
- (NSCollectionUpdateAction) updateAction;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface NSCollectionViewLayoutInvalidationContext : NSObject
|
||||
{
|
||||
NSPoint _contentOffsetAdjustment;
|
||||
NSPoint _contentOffsetAdjustment;
|
||||
NSSize _contentSizeAdjustment;
|
||||
NSSet *_invalidatedItemIndexPaths;
|
||||
NSDictionary *_invalidatedSupplementaryIndexPaths;
|
||||
NSDictionary *_invalidatedSupplementaryIndexPaths;
|
||||
NSDictionary *_invalidatedDecorationIndexPaths;
|
||||
}
|
||||
|
||||
|
@ -149,6 +151,7 @@ typedef NSInteger NSCollectionUpdateAction;
|
|||
|
||||
- (NSDictionary *) invalidatedSupplementaryIndexPaths;
|
||||
- (NSDictionary *) invalidatedDecorationIndexPaths;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSCollectionViewLayout : NSObject <NSCoding>
|
||||
|
@ -163,7 +166,7 @@ typedef NSInteger NSCollectionUpdateAction;
|
|||
|
||||
// Initializers
|
||||
- (void)invalidateLayout;
|
||||
- (void)invalidateLayoutWithContext:(NSCollectionViewLayoutInvalidationContext *)context;
|
||||
- (void)invalidateLayoutWithContext: (NSCollectionViewLayoutInvalidationContext *)context;
|
||||
|
||||
- (void)registerClass: (Class)viewClass
|
||||
forDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind;
|
||||
|
@ -173,7 +176,7 @@ typedef NSInteger NSCollectionUpdateAction;
|
|||
// Properties
|
||||
- (NSCollectionView *) collectionView;
|
||||
- (void) setCollectionView: (NSCollectionView *)cv;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@interface NSCollectionViewLayout (NSSubclassingHooks)
|
||||
|
|
|
@ -439,6 +439,8 @@ static NSString *placeholderItem = nil;
|
|||
- (void) setCollectionViewLayout: (NSCollectionViewLayout *)layout
|
||||
{
|
||||
ASSIGN(_collectionViewLayout, layout);
|
||||
|
||||
[_collectionViewLayout setCollectionView: self]; // weak reference
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
|
@ -1363,8 +1365,9 @@ static NSString *placeholderItem = nil;
|
|||
{
|
||||
NSInteger ns = [self numberOfSections];
|
||||
NSInteger cs = 0;
|
||||
|
||||
|
||||
NSLog(@"reloading data... number of sections = %ld, %@", ns, _collectionViewLayout);
|
||||
[_collectionViewLayout prepareLayout];
|
||||
for (cs = 0; cs < ns; cs++)
|
||||
{
|
||||
NSInteger ni = [self numberOfItemsInSection: cs];
|
||||
|
|
|
@ -174,5 +174,87 @@
|
|||
{
|
||||
}
|
||||
|
||||
// Methods to override for specific layouts...
|
||||
- (void) prepareLayout
|
||||
{
|
||||
[super prepareLayout];
|
||||
_invalidateFlowLayoutAttributes = NO;
|
||||
_invalidateFlowLayoutDelegateMetrics = NO;
|
||||
}
|
||||
|
||||
- (NSArray *) layoutAttributesForElementsInRect: (NSRect)rect
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)layoutAttributesForDropTargetAtPoint: (NSPoint)pointInCollectionView
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)layoutAttributesForInterItemGapBeforeIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)shouldInvalidateLayoutForBoundsChange: (NSRect)newBounds
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange: (NSRect)newBounds
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)shouldInvalidateLayoutForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutInvalidationContext *)
|
||||
invalidationContextForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset
|
||||
withScrollingVelocity: (NSPoint)velocity
|
||||
{
|
||||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset
|
||||
{
|
||||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (NSSize) collectionViewContentSize
|
||||
{
|
||||
return [_collectionView frame].size;
|
||||
}
|
||||
// end subclassing hooks...
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -242,6 +242,14 @@
|
|||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self != nil)
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSItemSize"])
|
||||
{
|
||||
[coder decodeSizeForKey: @"NSItemSize"];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue