| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/base/cocoa/controls/blue_label_button.h" | 5 #import "ui/base/cocoa/controls/blue_label_button.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "skia/ext/skia_utils_mac.h" | 8 #include "skia/ext/skia_utils_mac.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/base/cocoa/scoped_cg_context_smooth_fonts.h" | 10 #include "ui/base/cocoa/scoped_cg_context_smooth_fonts.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 const SkColor kHoverColor = SkColorSetRGB(0x55, 0x8f, 0xf3); | 22 const SkColor kHoverColor = SkColorSetRGB(0x55, 0x8f, 0xf3); |
| 23 const SkColor kPressedColor = SkColorSetRGB(0x42, 0x79, 0xd8); | 23 const SkColor kPressedColor = SkColorSetRGB(0x42, 0x79, 0xd8); |
| 24 | 24 |
| 25 const SkColor kInnerRingColor = SkColorSetRGB(0x64, 0x9e, 0xff); | 25 const SkColor kInnerRingColor = SkColorSetRGB(0x64, 0x9e, 0xff); |
| 26 const SkColor kFocusInnerRingColor = SkColorSetRGB(0xad, 0xcc, 0xff); | 26 const SkColor kFocusInnerRingColor = SkColorSetRGB(0xad, 0xcc, 0xff); |
| 27 const SkColor kPressInnerRingColor = SkColorSetRGB(0x3f, 0x73, 0xcd); | 27 const SkColor kPressInnerRingColor = SkColorSetRGB(0x3f, 0x73, 0xcd); |
| 28 | 28 |
| 29 const SkColor kOuterRingColor = SkColorSetRGB(0x2b, 0x67, 0xce); | 29 const SkColor kOuterRingColor = SkColorSetRGB(0x2b, 0x67, 0xce); |
| 30 const SkColor kPressOuterRingColor = SkColorSetRGB(0x23, 0x52, 0xa2); | 30 const SkColor kPressOuterRingColor = SkColorSetRGB(0x23, 0x52, 0xa2); |
| 31 | 31 |
| 32 const int kFontSizeDelta = ui::ResourceBundle::kSmallFontDelta; |
| 33 |
| 32 @interface BlueLabelButtonCell : NSButtonCell | 34 @interface BlueLabelButtonCell : NSButtonCell |
| 33 | 35 |
| 34 + (NSAttributedString*)generateAttributedString:(NSString*)buttonText; | 36 + (NSAttributedString*)generateAttributedString:(NSString*)buttonText; |
| 35 | 37 |
| 36 @end | 38 @end |
| 37 | 39 |
| 38 @implementation BlueLabelButton | 40 @implementation BlueLabelButton |
| 39 | 41 |
| 40 + (Class)cellClass { | 42 + (Class)cellClass { |
| 41 return [BlueLabelButtonCell class]; | 43 return [BlueLabelButtonCell class]; |
| 42 } | 44 } |
| 43 | 45 |
| 44 - (id)initWithFrame:(NSRect)frameRect { | 46 - (id)initWithFrame:(NSRect)frameRect { |
| 45 if ((self = [super initWithFrame:frameRect])) { | 47 if ((self = [super initWithFrame:frameRect])) { |
| 46 [self setBezelStyle:NSSmallSquareBezelStyle]; | 48 [self setBezelStyle:NSSmallSquareBezelStyle]; |
| 47 } | 49 } |
| 48 return self; | 50 return self; |
| 49 } | 51 } |
| 50 | 52 |
| 51 @end | 53 @end |
| 52 | 54 |
| 53 @implementation BlueLabelButtonCell | 55 @implementation BlueLabelButtonCell |
| 54 | 56 |
| 55 + (NSAttributedString*)generateAttributedString:(NSString*)buttonText { | 57 + (NSAttributedString*)generateAttributedString:(NSString*)buttonText { |
| 56 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 58 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 57 NSFont* buttonFont = rb.GetFontList(ui::ResourceBundle::SmallFont). | 59 NSFont* buttonFont = rb.GetFontWithDelta(kFontSizeDelta).GetNativeFont(); |
| 58 GetPrimaryFont().GetNativeFont(); | |
| 59 base::scoped_nsobject<NSMutableParagraphStyle> buttonTextParagraphStyle( | 60 base::scoped_nsobject<NSMutableParagraphStyle> buttonTextParagraphStyle( |
| 60 [[NSMutableParagraphStyle alloc] init]); | 61 [[NSMutableParagraphStyle alloc] init]); |
| 61 [buttonTextParagraphStyle setAlignment:NSCenterTextAlignment]; | 62 [buttonTextParagraphStyle setAlignment:NSCenterTextAlignment]; |
| 62 | 63 |
| 63 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); | 64 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
| 64 [shadow setShadowOffset:NSMakeSize(0, -1)]; | 65 [shadow setShadowOffset:NSMakeSize(0, -1)]; |
| 65 [shadow setShadowBlurRadius:0]; | 66 [shadow setShadowBlurRadius:0]; |
| 66 [shadow setShadowColor:skia::SkColorToSRGBNSColor(kTextShadowColor)]; | 67 [shadow setShadowColor:skia::SkColorToSRGBNSColor(kTextShadowColor)]; |
| 67 | 68 |
| 68 NSDictionary* buttonTextAttributes = @{ | 69 NSDictionary* buttonTextAttributes = @{ |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 1, 1) | 143 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 1, 1) |
| 143 xRadius:kCornerRadius | 144 xRadius:kCornerRadius |
| 144 yRadius:kCornerRadius] fill]; | 145 yRadius:kCornerRadius] fill]; |
| 145 [centerColor set]; | 146 [centerColor set]; |
| 146 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 2, 2) | 147 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 2, 2) |
| 147 xRadius:kCornerRadius | 148 xRadius:kCornerRadius |
| 148 yRadius:kCornerRadius] fill]; | 149 yRadius:kCornerRadius] fill]; |
| 149 } | 150 } |
| 150 | 151 |
| 151 @end | 152 @end |
| OLD | NEW |