mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
Fix implementation of resize when elements overflow the size of the view
This commit is contained in:
parent
b96dbcba2e
commit
5ff478ac85
3 changed files with 22 additions and 89 deletions
|
@ -1670,14 +1670,30 @@ static NSString *placeholderItem = nil;
|
|||
_indexPathsToItems = RETAIN([NSMapTable strongToStrongObjectsMapTable]);
|
||||
}
|
||||
|
||||
- (void) _setFrameWithoutTile: (NSRect)f
|
||||
{
|
||||
_frame = f;
|
||||
}
|
||||
|
||||
- (void) _updateParentViewFrame
|
||||
{
|
||||
NSEnumerator *oe = [_itemsToAttributes objectEnumerator];
|
||||
NSCollectionViewLayoutAttributes *attrs = nil;
|
||||
|
||||
NSRect cf = [self frame];
|
||||
NSSize ps = cf.size;
|
||||
|
||||
while ((attrs = [oe nextObject]) != nil)
|
||||
{
|
||||
NSRect f = [attrs frame];
|
||||
CGFloat w = f.origin.x + f.size.width;
|
||||
CGFloat h = f.origin.y + f.size.height;
|
||||
|
||||
ps.width = (w > ps.width) ? w : ps.width;
|
||||
ps.height = (h > ps.height) ? h : ps.height;
|
||||
}
|
||||
|
||||
cf.size = ps;
|
||||
[self _setFrameWithoutTile: cf];
|
||||
}
|
||||
|
||||
- (void) reloadData
|
||||
|
|
|
@ -29,17 +29,6 @@
|
|||
|
||||
#import "GSGuiPrivate.h"
|
||||
|
||||
@interface NSCollectionView (__FlowLayoutPrivate__)
|
||||
- (void) _setFrameWithoutTile: (NSRect)f;
|
||||
@end
|
||||
|
||||
@implementation NSCollectionView (__FlowLayoutPrivate__)
|
||||
- (void) _setFrameWithoutTile: (NSRect)f
|
||||
{
|
||||
_frame = f;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewFlowLayoutInvalidationContext
|
||||
|
||||
- (instancetype) init
|
||||
|
@ -384,7 +373,7 @@
|
|||
CGFloat mis = 0.0;
|
||||
CGFloat h = 0.0, w = 0.0, x = 0.0, y = 0.0;
|
||||
NSRect f = NSZeroRect;
|
||||
NSRect vf = [_collectionView frame];
|
||||
NSRect vf = [_collectionView frame]; // needed for reflow...
|
||||
|
||||
// Item size...
|
||||
if ([d respondsToSelector: @selector(collectionView:layout:sizeForItemAtIndexPath:)])
|
||||
|
@ -450,16 +439,8 @@
|
|||
f = NSMakeRect(x, y, w, h);
|
||||
}
|
||||
|
||||
// Resize parent view...
|
||||
if (y + h > vf.size.height)
|
||||
{
|
||||
vf.size.height = y + h;
|
||||
[_collectionView _setFrameWithoutTile: vf];
|
||||
}
|
||||
|
||||
// Build attrs object...
|
||||
[attrs setFrame: f];
|
||||
[attrs setHidden: NO];
|
||||
[attrs setZIndex: 0];
|
||||
[attrs setSize: sz];
|
||||
[attrs setHidden: NO];
|
||||
|
|
|
@ -206,7 +206,6 @@
|
|||
{
|
||||
NSCollectionViewLayoutAttributes *attrs = AUTORELEASE([[NSCollectionViewLayoutAttributes alloc] init]);
|
||||
NSSize sz = NSZeroSize;
|
||||
id <NSCollectionViewDelegateFlowLayout> d = (id <NSCollectionViewDelegateFlowLayout>)[_collectionView delegate];
|
||||
NSInteger s = [indexPath section]; // + _ds;
|
||||
NSInteger r = [indexPath item]; // + _dr;
|
||||
NSEdgeInsets si;
|
||||
|
@ -214,57 +213,11 @@
|
|||
CGFloat mis = 0.0;
|
||||
CGFloat h = 0.0, w = 0.0, x = 0.0, y = 0.0;
|
||||
NSRect f = NSZeroRect;
|
||||
NSRect vf = [_collectionView frame];
|
||||
|
||||
// Item size...
|
||||
if ([d respondsToSelector: @selector(collectionView:layout:sizeForItemAtIndexPath:)])
|
||||
{
|
||||
sz = [d collectionView: _collectionView
|
||||
layout: self
|
||||
sizeForItemAtIndexPath: indexPath];
|
||||
|
||||
if (sz.width > _maxiumumItemSize.width &&
|
||||
}
|
||||
else
|
||||
{
|
||||
sz = [self itemSize];
|
||||
}
|
||||
|
||||
// Inset
|
||||
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];
|
||||
}
|
||||
sz = [self minimumItemSize];
|
||||
si = [self margins];
|
||||
mls = [self minimumInteritemSpacing];
|
||||
mis = [self minimumInteritemSpacing];
|
||||
|
||||
// Calculations...
|
||||
h = sz.height;
|
||||
|
@ -273,25 +226,8 @@
|
|||
y = (s * h) + si.top + mls;
|
||||
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);
|
||||
}
|
||||
|
||||
// Resize parent view...
|
||||
if (y + h > vf.size.height)
|
||||
{
|
||||
vf.size.height = y + h;
|
||||
[_collectionView _setFrameWithoutTile: vf];
|
||||
}
|
||||
|
||||
// Build attrs object...
|
||||
[attrs setFrame: f];
|
||||
[attrs setHidden: NO];
|
||||
[attrs setZIndex: 0];
|
||||
[attrs setSize: sz];
|
||||
[attrs setHidden: NO];
|
||||
|
|
Loading…
Reference in a new issue