| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_button_cell.h" | 5 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_button_cell.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 8 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 9 | 9 |
| 10 @implementation WrenchMenuButtonCell | 10 @implementation WrenchMenuButtonCell |
| 11 | 11 |
| 12 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { | 12 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { |
| 13 gfx::ScopedNSGraphicsContextSaveGState scopedGState; | 13 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
| 14 | 14 |
| 15 // Inset the rect to match the appearance of the layout of interface builder. | 15 // Inset the rect to match the appearance of the layout of interface builder. |
| 16 // The bounding rect of buttons is actually larger than the display rect shown | 16 // The bounding rect of buttons is actually larger than the display rect shown |
| 17 // there. | 17 // there. |
| 18 frame = NSInsetRect(frame, 0.0, 1.0); | 18 frame = NSInsetRect(frame, 0.0, 1.0); |
| 19 | 19 |
| 20 // Stroking the rect gives a weak stroke. Filling and insetting gives a | 20 // Stroking the rect gives a weak stroke. Filling and insetting gives a |
| 21 // strong, un-anti-aliased border. | 21 // strong, un-anti-aliased border. |
| 22 [[NSColor colorWithDeviceWhite:0.663 alpha:1.0] set]; | 22 [[NSColor colorWithDeviceWhite:0.663 alpha:1.0] set]; |
| 23 NSRectFill(frame); | 23 NSRectFill(frame); |
| 24 frame = NSInsetRect(frame, 1.0, 1.0); | 24 frame = NSInsetRect(frame, 1.0, 1.0); |
| 25 | 25 |
| 26 // The default state should be a subtle gray gradient. | 26 // The default state should be a subtle gray gradient. |
| 27 if (![self isHighlighted]) { | 27 if (![self isHighlighted]) { |
| 28 NSColor* end = [NSColor colorWithDeviceWhite:0.922 alpha:1.0]; | 28 NSColor* end = [NSColor colorWithDeviceWhite:0.922 alpha:1.0]; |
| 29 scoped_nsobject<NSGradient> gradient( | 29 base::scoped_nsobject<NSGradient> gradient( |
| 30 [[NSGradient alloc] initWithStartingColor:[NSColor whiteColor] | 30 [[NSGradient alloc] initWithStartingColor:[NSColor whiteColor] |
| 31 endingColor:end]); | 31 endingColor:end]); |
| 32 [gradient drawInRect:frame angle:90.0]; | 32 [gradient drawInRect:frame angle:90.0]; |
| 33 } else { | 33 } else { |
| 34 // |+selectedMenuItemColor| appears to be a gradient, so just filling the | 34 // |+selectedMenuItemColor| appears to be a gradient, so just filling the |
| 35 // rect with that color produces the desired effect. | 35 // rect with that color produces the desired effect. |
| 36 [[NSColor selectedMenuItemColor] set]; | 36 [[NSColor selectedMenuItemColor] set]; |
| 37 NSRectFill(frame); | 37 NSRectFill(frame); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 - (NSBackgroundStyle)interiorBackgroundStyle { | 41 - (NSBackgroundStyle)interiorBackgroundStyle { |
| 42 if ([self isHighlighted]) | 42 if ([self isHighlighted]) |
| 43 return NSBackgroundStyleDark; | 43 return NSBackgroundStyleDark; |
| 44 return [super interiorBackgroundStyle]; | 44 return [super interiorBackgroundStyle]; |
| 45 } | 45 } |
| 46 | 46 |
| 47 @end | 47 @end |
| OLD | NEW |