Skip to content
Snippets Groups Projects
Commit bad671d9 authored by rsesek@chromium.org's avatar rsesek@chromium.org
Browse files

[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
parent cbfc8a89
No related merge requests found
......@@ -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">
......@@ -1615,6 +1629,14 @@
<string key="minorKey"/>
</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>
......@@ -2211,6 +2233,27 @@
<string key="minorKey">Print.framework/Headers/PDEPluginInterface.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/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">
......
// 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_
// 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
// 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
......@@ -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',
......
......@@ -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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment