OLD | NEW |
---|---|
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(). | |
sky
2013/04/26 16:13:50
AFIACT you're moving these to FallbackTheme. The c
keishi
2013/04/30 08:16:58
I meant to make NativeTheme for Aura inherit Fallb
| |
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 // TextButton: | |
32 const SkColor kTextButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE); | |
33 const SkColor kTextButtonEnabledColor = SkColorSetRGB(0x22, 0x22, 0x22); | |
34 const SkColor kTextButtonDisabledColor = SkColorSetRGB(0x99, 0x99, 0x99); | |
35 const SkColor kTextButtonHighlightColor = SkColorSetRGB(0, 0, 0); | |
36 const SkColor kTextButtonHoverColor = kTextButtonEnabledColor; | |
37 // MenuItem: | |
38 const SkColor kEnabledMenuItemForegroundColor = kTextButtonEnabledColor; | |
39 const SkColor kDisabledMenuItemForegroundColor = kTextButtonDisabledColor; | |
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 = kTextButtonEnabledColor; | |
49 const SkColor kLabelDisabledColor = kTextButtonDisabledColor; | |
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 // TextButton | |
120 case kColorId_TextButtonBackgroundColor: | |
121 return kTextButtonBackgroundColor; | |
122 case kColorId_TextButtonEnabledColor: | |
123 return kTextButtonEnabledColor; | |
124 case kColorId_TextButtonDisabledColor: | |
125 return kTextButtonDisabledColor; | |
126 case kColorId_TextButtonHighlightColor: | |
127 return kTextButtonHighlightColor; | |
128 case kColorId_TextButtonHoverColor: | |
129 return kTextButtonHoverColor; | |
130 | |
131 // MenuItem | |
132 case kColorId_EnabledMenuItemForegroundColor: | |
133 return kEnabledMenuItemForegroundColor; | |
134 case kColorId_DisabledMenuItemForegroundColor: | |
135 return kDisabledMenuItemForegroundColor; | |
136 case kColorId_FocusedMenuItemBackgroundColor: | |
137 return kFocusedMenuItemBackgroundColor; | |
138 case kColorId_HoverMenuItemBackgroundColor: | |
139 return kHoverMenuItemBackgroundColor; | |
140 case kColorId_MenuSeparatorColor: | |
141 return kMenuSeparatorColor; | |
142 case kColorId_EnabledMenuButtonBorderColor: | |
143 return kEnabledMenuButtonBorderColor; | |
144 case kColorId_FocusedMenuButtonBorderColor: | |
145 return kFocusedMenuButtonBorderColor; | |
146 case kColorId_HoverMenuButtonBorderColor: | |
147 return kHoverMenuButtonBorderColor; | |
148 | |
149 // Label | |
150 case kColorId_LabelEnabledColor: | |
151 return kLabelEnabledColor; | |
152 case kColorId_LabelDisabledColor: | |
153 return kLabelDisabledColor; | |
154 case kColorId_LabelBackgroundColor: | |
155 return kLabelBackgroundColor; | |
156 | |
157 // Textfield | |
158 case kColorId_TextfieldDefaultColor: | |
159 return kTextfieldDefaultColor; | |
160 case kColorId_TextfieldDefaultBackground: | |
161 return kTextfieldDefaultBackground; | |
162 case kColorId_TextfieldReadOnlyColor: | |
163 return kTextfieldReadOnlyColor; | |
164 case kColorId_TextfieldReadOnlyBackground: | |
165 return kTextfieldReadOnlyBackground; | |
166 case kColorId_TextfieldSelectionColor: | |
167 return kTextfieldSelectionColor; | |
168 case kColorId_TextfieldSelectionBackgroundFocused: | |
169 return kTextfieldSelectionBackgroundFocused; | |
170 case kColorId_TextfieldSelectionBackgroundUnfocused: | |
171 return kTextfieldSelectionBackgroundUnfocused; | |
172 | |
173 // Tree | |
174 case kColorId_TreeBackground: | |
175 return kTreeBackground; | |
176 case kColorId_TreeText: | |
177 return kTreeTextColor; | |
178 case kColorId_TreeSelectedText: | |
179 case kColorId_TreeSelectedTextUnfocused: | |
180 return kTreeSelectedTextColor; | |
181 case kColorId_TreeSelectionBackgroundFocused: | |
182 case kColorId_TreeSelectionBackgroundUnfocused: | |
183 return kTreeSelectionBackgroundColor; | |
184 case kColorId_TreeArrow: | |
185 return kTreeArrowColor; | |
186 | |
187 // Table | |
188 case kColorId_TableBackground: | |
189 return kTableBackground; | |
190 case kColorId_TableText: | |
191 return kTableTextColor; | |
192 case kColorId_TableSelectedText: | |
193 case kColorId_TableSelectedTextUnfocused: | |
194 return kTableSelectedTextColor; | |
195 case kColorId_TableSelectionBackgroundFocused: | |
196 case kColorId_TableSelectionBackgroundUnfocused: | |
197 return kTableSelectionBackgroundColor; | |
198 case kColorId_TableGroupingIndicatorColor: | |
199 return kTableGroupingIndicatorColor; | |
200 | |
201 case kColorId_MenuBackgroundColor: | |
202 return kMenuBackgroundColor; | |
203 case kColorId_MenuBorderColor: | |
204 NOTREACHED(); | |
205 break; | |
206 } | |
207 | |
208 return kInvalidColorIdColor; | |
209 } | |
210 | |
211 void NativeThemeAura::PaintMenuPopupBackground( | 45 void NativeThemeAura::PaintMenuPopupBackground( |
212 SkCanvas* canvas, | 46 SkCanvas* canvas, |
213 const gfx::Size& size, | 47 const gfx::Size& size, |
214 const MenuBackgroundExtraParams& menu_background) const { | 48 const MenuBackgroundExtraParams& menu_background) const { |
215 if (menu_background.corner_radius > 0) { | 49 if (menu_background.corner_radius > 0) { |
216 SkPaint paint; | 50 SkPaint paint; |
217 paint.setStyle(SkPaint::kFill_Style); | 51 paint.setStyle(SkPaint::kFill_Style); |
218 paint.setFlags(SkPaint::kAntiAlias_Flag); | 52 paint.setFlags(SkPaint::kAntiAlias_Flag); |
219 paint.setColor(kMenuBackgroundColor); | 53 paint.setColor(kMenuBackgroundColor); |
220 | 54 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 DrawTiledImage(canvas, *center, | 212 DrawTiledImage(canvas, *center, |
379 0, 0, 1.0, 1.0, | 213 0, 0, 1.0, 1.0, |
380 rect.x() + left->width(), rect.y(), | 214 rect.x() + left->width(), rect.y(), |
381 rect.width() - left->width() - right->width(), | 215 rect.width() - left->width() - right->width(), |
382 center->height()); | 216 center->height()); |
383 } | 217 } |
384 } | 218 } |
385 } | 219 } |
386 | 220 |
387 } // namespace ui | 221 } // namespace ui |
OLD | NEW |