Commit eab083a4 authored by sail@chromium.org's avatar sail@chromium.org

Use bold for default constrained window button

Screenshot: http://i.imgur.com/G5246.png

BUG=158847


Review URL: https://chromiumcodereview.appspot.com/11348343

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170773 0039d316-1c4b-4281-b951-d872f2087c98
parent b271b9e7
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
#include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/key_equivalent_constants.h"
#include "skia/ext/skia_utils_mac.h" #include "skia/ext/skia_utils_mac.h"
#import "third_party/molokocacao/NSBezierPath+MCAdditions.h" #import "third_party/molokocacao/NSBezierPath+MCAdditions.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
...@@ -79,6 +80,7 @@ NSColor* GetButtonBorderColor(ButtonState button_state) { ...@@ -79,6 +80,7 @@ NSColor* GetButtonBorderColor(ButtonState button_state) {
} }
NSAttributedString* GetButtonAttributedString(NSString* title, NSAttributedString* GetButtonAttributedString(NSString* title,
NSString* key_equivalent,
ButtonState button_state) { ButtonState button_state) {
const SkColor text_color[] = {0xFF333333, 0XFF000000, 0xFF000000, 0xFFAAAAAA}; const SkColor text_color[] = {0xFF333333, 0XFF000000, 0xFF000000, 0xFFAAAAAA};
// The shadow color should be 0xFFF0F0F0 but that doesn't show up so use // The shadow color should be 0xFFF0F0F0 but that doesn't show up so use
...@@ -96,8 +98,14 @@ NSAttributedString* GetButtonAttributedString(NSString* title, ...@@ -96,8 +98,14 @@ NSAttributedString* GetButtonAttributedString(NSString* title,
[[NSMutableParagraphStyle alloc] init]); [[NSMutableParagraphStyle alloc] init]);
[paragraphStyle setAlignment:NSCenterTextAlignment]; [paragraphStyle setAlignment:NSCenterTextAlignment];
NSFont* font = nil;
if ([key_equivalent isEqualToString:kKeyEquivalentReturn])
font = [NSFont boldSystemFontOfSize:12];
else
font = [NSFont systemFontOfSize:12];
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:12], NSFontAttributeName, font, NSFontAttributeName,
gfx::SkColorToCalibratedNSColor(text_color[button_state]), gfx::SkColorToCalibratedNSColor(text_color[button_state]),
NSForegroundColorAttributeName, NSForegroundColorAttributeName,
shadow.get(), NSShadowAttributeName, shadow.get(), NSShadowAttributeName,
...@@ -212,15 +220,15 @@ NSAttributedString* GetButtonAttributedString(NSString* title, ...@@ -212,15 +220,15 @@ NSAttributedString* GetButtonAttributedString(NSString* title,
[GetButtonBorderColor(buttonState) set]; [GetButtonBorderColor(buttonState) set];
[path stroke]; [path stroke];
[self drawTitle:GetButtonAttributedString([self title], buttonState) NSAttributedString* title = GetButtonAttributedString(
withFrame:frame [self title], [self keyEquivalent], buttonState);
inView:controlView]; [self drawTitle:title withFrame:frame inView:controlView];
} }
- (NSSize)cellSize { - (NSSize)cellSize {
NSAttributedString* attributedString = NSAttributedString* title = GetButtonAttributedString(
GetButtonAttributedString([self title], BUTTON_NORMAL); [self title], [self keyEquivalent], [self buttonState]);
NSSize size = [attributedString size]; NSSize size = [title size];
size.height = std::max(size.height, kButtonHeight); size.height = std::max(size.height, kButtonHeight);
size.width += kButtonPaddingX * 2; size.width += kButtonPaddingX * 2;
return size; return size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment