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

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/constrained_window/constrained_window_button.h" 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" 8 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h"
9 #include "skia/ext/skia_utils_mac.h" 9 #include "skia/ext/skia_utils_mac.h"
10 #import "third_party/molokocacao/NSBezierPath+MCAdditions.h" 10 #import "third_party/molokocacao/NSBezierPath+MCAdditions.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 // The functions below use hex color values to make it easier to compare 41 // The functions below use hex color values to make it easier to compare
42 // the code with the spec. Table of hex values are also more readable 42 // the code with the spec. Table of hex values are also more readable
43 // then tables of NSColor constructors. 43 // then tables of NSColor constructors.
44 44
45 NSGradient* GetButtonGradient(ButtonState button_state) { 45 NSGradient* GetButtonGradient(ButtonState button_state) {
46 const SkColor start[] = {0xFFF0F0F0, 0xFFF4F4F4, 0xFFEBEBEB, 0xFFEDEDED}; 46 const SkColor start[] = {0xFFF0F0F0, 0xFFF4F4F4, 0xFFEBEBEB, 0xFFEDEDED};
47 const SkColor end[] = {0xFFE0E0E0, 0xFFE4E4E4, 0xFFDBDBDB, 0xFFDEDEDE}; 47 const SkColor end[] = {0xFFE0E0E0, 0xFFE4E4E4, 0xFFDBDBDB, 0xFFDEDEDE};
48 48
49 NSColor* start_color = gfx::SkColorToCalibratedNSColor(start[button_state]); 49 NSColor* start_color = skia::SkColorToCalibratedNSColor(start[button_state]);
50 NSColor* end_color = gfx::SkColorToCalibratedNSColor(end[button_state]); 50 NSColor* end_color = skia::SkColorToCalibratedNSColor(end[button_state]);
51 return [[[NSGradient alloc] initWithColorsAndLocations: 51 return [[[NSGradient alloc] initWithColorsAndLocations:
52 start_color, 0.0, 52 start_color, 0.0,
53 start_color, 0.38, 53 start_color, 0.38,
54 end_color, 1.0, 54 end_color, 1.0,
55 nil] autorelease]; 55 nil] autorelease];
56 } 56 }
57 57
58 NSShadow* GetButtonHighlight(ButtonState button_state) { 58 NSShadow* GetButtonHighlight(ButtonState button_state) {
59 const SkColor color[] = {0xBFFFFFFF, 0xF2FFFFFF, 0x24000000, 0x00000000}; 59 const SkColor color[] = {0xBFFFFFFF, 0xF2FFFFFF, 0x24000000, 0x00000000};
60 60
61 NSShadow* shadow = [[[NSShadow alloc] init] autorelease]; 61 NSShadow* shadow = [[[NSShadow alloc] init] autorelease];
62 [shadow setShadowColor:gfx::SkColorToCalibratedNSColor(color[button_state])]; 62 [shadow setShadowColor:skia::SkColorToCalibratedNSColor(color[button_state])];
63 [shadow setShadowOffset:NSMakeSize(0, -1)]; 63 [shadow setShadowOffset:NSMakeSize(0, -1)];
64 [shadow setShadowBlurRadius:2]; 64 [shadow setShadowBlurRadius:2];
65 return shadow; 65 return shadow;
66 } 66 }
67 67
68 NSShadow* GetButtonShadow(ButtonState button_state) { 68 NSShadow* GetButtonShadow(ButtonState button_state) {
69 const SkColor color[] = {0x14000000, 0x1F000000, 0x00000000, 0x00000000}; 69 const SkColor color[] = {0x14000000, 0x1F000000, 0x00000000, 0x00000000};
70 70
71 NSShadow* shadow = [[[NSShadow alloc] init] autorelease]; 71 NSShadow* shadow = [[[NSShadow alloc] init] autorelease];
72 [shadow setShadowColor:gfx::SkColorToCalibratedNSColor(color[button_state])]; 72 [shadow setShadowColor:skia::SkColorToCalibratedNSColor(color[button_state])];
73 [shadow setShadowOffset:NSMakeSize(0, -1)]; 73 [shadow setShadowOffset:NSMakeSize(0, -1)];
74 [shadow setShadowBlurRadius:0]; 74 [shadow setShadowBlurRadius:0];
75 return shadow; 75 return shadow;
76 } 76 }
77 77
78 NSColor* GetButtonBorderColor(ButtonState button_state) { 78 NSColor* GetButtonBorderColor(ButtonState button_state) {
79 const SkColor color[] = {0x40000000, 0x4D000000, 0x4D000000, 0x1F000000}; 79 const SkColor color[] = {0x40000000, 0x4D000000, 0x4D000000, 0x1F000000};
80 80
81 return gfx::SkColorToCalibratedNSColor(color[button_state]); 81 return skia::SkColorToCalibratedNSColor(color[button_state]);
82 } 82 }
83 83
84 NSAttributedString* GetButtonAttributedString( 84 NSAttributedString* GetButtonAttributedString(
85 NSString* title, 85 NSString* title,
86 NSString* key_equivalent, 86 NSString* key_equivalent,
87 id<ConstrainedWindowButtonDrawableCell> cell) { 87 id<ConstrainedWindowButtonDrawableCell> cell) {
88 const SkColor text_color[] = {0xFF333333, 0XFF000000, 0xFF000000, 0xFFAAAAAA}; 88 const SkColor text_color[] = {0xFF333333, 0XFF000000, 0xFF000000, 0xFFAAAAAA};
89 // The shadow color should be 0xFFF0F0F0 but that doesn't show up so use 89 // The shadow color should be 0xFFF0F0F0 but that doesn't show up so use
90 // pure white instead. 90 // pure white instead.
91 const SkColor shadow_color[] = 91 const SkColor shadow_color[] =
92 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF}; 92 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF};
93 93
94 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); 94 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
95 [shadow setShadowColor: 95 [shadow setShadowColor:
96 gfx::SkColorToCalibratedNSColor(shadow_color[cellButtonState(cell)])]; 96 skia::SkColorToCalibratedNSColor(shadow_color[cellButtonState(cell)])];
97 [shadow setShadowOffset:NSMakeSize(0, -1)]; 97 [shadow setShadowOffset:NSMakeSize(0, -1)];
98 [shadow setShadowBlurRadius:0]; 98 [shadow setShadowBlurRadius:0];
99 99
100 base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( 100 base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
101 [[NSMutableParagraphStyle alloc] init]); 101 [[NSMutableParagraphStyle alloc] init]);
102 [paragraphStyle setAlignment:NSCenterTextAlignment]; 102 [paragraphStyle setAlignment:NSCenterTextAlignment];
103 103
104 NSFont* font = nil; 104 NSFont* font = nil;
105 if ([key_equivalent isEqualToString:kKeyEquivalentReturn]) 105 if ([key_equivalent isEqualToString:kKeyEquivalentReturn])
106 font = [NSFont boldSystemFontOfSize:12]; 106 font = [NSFont boldSystemFontOfSize:12];
107 else 107 else
108 font = [NSFont systemFontOfSize:12]; 108 font = [NSFont systemFontOfSize:12];
109 109
110 NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: 110 NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
111 font, NSFontAttributeName, 111 font, NSFontAttributeName,
112 gfx::SkColorToCalibratedNSColor(text_color[cellButtonState(cell)]), 112 skia::SkColorToCalibratedNSColor(text_color[cellButtonState(cell)]),
113 NSForegroundColorAttributeName, 113 NSForegroundColorAttributeName,
114 shadow.get(), NSShadowAttributeName, 114 shadow.get(), NSShadowAttributeName,
115 paragraphStyle.get(), NSParagraphStyleAttributeName, 115 paragraphStyle.get(), NSParagraphStyleAttributeName,
116 nil]; 116 nil];
117 return [[[NSAttributedString alloc] initWithString:title 117 return [[[NSAttributedString alloc] initWithString:title
118 attributes:attributes] autorelease]; 118 attributes:attributes] autorelease];
119 } 119 }
120 120
121 void DrawBackgroundAndShadow(const NSRect& frame, 121 void DrawBackgroundAndShadow(const NSRect& frame,
122 id<ConstrainedWindowButtonDrawableCell> cell, 122 id<ConstrainedWindowButtonDrawableCell> cell,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 size.width += kButtonPaddingX * 2; 281 size.width += kButtonPaddingX * 2;
282 return size; 282 return size;
283 } 283 }
284 284
285 - (NSAttributedString*)getAttributedTitle { 285 - (NSAttributedString*)getAttributedTitle {
286 return GetButtonAttributedString( 286 return GetButtonAttributedString(
287 [self title], [self keyEquivalent], self); 287 [self title], [self keyEquivalent], self);
288 } 288 }
289 289
290 @end 290 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698