Update to fix menu item sizes breaking on second open.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-11-20 23:34:21 -08:00
1 parent a4fdc50d1d
commit e3babe97e4
5 files changed
+29 -25

No files matched your search

+14 -18
View File
@@ -72,7 +72,7 @@ var STICKY_TIME_INTERVAL = 500,
{
if (!aMenuWindow || _CPMenuWindowPool.length >= _CPMenuWindowPoolCapacity)
return;
_CPMenuWindowPool.push(aMenuWindow);
}
@@ -338,24 +338,21 @@ var STICKY_TIME_INTERVAL = 500,
var count = _menuWindowStack.length,
index = count;
// Hide all menus up to the base menu...
while (index--)
{
var menuWindow = _menuWindowStack[index];
if ([menuWindow menu] !== baseMenu)
continue;
if ([menuWindow menu] === baseMenu)
break;
// If we're already showing this menu, then hide all submenus...
while (count-- > index + 1)
{
var menuWindow = _menuWindowStack[count];
[[menuWindow menu] _highlightItemAtIndex:CPNotFound];
[menuWindow orderOut:self];
[menuWindow setMenu:nil];
[_CPMenuWindow poolMenuWindow:menuWindow];
[_menuWindowStack removeObjectAtIndex:count];
}
[menuWindow orderOut:self];
[menuWindow setMenu:nil];
[_CPMenuWindow poolMenuWindow:menuWindow];
[_menuWindowStack removeObjectAtIndex:index];
}
if (!newMenu)
@@ -383,9 +380,11 @@ var STICKY_TIME_INTERVAL = 500,
var highlightedItem = [[_menuView menu] highlightedItem];
[menu _highlightItemAtIndex:CPNotFound];
// Hide all submenus.
[self showMenu:nil fromMenu:menu atPoint:nil];
[_menuWindowStack makeObjectsPerformSelector:@selector(orderOut:) withObject:self];
[self orderOut:self];
[self setMenu:nil];
var delegate = [menu delegate];
@@ -399,9 +398,6 @@ var STICKY_TIME_INTERVAL = 500,
postNotificationName:CPMenuDidEndTrackingNotification
object:menu];
// Clear these now so its faster next time around.
[_menuView setMenu:nil];
CPApp._activeMenu = nil;
return;
@@ -1,3 +1,7 @@
@import <AppKit/CPView.j>
@implementation _CPMenuItemSeparatorView : CPView
{
}
+7 -5
View File
@@ -1,5 +1,5 @@
var LEFT_MARGIN = 3.0,
RIGHT_MARGIN = 16.0,
RIGHT_MARGIN = 14.0 + 3.0,
STATE_COLUMN_WIDTH = 14.0,
INDENTATION_WIDTH = 17.0,
VERTICAL_MARGIN = 4.0,
@@ -16,7 +16,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
@implementation _CPMenuItemStandardView : CPView
{
CPMenuItem _menuItem @accessors(property = menuItem);
CPMenuItem _menuItem @accessors(property=menuItem);
CPFont _font;
CPColor _textColor;
@@ -90,7 +90,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
[_submenuIndicatorView setAutoresizingMask:CPViewMinXMargin];
[self addSubview:_submenuIndicatorView];
[self setAutoresizingMask:CPViewWidthSizable];
}
@@ -180,8 +180,10 @@ var SUBMENU_INDICATOR_COLOR = nil,
var submenuViewFrame = [_submenuIndicatorView frame];
height = MAX(height, CGRectGetHeight(submenuViewFrame));
submenuViewFrame.origin.x = x;
x += CGRectGetWidth(submenuViewFrame);
height = MAX(height, CGRectGetHeight(submenuViewFrame));
}
else
[_submenuIndicatorView setHidden:YES];
@@ -203,7 +205,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
[_submenuIndicatorView setFrame:submenuViewFrame];
}
_minSize = CGSizeMake(x + RIGHT_MARGIN + 3.0, height);
_minSize = CGSizeMake(x + RIGHT_MARGIN, height);
[self setAutoresizesSubviews:NO];
[self setFrameSize:_minSize];
+3 -1
View File
@@ -73,7 +73,7 @@ var _CPMenuItemSelectionColor = nil,
_isDirty = YES;
[self setAutoresizingMask:CPViewWidthSizable];
[self synchronizeWithMenuItem];
}
@@ -127,7 +127,9 @@ var _CPMenuItemSelectionColor = nil,
[_view update];
_minSize = [_view frame].size;
[self setAutoresizesSubviews:NO];
[self setFrameSize:_minSize];
[self setAutoresizesSubviews:YES];
}
- (CGFloat)overlapOffsetWidth
+1 -1
View File
@@ -644,7 +644,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
var menu = [self menu],
theWindow = [self window],
menuWindow = [_CPMenuWindow menuWindowWithMenu:menu font:[self font]];
[menuWindow setDelegate:self];
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];