diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-21 20:07:31 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-21 20:07:31 +0000 |
commit | 9b5fe303ff7f97595594e1dec04ce5b96610c748 (patch) | |
tree | d96383706e3318e7255155cd8db3a1f657f5b819 | |
parent | af19338e9e281cb36b94c198a95d1e9a760e767b (diff) | |
download | chromium_src-9b5fe303ff7f97595594e1dec04ce5b96610c748.zip chromium_src-9b5fe303ff7f97595594e1dec04ce5b96610c748.tar.gz chromium_src-9b5fe303ff7f97595594e1dec04ce5b96610c748.tar.bz2 |
[Mac] UI changes for the Browser Actions toolbar container.
o Grippy is hidden for now pending new UI. You can still resize just fine.
o The right divider is removed since the wrench menu is now always being shown.
TEST=none
BUG=45764
Review URL: http://codereview.chromium.org/2863013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50375 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 24 insertions, 100 deletions
diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib index f1f56de..a7d65cf 100644 --- a/chrome/app/nibs/Toolbar.xib +++ b/chrome/app/nibs/Toolbar.xib @@ -3,7 +3,7 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">9L31a</string> - <string key="IBDocument.InterfaceBuilderVersion">677</string> + <string key="IBDocument.InterfaceBuilderVersion">680</string> <string key="IBDocument.AppKitVersion">949.54</string> <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> @@ -42,7 +42,7 @@ <object class="NSCustomView" id="421615633"> <reference key="NSNextResponder" ref="928520650"/> <int key="NSvFlags">-2147483383</int> - <string key="NSFrame">{{574, 0}, {0.777771, 36}}</string> + <string key="NSFrame">{{570, 0}, {1, 36}}</string> <reference key="NSSuperview" ref="928520650"/> <string key="NSClassName">BrowserActionsContainerView</string> </object> @@ -347,7 +347,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBObjectRecord"> <int key="objectID">0</int> - <object class="NSArray" key="object" id="588411309"> + <object class="NSArray" key="object" id="810617569"> <bool key="EncodedWithXMLCoder">YES</bool> </object> <reference key="children" ref="1000"/> @@ -356,19 +356,19 @@ <object class="IBObjectRecord"> <int key="objectID">-2</int> <reference key="object" ref="1001"/> - <reference key="parent" ref="588411309"/> + <reference key="parent" ref="810617569"/> <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="1003"/> - <reference key="parent" ref="588411309"/> + <reference key="parent" ref="810617569"/> <string key="objectName">First Responder</string> </object> <object class="IBObjectRecord"> <int key="objectID">-3</int> <reference key="object" ref="1004"/> - <reference key="parent" ref="588411309"/> + <reference key="parent" ref="810617569"/> <string key="objectName">Application</string> </object> <object class="IBObjectRecord"> @@ -384,7 +384,7 @@ <reference ref="602421009"/> <reference ref="421615633"/> </object> - <reference key="parent" ref="588411309"/> + <reference key="parent" ref="810617569"/> </object> <object class="IBObjectRecord"> <int key="objectID">2</int> @@ -473,12 +473,12 @@ <object class="IBObjectRecord"> <int key="objectID">122</int> <reference key="object" ref="1044322163"/> - <reference key="parent" ref="588411309"/> + <reference key="parent" ref="810617569"/> </object> <object class="IBObjectRecord"> <int key="objectID">130</int> <reference key="object" ref="306232897"/> - <reference key="parent" ref="588411309"/> + <reference key="parent" ref="810617569"/> </object> <object class="IBObjectRecord"> <int key="objectID">144</int> @@ -534,7 +534,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{175, 552}, {618, 36}}</string> + <string>{{370, 714}, {618, 36}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="YES"/> <string>ClickHoldButtonCell</string> @@ -809,7 +809,6 @@ <string>forwardButton_</string> <string>homeButton_</string> <string>locationBar_</string> - <string>pageButton_</string> <string>reloadButton_</string> <string>resizeDelegate_</string> <string>wrenchButton_</string> @@ -821,7 +820,6 @@ <string>DelayedMenuButton</string> <string>NSButton</string> <string>AutocompleteTextField</string> - <string>MenuButton</string> <string>NSButton</string> <string>id</string> <string>MenuButton</string> diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.h b/chrome/browser/cocoa/extensions/browser_actions_container_view.h index a1184e2..8569ece 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view.h +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.h @@ -37,9 +37,6 @@ extern NSString* const kBrowserActionGrippyDragFinishedNotification; // The maximum width of the container. CGFloat maxWidth_; - // Whether there is a border to the right of the last Browser Action. - BOOL rightBorderShown_; - // Whether the container is currently being resized by the user. BOOL userIsResizing_; @@ -80,7 +77,6 @@ extern NSString* const kBrowserActionGrippyDragFinishedNotification; @property(nonatomic,getter=isResizable) BOOL resizable; @property(nonatomic) CGFloat maxWidth; @property(readonly, nonatomic) BOOL userIsResizing; -@property(nonatomic) BOOL rightBorderShown; @end diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm index cf5087a..4fa7b15a 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm @@ -18,24 +18,14 @@ NSString* const kBrowserActionGrippyDragFinishedNotification = namespace { const CGFloat kAnimationDuration = 0.2; -const CGFloat kGrippyLowerPadding = 4.0; -const CGFloat kGrippyUpperPadding = 8.0; -const CGFloat kGrippyWidth = 10.0; -const CGFloat kLowerPadding = 5.0; +const CGFloat kGrippyWidth = 8.0; const CGFloat kMinimumContainerWidth = 10.0; -const CGFloat kRightBorderXOffset = -1.0; -const CGFloat kRightBorderWidth = 1.0; -const CGFloat kRightBorderGrayscale = 0.5; -const CGFloat kUpperPadding = 9.0; } // namespace @interface BrowserActionsContainerView(Private) // Returns the cursor that should be shown when hovering over the grippy based // on |canDragLeft_| and |canDragRight_|. - (NSCursor*)appropriateCursorForGrippy; -// Draws the area that the user can use to resize the container. Currently, two -// vertical "grip" bars. -- (void)drawGrippy; @end @implementation BrowserActionsContainerView @@ -46,7 +36,6 @@ const CGFloat kUpperPadding = 9.0; @synthesize grippyPinned = grippyPinned_; @synthesize maxWidth = maxWidth_; @synthesize userIsResizing = userIsResizing_; -@synthesize rightBorderShown = rightBorderShown_; #pragma mark - #pragma mark Overridden Class Functions @@ -73,29 +62,6 @@ const CGFloat kUpperPadding = 9.0; return resizable_; } -- (void)drawRect:(NSRect)dirtyRect { - if (rightBorderShown_) { - NSRect bounds = [self bounds]; - NSColor* middleColor = - [NSColor colorWithCalibratedWhite:kRightBorderGrayscale alpha:1.0]; - NSColor* endPointColor = - [NSColor colorWithCalibratedWhite:kRightBorderGrayscale alpha:0.0]; - scoped_nsobject<NSGradient> borderGradient([[NSGradient alloc] - initWithColorsAndLocations:endPointColor, (CGFloat)0.0, - middleColor, (CGFloat)0.5, - endPointColor, (CGFloat)1.0, - nil]); - CGFloat xPos = bounds.origin.x + bounds.size.width - kRightBorderWidth + - kRightBorderXOffset; - NSRect borderRect = NSMakeRect(xPos, kLowerPadding, kRightBorderWidth, - bounds.size.height - kUpperPadding); - [borderGradient drawInRect:borderRect angle:90.0]; - } - - if (resizable_) - [self drawGrippy]; -} - - (void)resetCursorRects { [self discardCursorRects]; [self addCursorRect:grippyRect_ cursor:[self appropriateCursorForGrippy]]; @@ -215,25 +181,4 @@ const CGFloat kUpperPadding = 9.0; return retVal; } -- (void)drawGrippy { - NSRect grippyRect = NSMakeRect(0.0, kLowerPadding + kGrippyLowerPadding, 1.0, - [self bounds].size.height - kUpperPadding - kGrippyUpperPadding); - [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; - NSRectFill(grippyRect); - - [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set]; - grippyRect.origin.x += 1.0; - NSRectFill(grippyRect); - - grippyRect.origin.x += 1.0; - - [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; - grippyRect.origin.x += 1.0; - NSRectFill(grippyRect); - - [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set]; - grippyRect.origin.x += 1.0; - NSRectFill(grippyRect); -} - @end diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm index b3ba5c3..0b9a9cc 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm @@ -40,10 +40,8 @@ const CGFloat kAnimationDuration = 0.2; const CGFloat kButtonOpacityLeadPadding = 5.0; const CGFloat kChevronHeight = 28.0; const CGFloat kChevronLowerPadding = 5.0; -const CGFloat kChevronRightPadding = 5.0; const CGFloat kChevronWidth = 14.0; -const CGFloat kContainerPadding = 2.0; -const CGFloat kGrippyXOffset = 8.0; +const CGFloat kGrippyXOffset = 7.0; } // namespace @interface BrowserActionsController(Private) @@ -345,7 +343,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, profile_->GetPrefs()->GetReal(prefs::kBrowserActionContainerWidth); if (predefinedWidth != 0) { int iconWidth = kBrowserActionWidth + kBrowserActionButtonPadding; - int extraWidth = kContainerPadding + kChevronWidth; + int extraWidth = kChevronWidth; toolbarModel_->SetVisibleIconCount( (predefinedWidth - extraWidth) / iconWidth); } @@ -552,22 +550,19 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, - (CGFloat)containerWidthWithButtonCount:(NSUInteger)buttonCount { CGFloat width = 0.0; if (buttonCount > 0) { - width = kGrippyXOffset + kContainerPadding + + width = kGrippyXOffset + (buttonCount * (kBrowserActionWidth + kBrowserActionButtonPadding)); } // Make room for the chevron if any buttons are hidden. - if ([self buttonCount] != [self visibleButtonCount]) { + if ([self buttonCount] != [self visibleButtonCount]) width += kChevronWidth + kBrowserActionButtonPadding; - // Add extra padding if all buttons are hidden. - if ([self visibleButtonCount] == 0) - width += 3 * kBrowserActionButtonPadding; - } + return width; } - (NSUInteger)containerButtonCapacity { CGFloat containerWidth = [self savedWidth]; - return (containerWidth - kGrippyXOffset + kContainerPadding) / + return (containerWidth - kGrippyXOffset) / (kBrowserActionWidth + kBrowserActionButtonPadding); } @@ -733,7 +728,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, } - (void)updateChevronPositionInFrame:(NSRect)frame { - CGFloat xPos = NSWidth(frame) - kChevronWidth - kChevronRightPadding; + CGFloat xPos = NSWidth(frame) - kChevronWidth; NSRect buttonFrame = NSMakeRect(xPos, kChevronLowerPadding, kChevronWidth, diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm index 5c28d66..a17948d 100644 --- a/chrome/browser/cocoa/toolbar_controller.mm +++ b/chrome/browser/cocoa/toolbar_controller.mm @@ -55,10 +55,6 @@ NSString* const kWrenchButtonImageName = @"menu_chrome_Template.pdf"; // Height of the toolbar in pixels when the bookmark bar is closed. const CGFloat kBaseToolbarHeight = 36.0; -// The distance from the location bar to the Browser Actions container -// in pixels. -const CGFloat kBrowserActionsContainerLeftPadding = 5.0; - // The minimum width of the location bar in pixels. const CGFloat kMinimumLocationBarWidth = 100.0; @@ -558,9 +554,6 @@ class PrefObserverBridge : public NotificationObserver { NSWidth([browserActionsContainerView_ frame]); if (containerWidth > 0.0) [self adjustLocationSizeBy:(containerWidth * -1) animate:NO]; - // Right border should always be visible because wrench menu can no longer - // hide. - [browserActionsContainerView_ setRightBorderShown:YES]; } - (void)adjustBrowserActionsContainerForNewWindow: @@ -592,22 +585,20 @@ class PrefObserverBridge : public NotificationObserver { - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { CGFloat locationBarXPos = NSMaxX([locationBar_ frame]); - CGFloat leftPadding; + CGFloat leftDistance; if ([browserActionsContainerView_ isHidden]) { CGFloat edgeXPos = [wrenchButton_ frame].origin.x; - leftPadding = edgeXPos - locationBarXPos; + leftDistance = edgeXPos - locationBarXPos; } else { NSRect containerFrame = animate ? [browserActionsContainerView_ animationEndFrame] : [browserActionsContainerView_ frame]; - leftPadding = containerFrame.origin.x - locationBarXPos; - } - if (leftPadding != kBrowserActionsContainerLeftPadding) { - CGFloat dX = leftPadding - kBrowserActionsContainerLeftPadding; - [self adjustLocationSizeBy:dX animate:animate]; + leftDistance = containerFrame.origin.x - locationBarXPos; } + if (leftDistance != 0.0) + [self adjustLocationSizeBy:leftDistance animate:animate]; } - (void)maintainMinimumLocationBarWidth { @@ -633,8 +624,7 @@ class PrefObserverBridge : public NotificationObserver { NSRect containerFrame = [browserActionsContainerView_ frame]; // Determine how much the container needs to move in case it's overlapping // with the location bar. - CGFloat dX = NSMaxX([locationBar_ frame]) - - containerFrame.origin.x + kBrowserActionsContainerLeftPadding; + CGFloat dX = NSMaxX([locationBar_ frame]) - containerFrame.origin.x; containerFrame = NSOffsetRect(containerFrame, dX, 0); containerFrame.size.width -= dX; [browserActionsContainerView_ setFrame:containerFrame]; |