Merge pull request #242 from gnustep/NSCollectionViewLayout_branch

This branch is to support methods needed by NSCollectionView layout methods.   Added NSIndexMethods needed.
This commit is contained in:
Gregory Casamento 2022-03-07 04:33:31 -05:00 committed by GitHub
commit 61d14215fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -72,6 +72,23 @@ GS_EXPORT_CLASS
*/
+ (id) indexPathWithIndexes: (NSUInteger*)indexes length: (NSUInteger)length;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11,GS_API_LATEST)
/**
* Return a path containing an item number and section.
*/
+ (NSIndexPath *) indexPathForItem: (NSInteger)item inSection: (NSInteger)section;
/**
* Return an index number identifying an item in a collection view
*/
- (NSInteger) item;
/**
* Return an index number identifying a section in a collection view
*/
- (NSInteger) section;
#endif
/**
* Compares other with the receiver.<br />
* Returns NSOrderedSame if the two are identical.<br />

View file

@ -64,6 +64,16 @@ static NSIndexPath *dummy = nil;
return AUTORELEASE(o);
}
+ (NSIndexPath *) indexPathForItem: (NSInteger)item inSection: (NSInteger)section;
{
NSUInteger idxs[2];
idxs[0] = (NSUInteger)section;
idxs[1] = (NSUInteger)item;
return [self indexPathWithIndexes: idxs length: 2];
}
+ (void) initialize
{
if (empty == nil)
@ -198,6 +208,16 @@ static NSIndexPath *dummy = nil;
}
}
- (NSInteger) item
{
return (NSInteger)[self indexAtPosition: 1];
}
- (NSInteger) section
{
return (NSInteger)[self indexAtPosition: 0];
}
- (void) getIndexes: (NSUInteger*)aBuffer
{
memcpy(aBuffer, _indexes, _length * sizeof(NSUInteger));