libs-gui/Source/NSCollectionViewFlowLayout.m

519 lines
15 KiB
Mathematica
Raw Normal View History

2021-05-30 08:53:03 +00:00
/* Implementation of class NSCollectionViewFlowLayout
Copyright (C) 2021 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 30-05-2021
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSIndexPath.h>
2022-11-28 06:20:25 +00:00
#import "AppKit/NSCollectionView.h"
2021-05-30 08:53:03 +00:00
#import "AppKit/NSCollectionViewFlowLayout.h"
#import "AppKit/NSCollectionViewItem.h"
2021-05-30 08:53:03 +00:00
2022-07-15 11:11:13 +00:00
#import "GSGuiPrivate.h"
Add methods and actions for layout classes as well as the abstract classes for NSCollectionViewLayout. Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add header for NSCollectionViewFlowLayout.h Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Skeleton of NSCollectionViewTransitionLayout implementation Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView Add 10.11 methods to delegate declaration remove templating from NSCollectionViewDelegate that gcc can't handle. New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Add the remaining missing methods as well as delcarations for blocks needed for batch handler and completion handler. Add skeleton implementations for all new methods Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Implementation of dataSource related methods Implment nib loading for NSCollectionViewItem subclasses Remove uneeded ivars, add categories for override and layout Minor formatting change Update categories and organization of code Add init method to NSCollectionViewFlowLayoutInvalidationContext Add collectionview layout subclasses Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Add init method to NSCollectionViewFlowLayoutInvalidationContext Fix issues with rebase
2021-05-31 11:47:58 +00:00
@implementation NSCollectionViewFlowLayoutInvalidationContext
- (instancetype) init
{
self = [super init];
if (self != nil)
{
_invalidateFlowLayoutAttributes = YES;
_invalidateFlowLayoutDelegateMetrics = YES;
}
return self;
}
- (void) setInvalidateFlowLayoutDelegateMetrics: (BOOL)flag
{
_invalidateFlowLayoutDelegateMetrics = flag;
}
- (BOOL) invalidateFlowLayoutDelegateMetrics
{
return _invalidateFlowLayoutDelegateMetrics;
}
- (void) setInvalidateFlowLayoutAttributes: (BOOL)flag
{
_invalidateFlowLayoutAttributes = flag;
}
- (BOOL) invalidateFlowLayoutAttributes
{
return _invalidateFlowLayoutAttributes;
}
@end
2021-05-30 08:53:03 +00:00
@implementation NSCollectionViewFlowLayout
2022-07-16 09:44:17 +00:00
- (instancetype) init
{
self = [super init];
if (self != nil)
{
_collapsedSections = [[NSMutableIndexSet alloc] init];
}
return self;
}
- (void) dealloc
{
RELEASE(_collapsedSections);
[super dealloc];
}
- (id) initWithCoder: (NSCoder *)coder
{
self = [super initWithCoder: coder];
if (self)
{
2022-07-16 09:44:17 +00:00
_collapsedSections = [[NSMutableIndexSet alloc] init];
if ([coder allowsKeyedCoding])
{
2022-07-14 15:17:39 +00:00
if ([coder containsValueForKey: @"NSMinimumLineSpacing"])
{
_minimumLineSpacing = [coder decodeFloatForKey: @"NSMinimumLineSpacing"];
}
if ([coder containsValueForKey: @"NSMinimumInteritemSpacing"])
{
_minimumInteritemSpacing = [coder decodeFloatForKey: @"NSMinimumInteritemSpacing"];
}
if ([coder containsValueForKey: @"NSItemSize"])
{
_itemSize = [coder decodeSizeForKey: @"NSItemSize"];
}
if ([coder containsValueForKey: @"NSEstimatedItemSize"])
{
_estimatedItemSize = [coder decodeSizeForKey: @"NSEstimatedItemSize"];
}
if ([coder containsValueForKey: @"NSScrollDirection"])
{
_scrollDirection = [coder decodeIntForKey: @"NSScrollDirection"];
}
if ([coder containsValueForKey: @"NSHeaderReferenceSize"])
{
_headerReferenceSize = [coder decodeSizeForKey: @"NSHeaderReferneceSize"];
}
if ([coder containsValueForKey: @"NSFooterReferenceSize"])
{
_footerReferenceSize = [coder decodeSizeForKey: @"NSFooterReferenceSize"];
}
// decode inset...
if ([coder containsValueForKey: @"NSSectionInset.bottom"])
{
_sectionInset.bottom = [coder decodeFloatForKey: @"NSSectionInset.bottom"];
}
if ([coder containsValueForKey: @"NSSectionInset.top"])
{
_sectionInset.top = [coder decodeFloatForKey: @"NSSectionInset.top"];
}
if ([coder containsValueForKey: @"NSSectionInset.left"])
{
_sectionInset.left = [coder decodeFloatForKey: @"NSSectionInset.left"];
}
if ([coder containsValueForKey: @"NSSectionInset.right"])
{
_sectionInset.right = [coder decodeFloatForKey: @"NSSectionInset.right"];
}
if ([coder containsValueForKey: @"NSSectionHeadersPinToVisibleBounds"])
{
_sectionHeadersPinToVisibleBounds = [coder decodeBoolForKey: @"NSSectionHeadersPinToVisibleBounds"];
}
if ([coder containsValueForKey: @"NSSectionFootersPinToVisibleBounds"])
{
_sectionFootersPinToVisibleBounds = [coder decodeBoolForKey: @"NSSectionFootersPinToVisibleBounds"];
}
}
else
{
2022-07-15 11:34:17 +00:00
[coder decodeValueOfObjCType: @encode(CGFloat)
at: &_minimumInteritemSpacing];
_itemSize = [coder decodeSize];
2022-07-15 11:34:17 +00:00
_estimatedItemSize = [coder decodeSize];
decode_NSInteger(coder, &_scrollDirection);
_headerReferenceSize = [coder decodeSize];
_footerReferenceSize = [coder decodeSize];
// decode inset...
[coder decodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.bottom];
[coder decodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.top];
[coder decodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.left];
[coder decodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.right];
[coder decodeValueOfObjCType: @encode(BOOL)
at: &_sectionHeadersPinToVisibleBounds];
[coder decodeValueOfObjCType: @encode(BOOL)
at: &_sectionFootersPinToVisibleBounds];
}
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
2022-07-14 15:17:39 +00:00
if ([coder allowsKeyedCoding])
{
[coder encodeFloat: _minimumLineSpacing
forKey: @"NSMinimumLineSpacing"];
[coder encodeFloat: _minimumInteritemSpacing
forKey: @"NSMinimumInteritemSpacing"];
[coder encodeSize: _itemSize
forKey: @"NSItemSize"];
[coder encodeSize: _estimatedItemSize
forKey: @"NSEstimatedItemSize"];
[coder encodeInt: _scrollDirection
forKey: @"NSScrollDirection"];
[coder encodeSize: _headerReferenceSize
forKey: @"NSHeaderReferneceSize"];
[coder encodeSize: _footerReferenceSize
forKey: @"NSFooterReferenceSize"];
// decode inset...
[coder encodeFloat: _sectionInset.bottom
forKey: @"NSSectionInset.bottom"];
[coder encodeFloat: _sectionInset.top
forKey: @"NSSectionInset.top"];
[coder encodeFloat: _sectionInset.left
forKey: @"NSSectionInset.left"];
[coder encodeFloat: _sectionInset.right
forKey: @"NSSectionInset.right"];
[coder encodeBool: _sectionHeadersPinToVisibleBounds
forKey: @"NSSectionHeadersPinToVisibleBounds"];
[coder encodeBool: _sectionFootersPinToVisibleBounds
forKey: @"NSSectionFootersPinToVisibleBounds"];
}
else
{
2022-07-15 11:11:13 +00:00
[coder encodeValueOfObjCType: @encode(CGFloat)
at: &_minimumInteritemSpacing];
[coder encodeSize: _itemSize];
[coder encodeSize: _estimatedItemSize];
encode_NSInteger(coder, &_scrollDirection);
[coder encodeSize: _headerReferenceSize];
[coder encodeSize: _footerReferenceSize];
// decode inset...
[coder encodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.bottom];
[coder encodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.top];
[coder encodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.left];
[coder encodeValueOfObjCType: @encode(CGFloat)
at: &_sectionInset.right];
[coder encodeValueOfObjCType: @encode(BOOL)
at: &_sectionHeadersPinToVisibleBounds];
[coder encodeValueOfObjCType: @encode(BOOL)
at: &_sectionFootersPinToVisibleBounds];
2022-07-14 15:17:39 +00:00
}
}
Add methods and actions for layout classes as well as the abstract classes for NSCollectionViewLayout. Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add header for NSCollectionViewFlowLayout.h Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Skeleton of NSCollectionViewTransitionLayout implementation Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView Add 10.11 methods to delegate declaration remove templating from NSCollectionViewDelegate that gcc can't handle. New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Add the remaining missing methods as well as delcarations for blocks needed for batch handler and completion handler. Add skeleton implementations for all new methods Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Implementation of dataSource related methods Implment nib loading for NSCollectionViewItem subclasses Remove uneeded ivars, add categories for override and layout Minor formatting change Update categories and organization of code Add init method to NSCollectionViewFlowLayoutInvalidationContext Add collectionview layout subclasses Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Add init method to NSCollectionViewFlowLayoutInvalidationContext Fix issues with rebase
2021-05-31 11:47:58 +00:00
- (CGFloat) minimumLineSpacing
{
return _minimumLineSpacing;
}
- (void) setMinimumLineSpacing: (CGFloat)spacing
{
_minimumLineSpacing = spacing;
}
- (CGFloat) minimumInteritemSpacing
{
return _minimumInteritemSpacing;
}
- (void) setMinimumInteritemSpacing: (CGFloat)spacing
{
_minimumInteritemSpacing = spacing;
}
- (NSSize) itemSize
2022-07-16 09:44:17 +00:00
{
Add methods and actions for layout classes as well as the abstract classes for NSCollectionViewLayout. Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add header for NSCollectionViewFlowLayout.h Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Skeleton of NSCollectionViewTransitionLayout implementation Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView Add 10.11 methods to delegate declaration remove templating from NSCollectionViewDelegate that gcc can't handle. New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Add the remaining missing methods as well as delcarations for blocks needed for batch handler and completion handler. Add skeleton implementations for all new methods Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Implementation of dataSource related methods Implment nib loading for NSCollectionViewItem subclasses Remove uneeded ivars, add categories for override and layout Minor formatting change Update categories and organization of code Add init method to NSCollectionViewFlowLayoutInvalidationContext Add collectionview layout subclasses Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Add init method to NSCollectionViewFlowLayoutInvalidationContext Fix issues with rebase
2021-05-31 11:47:58 +00:00
return _itemSize;
}
- (void) setItemSize: (NSSize)itemSize
{
_itemSize = itemSize;
}
- (NSSize) estimatedItemSize
{
return _estimatedItemSize;
}
- (void) setEstimatedItemSize: (NSSize)size
{
_estimatedItemSize = size;
}
- (NSCollectionViewScrollDirection) scrollDirection
{
return _scrollDirection;
}
- (void) setScrollDirection: (NSCollectionViewScrollDirection)direction
{
_scrollDirection = direction;
}
- (NSSize) headerReferenceSize
{
return _headerReferenceSize;
}
- (void) setHeaderReferenceSize: (NSSize)size
{
_headerReferenceSize = size;
}
- (NSSize) footerReferenceSize
{
return _footerReferenceSize;
}
- (void) setFooterReferenceSize: (NSSize)size
{
_footerReferenceSize = size;
}
- (NSEdgeInsets) sectionInset
{
return _sectionInset;
}
- (void) setSectionInset: (NSEdgeInsets)inset
{
_sectionInset = inset;
}
- (BOOL) sectionHeadersPinToVisibleBounds
{
return _sectionHeadersPinToVisibleBounds;
}
- (void) setSectionHeadersPinToVisibleBounds: (BOOL)f
{
_sectionHeadersPinToVisibleBounds = f;
}
- (BOOL) sectionFootersPinToVisibleBounds
{
return _sectionFootersPinToVisibleBounds;
}
- (void) setSectionFootersPinToVisibleBounds: (BOOL)f
{
_sectionFootersPinToVisibleBounds = f;
}
- (BOOL) sectionAtIndexIsCollapsed: (NSUInteger)sectionIndex
{
2022-07-16 09:44:17 +00:00
return [_collapsedSections containsIndex: sectionIndex];
Add methods and actions for layout classes as well as the abstract classes for NSCollectionViewLayout. Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add header for NSCollectionViewFlowLayout.h Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Skeleton of NSCollectionViewTransitionLayout implementation Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView Add 10.11 methods to delegate declaration remove templating from NSCollectionViewDelegate that gcc can't handle. New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Add the remaining missing methods as well as delcarations for blocks needed for batch handler and completion handler. Add skeleton implementations for all new methods Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Implementation of dataSource related methods Implment nib loading for NSCollectionViewItem subclasses Remove uneeded ivars, add categories for override and layout Minor formatting change Update categories and organization of code Add init method to NSCollectionViewFlowLayoutInvalidationContext Add collectionview layout subclasses Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Add init method to NSCollectionViewFlowLayoutInvalidationContext Fix issues with rebase
2021-05-31 11:47:58 +00:00
}
- (void) collapseSectionAtIndex: (NSUInteger)sectionIndex
{
2022-07-16 09:44:17 +00:00
[_collapsedSections addIndex: sectionIndex];
Add methods and actions for layout classes as well as the abstract classes for NSCollectionViewLayout. Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add header for NSCollectionViewFlowLayout.h Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Skeleton of NSCollectionViewTransitionLayout implementation Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView Add 10.11 methods to delegate declaration remove templating from NSCollectionViewDelegate that gcc can't handle. New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Add the remaining missing methods as well as delcarations for blocks needed for batch handler and completion handler. Add skeleton implementations for all new methods Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Implementation of dataSource related methods Implment nib loading for NSCollectionViewItem subclasses Remove uneeded ivars, add categories for override and layout Minor formatting change Update categories and organization of code Add init method to NSCollectionViewFlowLayoutInvalidationContext Add collectionview layout subclasses Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Add init method to NSCollectionViewFlowLayoutInvalidationContext Fix issues with rebase
2021-05-31 11:47:58 +00:00
}
- (void) expandSectionAtIndex: (NSUInteger)sectionIndex
{
2022-07-16 09:44:17 +00:00
[_collapsedSections removeIndex: sectionIndex];
Add methods and actions for layout classes as well as the abstract classes for NSCollectionViewLayout. Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add header for NSCollectionViewFlowLayout.h Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Skeleton of NSCollectionViewTransitionLayout implementation Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView Add 10.11 methods to delegate declaration remove templating from NSCollectionViewDelegate that gcc can't handle. New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Add the remaining missing methods as well as delcarations for blocks needed for batch handler and completion handler. Add skeleton implementations for all new methods Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Implementation of dataSource related methods Implment nib loading for NSCollectionViewItem subclasses Remove uneeded ivars, add categories for override and layout Minor formatting change Update categories and organization of code Add init method to NSCollectionViewFlowLayoutInvalidationContext Add collectionview layout subclasses Declarations added to collectionview layout header. Clean compile for NSCollectionViewLayout abstract class Add skeleton implementation of NSCollectionViewFlowLayout Add implementation for simple setter/getter methods. Correct compilation error with non-clang compilers Fix compilation issues Add getter/setter for collectionViewLayout Add encoding/decoding for collectionViewLayout key Make NSCollectionViewGridLayout default if the NSCollectionViewLayoutKey is not set Add protocols for DataSource and Prefetching for NSCollectionView New delegate methods for NSCollectionViewDelegate to support NSSets of NSIndexPaths and multiple selection. Reset .travis.yml to the proper version and modify NSCollectionView.h to use forward declarations for both NSPasteboard and NSPasteboardWriting so that we don't explicitly import. Add declarations for missing methods from 10.11 version of NSCollectionView Add new methods for 10.11 for moving, deleting and collapsing sections. Add new methods from 10.11 Changes to add new methods to collection view for delegate Consolidate the registeredClass and registeredNib maps. Add init method to NSCollectionViewFlowLayoutInvalidationContext Fix issues with rebase
2021-05-31 11:47:58 +00:00
}
// Methods to override for specific layouts...
- (void) prepareLayout
{
[super prepareLayout];
2022-07-17 12:32:29 +00:00
_ds = 0;
_dr = 0;
}
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
{
2022-07-17 12:32:29 +00:00
NSCollectionViewLayoutAttributes *attrs = AUTORELEASE([[NSCollectionViewLayoutAttributes alloc] init]);
2022-07-16 09:44:17 +00:00
NSSize sz = NSZeroSize;
id <NSCollectionViewDelegateFlowLayout> d = (id <NSCollectionViewDelegateFlowLayout>)[_collectionView delegate];
2022-07-17 12:32:29 +00:00
NSInteger s = [indexPath section]; // + _ds;
NSInteger r = [indexPath item]; // + _dr;
2022-07-16 09:44:17 +00:00
NSEdgeInsets si;
CGFloat mls = 0.0;
CGFloat mis = 0.0;
CGFloat h = 0.0, w = 0.0, x = 0.0, y = 0.0;
NSRect f = NSZeroRect;
NSRect vf = [_collectionView frame]; // needed for reflow...
// Item size...
2022-07-16 09:44:17 +00:00
if ([d respondsToSelector: @selector(collectionView:layout:sizeForItemAtIndexPath:)])
{
sz = [d collectionView: _collectionView
layout: self
sizeForItemAtIndexPath: indexPath];
}
else
{
sz = [self itemSize];
}
// Inset
2022-07-16 09:44:17 +00:00
if ([d respondsToSelector: @selector(collectionView:layout:insetForSectionAtIndex:)])
{
si = [d collectionView: _collectionView
layout: self
insetForSectionAtIndex: s];
}
else
{
si = [self sectionInset];
}
// minimum line spacing
if ([d respondsToSelector: @selector(collectionView:layout:minimimLineSpacingForSectionAtIndex:)])
{
mls = [d collectionView: _collectionView
layout: self
minimumLineSpacingForSectionAtIndex: s];
}
else
{
mls = [self minimumLineSpacing];
}
// minimum interitem spacing
if ([d respondsToSelector: @selector(collectionView:layout:minimimInteritemSpacingForSectionAtIndex:)])
{
mis = [d collectionView: _collectionView
layout: self
minimumInteritemSpacingForSectionAtIndex: s];
}
else
{
mis = [self minimumInteritemSpacing];
}
2022-07-16 11:56:13 +00:00
// Calculations...
h = sz.height;
w = sz.width;
x = (r * w) + si.left + mis;
y = (s * h) + si.top + mls;
2022-07-17 12:32:29 +00:00
f = NSMakeRect(x, y, w, h);
// Determine if it is needed to reflow the given element...
if ((x + w) > (vf.size.width - w))
{
_ds += 1;
x = si.left + mis;
y = ((s + _ds) * h) + si.top + mls;
f = NSMakeRect(x, y, w, h);
}
2022-07-16 11:56:13 +00:00
// Build attrs object...
[attrs setFrame: f];
[attrs setZIndex: 0];
2022-10-26 16:11:17 +00:00
[attrs setSize: f.size];
2022-07-17 20:25:03 +00:00
[attrs setHidden: NO];
[attrs setAlpha: 1.0];
return attrs;
}
- (NSCollectionViewLayoutAttributes *)
layoutAttributesForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
2022-07-16 11:56:13 +00:00
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...
2021-05-30 08:53:03 +00:00
@end