diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-05 00:09:03 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-05 00:09:03 +0000 |
commit | bad671d9e43be274d926a2204b16e89b21cb7135 (patch) | |
tree | 8b9595a945ba434bbcec01407bd7a6b99dd2ba7a | |
parent | cbfc8a890278ae5f0fcc6e54ac169a7e068449b1 (diff) | |
download | chromium_src-bad671d9e43be274d926a2204b16e89b21cb7135.zip chromium_src-bad671d9e43be274d926a2204b16e89b21cb7135.tar.gz chromium_src-bad671d9e43be274d926a2204b16e89b21cb7135.tar.bz2 |
[Mac] Tweaks to the Wrench menu buttons.
This changes the two-tone background to an even gradient and changes the push
state of the buttons to use the blue selected menu item color.
BUG=none
TEST=visual
Review URL: http://codereview.chromium.org/3072021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55007 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/Toolbar.xib | 47 | ||||
-rw-r--r-- | chrome/browser/cocoa/wrench_menu_button_cell.h | 19 | ||||
-rw-r--r-- | chrome/browser/cocoa/wrench_menu_button_cell.mm | 46 | ||||
-rw-r--r-- | chrome/browser/cocoa/wrench_menu_button_cell_unittest.mm | 51 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 |
6 files changed, 164 insertions, 2 deletions
diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib index 6c8e1b8..05dab79 100644 --- a/chrome/app/nibs/Toolbar.xib +++ b/chrome/app/nibs/Toolbar.xib @@ -12,9 +12,9 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1"/> - <integer value="208"/> <integer value="211"/> + <integer value="208"/> + <integer value="1"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1168,12 +1168,16 @@ <string>161.IBPluginDependency</string> <string>162.IBPluginDependency</string> <string>163.IBPluginDependency</string> + <string>164.CustomClassName</string> <string>164.IBPluginDependency</string> + <string>165.CustomClassName</string> <string>165.IBPluginDependency</string> + <string>166.CustomClassName</string> <string>166.IBPluginDependency</string> <string>168.IBPluginDependency</string> <string>171.IBPluginDependency</string> <string>186.IBPluginDependency</string> + <string>187.CustomClassName</string> <string>187.IBPluginDependency</string> <string>189.IBPluginDependency</string> <string>2.CustomClassName</string> @@ -1182,12 +1186,15 @@ <string>211.IBPluginDependency</string> <string>212.CustomClassName</string> <string>212.IBPluginDependency</string> + <string>213.CustomClassName</string> <string>213.IBPluginDependency</string> <string>214.CustomClassName</string> <string>214.IBPluginDependency</string> + <string>215.CustomClassName</string> <string>215.IBPluginDependency</string> <string>216.CustomClassName</string> <string>216.IBPluginDependency</string> + <string>217.CustomClassName</string> <string>217.IBPluginDependency</string> <string>3.CustomClassName</string> <string>3.IBAttributePlaceholdersKey</string> @@ -1238,12 +1245,16 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>WrenchMenuButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>WrenchMenuButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>WrenchMenuButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>WrenchMenuButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>DelayedMenuButton</string> @@ -1259,12 +1270,15 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>MenuTrackedButton</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>WrenchMenuButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>MenuTrackedButton</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>WrenchMenuButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>MenuTrackedButton</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>WrenchMenuButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>ReloadButton</string> <object class="NSMutableDictionary"> @@ -1616,6 +1630,14 @@ </object> </object> <object class="IBPartialClassDescription"> + <string key="className">WrenchMenuButtonCell</string> + <string key="superclassName">NSButtonCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/wrench_menu_button_cell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">WrenchMenuController</string> <string key="superclassName">MenuController</string> <object class="NSMutableDictionary" key="actions"> @@ -2215,6 +2237,27 @@ <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CIImageProvider.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> <string key="minorKey">SecurityInterface.framework/Headers/SFAuthorizationView.h</string> </object> </object> diff --git a/chrome/browser/cocoa/wrench_menu_button_cell.h b/chrome/browser/cocoa/wrench_menu_button_cell.h new file mode 100644 index 0000000..1ce73a8 --- /dev/null +++ b/chrome/browser/cocoa/wrench_menu_button_cell.h @@ -0,0 +1,19 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_COCOA_WRENCH_MENU_BUTTON_CELL_H_ +#define CHROME_BROWSER_COCOA_WRENCH_MENU_BUTTON_CELL_H_ + +#import <Cocoa/Cocoa.h> + +// The WrenchMenuButtonCell overrides drawing the background gradient to use +// the same colors as NSSmallSquareBezelStyle but as a smooth gradient, rather +// than two blocks of colors. This also uses the blue menu highlight color for +// the pressed state. +@interface WrenchMenuButtonCell : NSButtonCell { +} + +@end + +#endif // CHROME_BROWSER_COCOA_WRENCH_MENU_BUTTON_CELL_H_ diff --git a/chrome/browser/cocoa/wrench_menu_button_cell.mm b/chrome/browser/cocoa/wrench_menu_button_cell.mm new file mode 100644 index 0000000..61edb5c --- /dev/null +++ b/chrome/browser/cocoa/wrench_menu_button_cell.mm @@ -0,0 +1,46 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "chrome/browser/cocoa/wrench_menu_button_cell.h" + +#include "base/scoped_nsobject.h" + +@implementation WrenchMenuButtonCell + +- (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { + [NSGraphicsContext saveGraphicsState]; + + // Inset the rect to match the appearance of the layout of interface builder. + // The bounding rect of buttons is actually larger than the display rect shown + // there. + frame = NSInsetRect(frame, 0.0, 1.0); + + // Stroking the rect gives a weak stroke. Filling and insetting gives a + // strong, un-anti-aliased border. + [[NSColor colorWithDeviceWhite:0.663 alpha:1.0] set]; + NSRectFill(frame); + frame = NSInsetRect(frame, 1.0, 1.0); + + NSColor* start = [NSColor whiteColor]; + NSColor* end = [NSColor colorWithDeviceWhite:0.922 alpha:1.0]; + if ([self isHighlighted]) { + start = [NSColor colorWithDeviceRed:0.396 green:0.641 blue:0.941 alpha:1.0]; + end = [NSColor selectedMenuItemColor]; + } + + scoped_nsobject<NSGradient> gradient( + [[NSGradient alloc] initWithStartingColor:start + endingColor:end]); + [gradient drawInRect:frame angle:90.0]; + + [NSGraphicsContext restoreGraphicsState]; +} + +- (NSBackgroundStyle)interiorBackgroundStyle { + if ([self isHighlighted]) + return NSBackgroundStyleDark; + return [super interiorBackgroundStyle]; +} + +@end diff --git a/chrome/browser/cocoa/wrench_menu_button_cell_unittest.mm b/chrome/browser/cocoa/wrench_menu_button_cell_unittest.mm new file mode 100644 index 0000000..e736fdc --- /dev/null +++ b/chrome/browser/cocoa/wrench_menu_button_cell_unittest.mm @@ -0,0 +1,51 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/scoped_nsobject.h" +#include "chrome/app/chrome_dll_resource.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#import "chrome/browser/cocoa/wrench_menu_button_cell.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" + +@interface TestWrenchMenuButton : NSButton +@end +@implementation TestWrenchMenuButton ++ (Class)cellClass { + return [WrenchMenuButtonCell class]; +} +@end + +namespace { + +class WrenchMenuButtonCellTest : public CocoaTest { + public: + void SetUp() { + CocoaTest::SetUp(); + + NSRect frame = NSMakeRect(10, 10, 50, 19); + button_.reset([[TestWrenchMenuButton alloc] initWithFrame:frame]); + [button_ setBezelStyle:NSSmallSquareBezelStyle]; + [[button_ cell] setControlSize:NSSmallControlSize]; + [button_ setTitle:@"Allays"]; + [button_ setButtonType:NSMomentaryPushInButton]; + } + + scoped_nsobject<NSButton> button_; +}; + +TEST_F(WrenchMenuButtonCellTest, Draw) { + ASSERT_TRUE(button_.get()); + [[test_window() contentView] addSubview:button_.get()]; + [button_ setNeedsDisplay:YES]; +} + +TEST_F(WrenchMenuButtonCellTest, DrawHighlight) { + ASSERT_TRUE(button_.get()); + [[test_window() contentView] addSubview:button_.get()]; + [button_ highlight:YES]; + [button_ setNeedsDisplay:YES]; +} + +} // namespace diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 5780bd3..54b790a 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1052,6 +1052,8 @@ 'browser/cocoa/web_drop_target.mm', 'browser/cocoa/window_size_autosaver.h', 'browser/cocoa/window_size_autosaver.mm', + 'browser/cocoa/wrench_menu_button_cell.h', + 'browser/cocoa/wrench_menu_button_cell.mm', 'browser/cocoa/wrench_menu_controller.h', 'browser/cocoa/wrench_menu_controller.mm', 'browser/command_line_pref_store.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index a547fac..b505d9c 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -901,6 +901,7 @@ 'browser/cocoa/view_resizer_pong.mm', 'browser/cocoa/web_drop_target_unittest.mm', 'browser/cocoa/window_size_autosaver_unittest.mm', + 'browser/cocoa/wrench_menu_button_cell_unittest.mm', 'browser/cocoa/wrench_menu_controller_unittest.mm', 'browser/config_dir_policy_provider_unittest.cc', 'browser/command_line_pref_store_unittest.cc', |