mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:21:04 +00:00
Return attributes for items that intersect
This commit is contained in:
parent
9c1aec70e7
commit
3f402d292b
4 changed files with 43 additions and 8 deletions
|
@ -438,9 +438,9 @@ APPKIT_EXPORT_CLASS
|
|||
|
||||
// Managing items
|
||||
NSMutableArray *_visibleItems;
|
||||
NSSet *_indexPathsForVisibleItems;
|
||||
NSMutableSet *_indexPathsForVisibleItems;
|
||||
NSDictionary *_visibleSupplementaryViews;
|
||||
NSSet *_indexPathsForSupplementaryElementsOfKind;
|
||||
NSMutableSet *_indexPathsForSupplementaryElementsOfKind;
|
||||
|
||||
// Registered class/nib for item identifier
|
||||
NSMapTable *_registeredNibs;
|
||||
|
|
|
@ -1391,6 +1391,7 @@ static NSString *placeholderItem = nil;
|
|||
NSView *v = [item view];
|
||||
|
||||
[_visibleItems addObject: item];
|
||||
[_indexPathsForVisibleItems addObject: path];
|
||||
if (_collectionViewLayout)
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *attrs =
|
||||
|
@ -1449,6 +1450,7 @@ static NSString *placeholderItem = nil;
|
|||
|
||||
[self setFrame: newRect];
|
||||
[_visibleItems removeAllObjects];
|
||||
[_indexPathsForVisibleItems removeAllObjects];
|
||||
[self setSubviews: [NSArray array]];
|
||||
[_collectionViewLayout prepareLayout];
|
||||
for (cs = 0; cs < ns; cs++)
|
||||
|
|
|
@ -372,11 +372,6 @@
|
|||
_dr = 0;
|
||||
}
|
||||
|
||||
- (NSArray *) layoutAttributesForElementsInRect: (NSRect)rect
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *attrs = AUTORELEASE([[NSCollectionViewLayoutAttributes alloc] init]);
|
||||
|
|
|
@ -23,6 +23,27 @@
|
|||
*/
|
||||
|
||||
#import "AppKit/NSCollectionViewLayout.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
@interface NSCollectionViewItem (__NSCollectionViewLayout__)
|
||||
- (NSCollectionViewLayoutAttributes *) attrs;
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewItem (__NSCollectionViewLayout__)
|
||||
- (NSCollectionViewLayoutAttributes *) attrs
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *attrs = AUTORELEASE([[NSCollectionViewLayoutAttributes alloc] init]);
|
||||
|
||||
[attrs setFrame: [[self view] frame]];
|
||||
[attrs setSize: [[self view] frame].size];
|
||||
[attrs setAlpha: [[self view] alphaValue]];
|
||||
[attrs setHidden: [[self view] isHidden]];
|
||||
|
||||
return attrs;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewLayoutAttributes
|
||||
|
||||
|
@ -287,7 +308,24 @@
|
|||
|
||||
- (NSArray *) layoutAttributesForElementsInRect: (NSRect)rect
|
||||
{
|
||||
return nil;
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
NSArray *items = [_collectionView visibleItems];
|
||||
|
||||
FOR_IN(NSCollectionViewItem*, i, items)
|
||||
{
|
||||
NSView *v = [i view];
|
||||
NSRect f = [v frame];
|
||||
BOOL intersects = NSIntersectsRect(f, rect);
|
||||
|
||||
if (intersects)
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *a = [i attrs];
|
||||
[result addObject: a]; // add item since it intersects
|
||||
}
|
||||
}
|
||||
END_FOR_IN(items);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
|
|
Loading…
Reference in a new issue