Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: ui/base/cocoa/controls/blue_label_button.mm

Issue 1508893003: Use proper namespace in skia/ext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | ui/gfx/image/image_skia_util_ios.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 56 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
57 NSFont* buttonFont = rb.GetFontList(ui::ResourceBundle::SmallFont). 57 NSFont* buttonFont = rb.GetFontList(ui::ResourceBundle::SmallFont).
58 GetPrimaryFont().GetNativeFont(); 58 GetPrimaryFont().GetNativeFont();
59 base::scoped_nsobject<NSMutableParagraphStyle> buttonTextParagraphStyle( 59 base::scoped_nsobject<NSMutableParagraphStyle> buttonTextParagraphStyle(
60 [[NSMutableParagraphStyle alloc] init]); 60 [[NSMutableParagraphStyle alloc] init]);
61 [buttonTextParagraphStyle setAlignment:NSCenterTextAlignment]; 61 [buttonTextParagraphStyle setAlignment:NSCenterTextAlignment];
62 62
63 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); 63 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
64 [shadow setShadowOffset:NSMakeSize(0, -1)]; 64 [shadow setShadowOffset:NSMakeSize(0, -1)];
65 [shadow setShadowBlurRadius:0]; 65 [shadow setShadowBlurRadius:0];
66 [shadow setShadowColor:gfx::SkColorToSRGBNSColor(kTextShadowColor)]; 66 [shadow setShadowColor:skia::SkColorToSRGBNSColor(kTextShadowColor)];
67 67
68 NSDictionary* buttonTextAttributes = @{ 68 NSDictionary* buttonTextAttributes = @{
69 NSParagraphStyleAttributeName : buttonTextParagraphStyle, 69 NSParagraphStyleAttributeName : buttonTextParagraphStyle,
70 NSFontAttributeName : buttonFont, 70 NSFontAttributeName : buttonFont,
71 NSForegroundColorAttributeName : [NSColor whiteColor], 71 NSForegroundColorAttributeName : [NSColor whiteColor],
72 NSShadowAttributeName : shadow.get() 72 NSShadowAttributeName : shadow.get()
73 }; 73 };
74 base::scoped_nsobject<NSAttributedString> attributedButtonText( 74 base::scoped_nsobject<NSAttributedString> attributedButtonText(
75 [[NSAttributedString alloc] initWithString:buttonText 75 [[NSAttributedString alloc] initWithString:buttonText
76 attributes:buttonTextAttributes]); 76 attributes:buttonTextAttributes]);
(...skipping 28 matching lines...) Expand all
105 inView:(NSView*)controlView { 105 inView:(NSView*)controlView {
106 NSColor* centerColor; 106 NSColor* centerColor;
107 NSColor* innerColor; 107 NSColor* innerColor;
108 NSColor* outerColor; 108 NSColor* outerColor;
109 HoverState hoverState = 109 HoverState hoverState =
110 [base::mac::ObjCCastStrict<HoverButton>(controlView) hoverState]; 110 [base::mac::ObjCCastStrict<HoverButton>(controlView) hoverState];
111 // Leave a sliver of height 1 for the button drop shadow. 111 // Leave a sliver of height 1 for the button drop shadow.
112 frame.size.height -= 1; 112 frame.size.height -= 1;
113 113
114 if (hoverState == kHoverStateMouseDown && [self isHighlighted]) { 114 if (hoverState == kHoverStateMouseDown && [self isHighlighted]) {
115 centerColor = gfx::SkColorToSRGBNSColor(kPressedColor); 115 centerColor = skia::SkColorToSRGBNSColor(kPressedColor);
116 innerColor = gfx::SkColorToSRGBNSColor(kPressInnerRingColor); 116 innerColor = skia::SkColorToSRGBNSColor(kPressInnerRingColor);
117 outerColor = gfx::SkColorToSRGBNSColor(kPressOuterRingColor); 117 outerColor = skia::SkColorToSRGBNSColor(kPressOuterRingColor);
118 } else { 118 } else {
119 centerColor = hoverState == kHoverStateMouseOver ? 119 centerColor = hoverState == kHoverStateMouseOver ?
120 gfx::SkColorToSRGBNSColor(kHoverColor) : 120 skia::SkColorToSRGBNSColor(kHoverColor) :
121 gfx::SkColorToSRGBNSColor(kDefaultColor); 121 skia::SkColorToSRGBNSColor(kDefaultColor);
122 innerColor = [self showsFirstResponder] ? 122 innerColor = [self showsFirstResponder] ?
123 gfx::SkColorToSRGBNSColor(kFocusInnerRingColor) : 123 skia::SkColorToSRGBNSColor(kFocusInnerRingColor) :
124 gfx::SkColorToSRGBNSColor(kInnerRingColor); 124 skia::SkColorToSRGBNSColor(kInnerRingColor);
125 outerColor = gfx::SkColorToSRGBNSColor(kOuterRingColor); 125 outerColor = skia::SkColorToSRGBNSColor(kOuterRingColor);
126 } 126 }
127 { 127 {
128 gfx::ScopedNSGraphicsContextSaveGState context; 128 gfx::ScopedNSGraphicsContextSaveGState context;
129 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); 129 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
130 [shadow setShadowOffset:NSMakeSize(0, -1)]; 130 [shadow setShadowOffset:NSMakeSize(0, -1)];
131 [shadow setShadowBlurRadius:1.0]; 131 [shadow setShadowBlurRadius:1.0];
132 [shadow setShadowColor:gfx::SkColorToSRGBNSColor(kShadowColor)]; 132 [shadow setShadowColor:skia::SkColorToSRGBNSColor(kShadowColor)];
133 [shadow set]; 133 [shadow set];
134 [outerColor set]; 134 [outerColor set];
135 135
136 [[NSBezierPath bezierPathWithRoundedRect:frame 136 [[NSBezierPath bezierPathWithRoundedRect:frame
137 xRadius:kCornerRadius 137 xRadius:kCornerRadius
138 yRadius:kCornerRadius] fill]; 138 yRadius:kCornerRadius] fill];
139 } 139 }
140 140
141 [innerColor set]; 141 [innerColor set];
142 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 1, 1) 142 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 1, 1)
143 xRadius:kCornerRadius 143 xRadius:kCornerRadius
144 yRadius:kCornerRadius] fill]; 144 yRadius:kCornerRadius] fill];
145 [centerColor set]; 145 [centerColor set];
146 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 2, 2) 146 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 2, 2)
147 xRadius:kCornerRadius 147 xRadius:kCornerRadius
148 yRadius:kCornerRadius] fill]; 148 yRadius:kCornerRadius] fill];
149 } 149 }
150 150
151 @end 151 @end
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | ui/gfx/image/image_skia_util_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698