diff --git a/Source/GSToolbarView.m b/Source/GSToolbarView.m index 44664340f..588ef7110 100644 --- a/Source/GSToolbarView.m +++ b/Source/GSToolbarView.m @@ -583,15 +583,13 @@ static void initSystemExtensionsColors(void) - (void) _takeInAccountFlexibleSpaces { NSArray *items = [_toolbar items]; - NSEnumerator *e; + NSEnumerator *e = [items objectEnumerator]; NSToolbarItem *item; NSView *backView; NSRect lastBackViewFrame; float lengthAvailable; - unsigned int flexibleSpaceItemsNumber; - unsigned int resizableItemsNumber; - float resizableSpaceFromMins; - BOOL mustAdjustNext; + unsigned int flexibleSpaceItemsNumber = 0; + BOOL mustAdjustNext = NO; float x = 0; if ([items count] == 0) @@ -603,36 +601,17 @@ static void initSystemExtensionsColors(void) if (lengthAvailable < 1) return; - - /* search for flexible spaces or for items which are resizable */ - flexibleSpaceItemsNumber = 0; - resizableItemsNumber = 0; - resizableSpaceFromMins = 0; - e = [items objectEnumerator]; while ((item = [e nextObject]) != nil) + { + if ([item _isFlexibleSpace]) { - float currWidth; - float minWidth; - - currWidth = [[item _backView] frame].size.width; - minWidth = [item minSize].width; - if ([item _isFlexibleSpace]) - { - flexibleSpaceItemsNumber++; - } - else if (([item maxSize].width > minWidth) && (currWidth > minWidth)) - { - resizableItemsNumber++; - resizableSpaceFromMins += currWidth - minWidth; - NSLog(@"%@: min, curr width: %f %f", [item itemIdentifier], minWidth, currWidth); - } + flexibleSpaceItemsNumber++; } - NSLog(@"length available 1: %f", lengthAvailable); - NSLog(@"resizable space %f in %d items", resizableSpaceFromMins, resizableItemsNumber); - if (flexibleSpaceItemsNumber < 1 && resizableSpaceFromMins <= 0) + } + + if (lengthAvailable < flexibleSpaceItemsNumber) return; - mustAdjustNext = NO; e = [items objectEnumerator]; while ((item = [e nextObject]) != nil) { @@ -655,47 +634,7 @@ static void initSystemExtensionsColors(void) } x += [backView frame].size.width; } - - lastBackViewFrame = [[[items lastObject] _backView] frame]; - lengthAvailable = [self frame].size.width - NSMaxX(lastBackViewFrame); - NSLog(@"length available 2: %f", lengthAvailable); - if (lengthAvailable <= 0 || resizableItemsNumber < 0) - return; - /* we adjusted all the flexible spaces, now we can try to adjust views to their minimum */ - mustAdjustNext = NO; - e = [items objectEnumerator]; - while ((item = [e nextObject]) != nil) - { - float currWidth; - float minWidth; - NSRect backViewFrame; - - backView = [item _backView]; - backViewFrame = [backView frame]; - currWidth = backViewFrame.size.width; - minWidth = [item minSize].width; - if (([item maxSize].width > minWidth) && (currWidth > minWidth)) - { - float newWidth; - - newWidth = currWidth - (lengthAvailable / resizableItemsNumber); - if (newWidth < minWidth) - newWidth = minWidth; - - [backView setFrame: NSMakeRect(x, backViewFrame.origin.y, - newWidth, - backViewFrame.size.height)]; - mustAdjustNext = YES; - } - else if (mustAdjustNext) - { - [backView setFrame: NSMakeRect(x, backViewFrame.origin.y, - backViewFrame.size.width, backViewFrame.size.height)]; - } - x += backViewFrame.size.width; - } - } - (void) _handleViewsVisibility