From cfc46edfb80ea9b48bbe5f6687ca73bb3f34cd10 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 3 Dec 2009 01:27:53 -0800 Subject: [PATCH] Fix for properly positioning pop up button menus. Reviewed by me. --- AppKit/CPMenuItem/_CPMenuItemStandardView.j | 5 +++++ AppKit/CPPopUpButton.j | 13 +++++++++---- AppKit/Themes/BlendKit/BKShowcaseController.j | 12 ++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/AppKit/CPMenuItem/_CPMenuItemStandardView.j b/AppKit/CPMenuItem/_CPMenuItemStandardView.j index 29e806f0a..a699f8491 100644 --- a/AppKit/CPMenuItem/_CPMenuItemStandardView.j +++ b/AppKit/CPMenuItem/_CPMenuItemStandardView.j @@ -58,6 +58,11 @@ var SUBMENU_INDICATOR_COLOR = nil, return [[self alloc] init]; } ++ (float)_standardLeftMargin +{ + return LEFT_MARGIN + STATE_COLUMN_WIDTH; +} + - (id)initWithFrame:(CGRect)aFrame { self = [super initWithFrame:aFrame]; diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index 6819794b9..3739be9ea 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -641,7 +641,8 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down"); [self highlight:YES]; - var bounds = [self bounds]; + var bounds = [self bounds], + minimumWidth = CGRectGetWidth(bounds); if ([self pullsDown]) { @@ -650,11 +651,15 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down"); } else { - var positionedItem = [self selectedItem], - location = CGPointMake(0.0, 0.0); + var contentRect = [self contentRectForBounds:bounds], + positionedItem = [self selectedItem], + standardLeftMargin = [_CPMenuItemStandardView _standardLeftMargin], + location = CGPointMake(CGRectGetMinX(contentRect) - standardLeftMargin, 0.0); + + minimumWidth += standardLeftMargin; } - [[self menu] setMinimumWidth:CGRectGetWidth(bounds)]; + [[self menu] setMinimumWidth:minimumWidth]; [[self menu] popUpMenuPositioningItem:positionedItem diff --git a/AppKit/Themes/BlendKit/BKShowcaseController.j b/AppKit/Themes/BlendKit/BKShowcaseController.j index 90f9b8c3b..36e663b4f 100644 --- a/AppKit/Themes/BlendKit/BKShowcaseController.j +++ b/AppKit/Themes/BlendKit/BKShowcaseController.j @@ -177,8 +177,8 @@ var BKLearnMoreToolbarItemIdentifier = @"BKLearnMoreToolbarItemId var width = CGRectGetWidth([popUpButton frame]); - [toolbarItem setMinSize:CGSizeMake(width + 20.0, 32.0)]; - [toolbarItem setMaxSize:CGSizeMake(width + 20.0, 32.0)]; + [toolbarItem setMinSize:CGSizeMake(width + 20.0, 24.0)]; + [toolbarItem setMaxSize:CGSizeMake(width + 20.0, 24.0)]; } else if (anItemIdentifier === BKBackgroundColorToolbarItemIdentifier) @@ -206,8 +206,8 @@ var BKLearnMoreToolbarItemIdentifier = @"BKLearnMoreToolbarItemId var width = CGRectGetWidth([popUpButton frame]); - [toolbarItem setMinSize:CGSizeMake(width, 32.0)]; - [toolbarItem setMaxSize:CGSizeMake(width, 32.0)]; + [toolbarItem setMinSize:CGSizeMake(width, 24.0)]; + [toolbarItem setMaxSize:CGSizeMake(width, 24.0)]; } else if (anItemIdentifier === BKLearnMoreToolbarItemIdentifier) { @@ -227,8 +227,8 @@ var BKLearnMoreToolbarItemIdentifier = @"BKLearnMoreToolbarItemId var width = CGRectGetWidth([button frame]); - [toolbarItem setMinSize:CGSizeMake(width, 32.0)]; - [toolbarItem setMaxSize:CGSizeMake(width, 32.0)]; + [toolbarItem setMinSize:CGSizeMake(width, 24.0)]; + [toolbarItem setMaxSize:CGSizeMake(width, 24.0)]; } return toolbarItem;