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

Side by Side Diff: ui/native_theme/native_theme_aura.cc

Issue 14424007: Use the default theme as the fallback UI in Blink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed static initializer Created 7 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « ui/native_theme/native_theme_aura.h ('k') | webkit/glue/webfallbackthemeengine_impl.h » ('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 (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 #include "ui/native_theme/native_theme_aura.h" 5 #include "ui/native_theme/native_theme_aura.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/base/layout.h" 9 #include "ui/base/layout.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/image/image_skia.h" 11 #include "ui/gfx/image/image_skia.h"
12 #include "ui/gfx/path.h" 12 #include "ui/gfx/path.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
15 #include "ui/gfx/skbitmap_operations.h" 15 #include "ui/gfx/skbitmap_operations.h"
16 #include "ui/native_theme/common_theme.h" 16 #include "ui/native_theme/common_theme.h"
17 17
18 namespace { 18 namespace {
19 19
20 const SkColor kMenuBackgroundColor = SK_ColorWHITE; 20 const SkColor kMenuBackgroundColor = SK_ColorWHITE;
21 21
22 // Theme colors returned by GetSystemColor().
23 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
24 // Windows:
25 const SkColor kWindowBackgroundColor = SK_ColorWHITE;
26 // Dialogs:
27 const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251);
28 // FocusableBorder:
29 const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE);
30 const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9);
31 // Button:
32 const SkColor kButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE);
33 const SkColor kButtonEnabledColor = SkColorSetRGB(0x22, 0x22, 0x22);
34 const SkColor kButtonDisabledColor = SkColorSetRGB(0x99, 0x99, 0x99);
35 const SkColor kButtonHighlightColor = SkColorSetRGB(0, 0, 0);
36 const SkColor kButtonHoverColor = kButtonEnabledColor;
37 // MenuItem:
38 const SkColor kEnabledMenuItemForegroundColor = kButtonEnabledColor;
39 const SkColor kDisabledMenuItemForegroundColor = kButtonDisabledColor;
40 const SkColor kFocusedMenuItemBackgroundColor = SkColorSetRGB(0xF1, 0xF1, 0xF1);
41 const SkColor kHoverMenuItemBackgroundColor =
42 SkColorSetARGB(204, 255, 255, 255);
43 const SkColor kMenuSeparatorColor = SkColorSetRGB(0xED, 0xED, 0xED);
44 const SkColor kEnabledMenuButtonBorderColor = SkColorSetARGB(36, 0, 0, 0);
45 const SkColor kFocusedMenuButtonBorderColor = SkColorSetARGB(72, 0, 0, 0);
46 const SkColor kHoverMenuButtonBorderColor = SkColorSetARGB(72, 0, 0, 0);
47 // Label:
48 const SkColor kLabelEnabledColor = kButtonEnabledColor;
49 const SkColor kLabelDisabledColor = kButtonDisabledColor;
50 const SkColor kLabelBackgroundColor = SK_ColorWHITE;
51 // Textfield:
52 const SkColor kTextfieldDefaultColor = SK_ColorBLACK;
53 const SkColor kTextfieldDefaultBackground = SK_ColorWHITE;
54 const SkColor kTextfieldReadOnlyColor = SK_ColorDKGRAY;
55 const SkColor kTextfieldReadOnlyBackground = SK_ColorWHITE;
56 const SkColor kTextfieldSelectionBackgroundFocused =
57 SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
58 const SkColor kTextfieldSelectionBackgroundUnfocused = SK_ColorLTGRAY;
59 const SkColor kTextfieldSelectionColor =
60 color_utils::AlphaBlend(SK_ColorBLACK,
61 kTextfieldSelectionBackgroundFocused, 0xdd);
62 // Tree
63 const SkColor kTreeBackground = SK_ColorWHITE;
64 const SkColor kTreeTextColor = SK_ColorBLACK;
65 const SkColor kTreeSelectedTextColor = SK_ColorBLACK;
66 const SkColor kTreeSelectionBackgroundColor = SkColorSetRGB(0xEE, 0xEE, 0xEE);
67 const SkColor kTreeArrowColor = SkColorSetRGB(0x7A, 0x7A, 0x7A);
68 // Table
69 const SkColor kTableBackground = SK_ColorWHITE;
70 const SkColor kTableTextColor = SK_ColorBLACK;
71 const SkColor kTableSelectedTextColor = SK_ColorBLACK;
72 const SkColor kTableSelectionBackgroundColor = SkColorSetRGB(0xEE, 0xEE, 0xEE);
73 const SkColor kTableGroupingIndicatorColor = SkColorSetRGB(0xCC, 0xCC, 0xCC);
74
75 } // namespace 22 } // namespace
76 23
77 namespace ui { 24 namespace ui {
78 25
79 // static 26 // static
80 NativeTheme* NativeTheme::instance() { 27 NativeTheme* NativeTheme::instance() {
81 return NativeThemeAura::instance(); 28 return NativeThemeAura::instance();
82 } 29 }
83 30
84 // static 31 // static
85 NativeThemeAura* NativeThemeAura::instance() { 32 NativeThemeAura* NativeThemeAura::instance() {
86 CR_DEFINE_STATIC_LOCAL(NativeThemeAura, s_native_theme, ()); 33 CR_DEFINE_STATIC_LOCAL(NativeThemeAura, s_native_theme, ());
87 return &s_native_theme; 34 return &s_native_theme;
88 } 35 }
89 36
90 NativeThemeAura::NativeThemeAura() { 37 NativeThemeAura::NativeThemeAura() {
91 // We don't draw scrollbar buttons. 38 // We don't draw scrollbar buttons.
92 set_scrollbar_button_length(0); 39 set_scrollbar_button_length(0);
93 } 40 }
94 41
95 NativeThemeAura::~NativeThemeAura() { 42 NativeThemeAura::~NativeThemeAura() {
96 } 43 }
97 44
98 SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const {
99 // This implementation returns hardcoded colors.
100 SkColor color;
101 if (CommonThemeGetSystemColor(color_id, &color))
102 return color;
103
104 switch (color_id) {
105 // Windows
106 case kColorId_WindowBackground:
107 return kWindowBackgroundColor;
108
109 // Dialogs
110 case kColorId_DialogBackground:
111 return kDialogBackgroundColor;
112
113 // FocusableBorder
114 case kColorId_FocusedBorderColor:
115 return kFocusedBorderColor;
116 case kColorId_UnfocusedBorderColor:
117 return kUnfocusedBorderColor;
118
119 // Button
120 case kColorId_ButtonBackgroundColor:
121 return kButtonBackgroundColor;
122 case kColorId_ButtonEnabledColor:
123 return kButtonEnabledColor;
124 case kColorId_ButtonDisabledColor:
125 return kButtonDisabledColor;
126 case kColorId_ButtonHighlightColor:
127 return kButtonHighlightColor;
128 case kColorId_ButtonHoverColor:
129 return kButtonHoverColor;
130
131 // MenuItem
132 case kColorId_EnabledMenuItemForegroundColor:
133 return kEnabledMenuItemForegroundColor;
134 case kColorId_DisabledMenuItemForegroundColor:
135 return kDisabledMenuItemForegroundColor;
136 case kColorId_SelectedMenuItemForegroundColor:
137 return kEnabledMenuItemForegroundColor;
138 case kColorId_FocusedMenuItemBackgroundColor:
139 return kFocusedMenuItemBackgroundColor;
140 case kColorId_HoverMenuItemBackgroundColor:
141 return kHoverMenuItemBackgroundColor;
142 case kColorId_MenuSeparatorColor:
143 return kMenuSeparatorColor;
144 case kColorId_EnabledMenuButtonBorderColor:
145 return kEnabledMenuButtonBorderColor;
146 case kColorId_FocusedMenuButtonBorderColor:
147 return kFocusedMenuButtonBorderColor;
148 case kColorId_HoverMenuButtonBorderColor:
149 return kHoverMenuButtonBorderColor;
150
151 // Label
152 case kColorId_LabelEnabledColor:
153 return kLabelEnabledColor;
154 case kColorId_LabelDisabledColor:
155 return kLabelDisabledColor;
156 case kColorId_LabelBackgroundColor:
157 return kLabelBackgroundColor;
158
159 // Textfield
160 case kColorId_TextfieldDefaultColor:
161 return kTextfieldDefaultColor;
162 case kColorId_TextfieldDefaultBackground:
163 return kTextfieldDefaultBackground;
164 case kColorId_TextfieldReadOnlyColor:
165 return kTextfieldReadOnlyColor;
166 case kColorId_TextfieldReadOnlyBackground:
167 return kTextfieldReadOnlyBackground;
168 case kColorId_TextfieldSelectionColor:
169 return kTextfieldSelectionColor;
170 case kColorId_TextfieldSelectionBackgroundFocused:
171 return kTextfieldSelectionBackgroundFocused;
172 case kColorId_TextfieldSelectionBackgroundUnfocused:
173 return kTextfieldSelectionBackgroundUnfocused;
174
175 // Tree
176 case kColorId_TreeBackground:
177 return kTreeBackground;
178 case kColorId_TreeText:
179 return kTreeTextColor;
180 case kColorId_TreeSelectedText:
181 case kColorId_TreeSelectedTextUnfocused:
182 return kTreeSelectedTextColor;
183 case kColorId_TreeSelectionBackgroundFocused:
184 case kColorId_TreeSelectionBackgroundUnfocused:
185 return kTreeSelectionBackgroundColor;
186 case kColorId_TreeArrow:
187 return kTreeArrowColor;
188
189 // Table
190 case kColorId_TableBackground:
191 return kTableBackground;
192 case kColorId_TableText:
193 return kTableTextColor;
194 case kColorId_TableSelectedText:
195 case kColorId_TableSelectedTextUnfocused:
196 return kTableSelectedTextColor;
197 case kColorId_TableSelectionBackgroundFocused:
198 case kColorId_TableSelectionBackgroundUnfocused:
199 return kTableSelectionBackgroundColor;
200 case kColorId_TableGroupingIndicatorColor:
201 return kTableGroupingIndicatorColor;
202
203 case kColorId_MenuBackgroundColor:
204 return kMenuBackgroundColor;
205 case kColorId_MenuBorderColor:
206 NOTREACHED();
207 break;
208 }
209
210 return kInvalidColorIdColor;
211 }
212
213 void NativeThemeAura::PaintMenuPopupBackground( 45 void NativeThemeAura::PaintMenuPopupBackground(
214 SkCanvas* canvas, 46 SkCanvas* canvas,
215 const gfx::Size& size, 47 const gfx::Size& size,
216 const MenuBackgroundExtraParams& menu_background) const { 48 const MenuBackgroundExtraParams& menu_background) const {
217 if (menu_background.corner_radius > 0) { 49 if (menu_background.corner_radius > 0) {
218 SkPaint paint; 50 SkPaint paint;
219 paint.setStyle(SkPaint::kFill_Style); 51 paint.setStyle(SkPaint::kFill_Style);
220 paint.setFlags(SkPaint::kAntiAlias_Flag); 52 paint.setFlags(SkPaint::kAntiAlias_Flag);
221 paint.setColor(kMenuBackgroundColor); 53 paint.setColor(kMenuBackgroundColor);
222 54
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 DrawTiledImage(canvas, *center, 220 DrawTiledImage(canvas, *center,
389 0, 0, 1.0, 1.0, 221 0, 0, 1.0, 1.0,
390 rect.x() + left->width(), rect.y(), 222 rect.x() + left->width(), rect.y(),
391 rect.width() - left->width() - right->width(), 223 rect.width() - left->width() - right->width(),
392 center->height()); 224 center->height());
393 } 225 }
394 } 226 }
395 } 227 }
396 228
397 } // namespace ui 229 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_aura.h ('k') | webkit/glue/webfallbackthemeengine_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698