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
3 // found in the LICENSE file.
5 #include "ui/native_theme/fallback_theme.h"
7 #include "base/basictypes.h"
8 #include "base/logging.h"
9 #include "ui/base/resource/material_design/material_design_controller.h"
10 #include "ui/gfx/color_utils.h"
11 #include "ui/native_theme/common_theme.h"
15 FallbackTheme::FallbackTheme() {
18 FallbackTheme::~FallbackTheme() {
21 // This implementation returns hardcoded colors.
22 SkColor
FallbackTheme::GetSystemColor(ColorId color_id
) const {
24 if (CommonThemeGetSystemColor(color_id
, &color
))
28 static const SkColor kTextfieldDefaultBackground
= SK_ColorWHITE
;
29 static const SkColor kTextfieldSelectionBackgroundFocused
=
30 SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
33 if (ui::MaterialDesignController::IsModeMaterial()) {
35 static const SkColor kDialogBackgroundColorMd
= SK_ColorWHITE
;
37 static const SkColor kResultsTableSelectedBackgroundMd
=
38 SkColorSetARGB(0x15, 0x00, 0x00, 0x00);
39 static const SkColor kResultsTableTextMd
= SK_ColorBLACK
;
40 static const SkColor kResultsTableDimmedTextMd
=
41 SkColorSetRGB(0x64, 0x64, 0x64);
42 static const SkColor kResultsTableUrlMd
= SkColorSetRGB(0x33, 0x67, 0xD6);
43 static const SkColor kResultsTableHoveredBackgroundMd
=
44 SkColorSetARGB(0x0D, 0x00, 0x00, 0x00);
45 static const SkColor kResultsTableDividerMd
= color_utils::AlphaBlend(
46 kResultsTableTextMd
, kTextfieldDefaultBackground
, 0x34);
47 static const SkColor kResultsTableSelectedDividerMd
=
48 color_utils::AlphaBlend(kResultsTableTextMd
,
49 kTextfieldSelectionBackgroundFocused
, 0x34);
50 static const SkColor kPositiveTextColorMd
= SkColorSetRGB(0x0b, 0x80, 0x43);
51 static const SkColor kNegativeTextColorMd
= SkColorSetRGB(0xc5, 0x39, 0x29);
55 case kColorId_DialogBackground
:
56 return kDialogBackgroundColorMd
;
59 case kColorId_ResultsTableHoveredBackground
:
60 return kResultsTableHoveredBackgroundMd
;
61 case kColorId_ResultsTableSelectedBackground
:
62 return kResultsTableSelectedBackgroundMd
;
63 case kColorId_ResultsTableNormalText
:
64 case kColorId_ResultsTableHoveredText
:
65 case kColorId_ResultsTableSelectedText
:
66 return kResultsTableTextMd
;
67 case kColorId_ResultsTableNormalDimmedText
:
68 case kColorId_ResultsTableHoveredDimmedText
:
69 case kColorId_ResultsTableSelectedDimmedText
:
70 return kResultsTableDimmedTextMd
;
71 case kColorId_ResultsTableNormalUrl
:
72 case kColorId_ResultsTableHoveredUrl
:
73 case kColorId_ResultsTableSelectedUrl
:
74 return kResultsTableUrlMd
;
75 case kColorId_ResultsTableNormalDivider
:
76 case kColorId_ResultsTableHoveredDivider
:
77 return kResultsTableDividerMd
;
78 case kColorId_ResultsTableSelectedDivider
:
79 return kResultsTableSelectedDividerMd
;
80 case kColorId_ResultsTablePositiveText
:
81 case kColorId_ResultsTablePositiveHoveredText
:
82 case kColorId_ResultsTablePositiveSelectedText
:
83 return kPositiveTextColorMd
;
84 case kColorId_ResultsTableNegativeText
:
85 case kColorId_ResultsTableNegativeHoveredText
:
86 case kColorId_ResultsTableNegativeSelectedText
:
87 return kNegativeTextColorMd
;
95 static const SkColor kInvalidColorIdColor
= SkColorSetRGB(255, 0, 128);
97 static const SkColor kWindowBackgroundColor
= SK_ColorWHITE
;
99 static const SkColor kDialogBackgroundColor
= SkColorSetRGB(251, 251, 251);
101 static const SkColor kFocusedBorderColor
= SkColorSetRGB(0x4D, 0x90, 0xFE);
102 static const SkColor kUnfocusedBorderColor
= SkColorSetRGB(0xD9, 0xD9, 0xD9);
104 static const SkColor kButtonBackgroundColor
= SkColorSetRGB(0xDE, 0xDE, 0xDE);
105 static const SkColor kButtonEnabledColor
= SkColorSetRGB(0x22, 0x22, 0x22);
106 static const SkColor kButtonHighlightColor
= SkColorSetRGB(0, 0, 0);
107 static const SkColor kButtonHoverColor
= kButtonEnabledColor
;
109 static const SkColor kLabelEnabledColor
= kButtonEnabledColor
;
110 static const SkColor kLabelBackgroundColor
= SK_ColorWHITE
;
112 static const SkColor kLinkDisabledColor
= SK_ColorBLACK
;
113 static const SkColor kLinkEnabledColor
= SkColorSetRGB(0, 51, 153);
114 static const SkColor kLinkPressedColor
= SK_ColorRED
;
116 static const SkColor kTextfieldDefaultColor
= SK_ColorBLACK
;
117 static const SkColor kTextfieldReadOnlyColor
= SK_ColorDKGRAY
;
118 static const SkColor kTextfieldReadOnlyBackground
= SK_ColorWHITE
;
119 static const SkColor kTextfieldSelectionColor
=
120 color_utils::AlphaBlend(SK_ColorBLACK
,
121 kTextfieldSelectionBackgroundFocused
, 0xdd);
123 static const SkColor kTooltipBackground
= 0xFFFFFFCC;
124 static const SkColor kTooltipTextColor
= kLabelEnabledColor
;
126 static const SkColor kTreeBackground
= SK_ColorWHITE
;
127 static const SkColor kTreeTextColor
= SK_ColorBLACK
;
128 static const SkColor kTreeSelectedTextColor
= SK_ColorBLACK
;
129 static const SkColor kTreeSelectionBackgroundColor
=
130 SkColorSetRGB(0xEE, 0xEE, 0xEE);
131 static const SkColor kTreeArrowColor
= SkColorSetRGB(0x7A, 0x7A, 0x7A);
133 static const SkColor kTableBackground
= SK_ColorWHITE
;
134 static const SkColor kTableTextColor
= SK_ColorBLACK
;
135 static const SkColor kTableSelectedTextColor
= SK_ColorBLACK
;
136 static const SkColor kTableSelectionBackgroundColor
=
137 SkColorSetRGB(0xEE, 0xEE, 0xEE);
138 static const SkColor kTableGroupingIndicatorColor
=
139 SkColorSetRGB(0xCC, 0xCC, 0xCC);
141 static const SkColor kResultsTableSelectedBackground
=
142 kTextfieldSelectionBackgroundFocused
;
143 static const SkColor kResultsTableNormalText
=
144 color_utils::AlphaBlend(SK_ColorBLACK
, kTextfieldDefaultBackground
, 0xDD);
145 static const SkColor kResultsTableHoveredBackground
= color_utils::AlphaBlend(
146 kTextfieldSelectionBackgroundFocused
, kTextfieldDefaultBackground
, 0x40);
147 static const SkColor kResultsTableHoveredText
= color_utils::AlphaBlend(
148 SK_ColorBLACK
, kResultsTableHoveredBackground
, 0xDD);
149 static const SkColor kResultsTableSelectedText
= color_utils::AlphaBlend(
150 SK_ColorBLACK
, kTextfieldSelectionBackgroundFocused
, 0xDD);
151 static const SkColor kResultsTableNormalDimmedText
=
152 color_utils::AlphaBlend(SK_ColorBLACK
, kTextfieldDefaultBackground
, 0xBB);
153 static const SkColor kResultsTableHoveredDimmedText
= color_utils::AlphaBlend(
154 SK_ColorBLACK
, kResultsTableHoveredBackground
, 0xBB);
155 static const SkColor kResultsTableSelectedDimmedText
=
156 color_utils::AlphaBlend(SK_ColorBLACK
,
157 kTextfieldSelectionBackgroundFocused
, 0xBB);
158 static const SkColor kResultsTableNormalUrl
= kTextfieldSelectionColor
;
159 static const SkColor kResultsTableSelectedOrHoveredUrl
=
160 SkColorSetARGB(0xff, 0x0b, 0x80, 0x43);
161 static const SkColor kResultsTableNormalDivider
= color_utils::AlphaBlend(
162 kResultsTableNormalText
, kTextfieldDefaultBackground
, 0x34);
163 static const SkColor kResultsTableHoveredDivider
= color_utils::AlphaBlend(
164 kResultsTableHoveredText
, kResultsTableHoveredBackground
, 0x34);
165 static const SkColor kResultsTableSelectedDivider
= color_utils::AlphaBlend(
166 kResultsTableSelectedText
, kTextfieldSelectionBackgroundFocused
, 0x34);
167 const SkColor kPositiveTextColor
= SkColorSetRGB(0x0b, 0x80, 0x43);
168 const SkColor kNegativeTextColor
= SkColorSetRGB(0xc5, 0x39, 0x29);
169 static const SkColor kResultsTablePositiveText
= color_utils::AlphaBlend(
170 kPositiveTextColor
, kTextfieldDefaultBackground
, 0xDD);
171 static const SkColor kResultsTablePositiveHoveredText
=
172 color_utils::AlphaBlend(kPositiveTextColor
,
173 kResultsTableHoveredBackground
, 0xDD);
174 static const SkColor kResultsTablePositiveSelectedText
=
175 color_utils::AlphaBlend(kPositiveTextColor
,
176 kTextfieldSelectionBackgroundFocused
, 0xDD);
177 static const SkColor kResultsTableNegativeText
= color_utils::AlphaBlend(
178 kNegativeTextColor
, kTextfieldDefaultBackground
, 0xDD);
179 static const SkColor kResultsTableNegativeHoveredText
=
180 color_utils::AlphaBlend(kNegativeTextColor
,
181 kResultsTableHoveredBackground
, 0xDD);
182 static const SkColor kResultsTableNegativeSelectedText
=
183 color_utils::AlphaBlend(kNegativeTextColor
,
184 kTextfieldSelectionBackgroundFocused
, 0xDD);
188 case kColorId_WindowBackground
:
189 return kWindowBackgroundColor
;
192 case kColorId_DialogBackground
:
193 return kDialogBackgroundColor
;
196 case kColorId_FocusedBorderColor
:
197 return kFocusedBorderColor
;
198 case kColorId_UnfocusedBorderColor
:
199 return kUnfocusedBorderColor
;
202 case kColorId_ButtonBackgroundColor
:
203 return kButtonBackgroundColor
;
204 case kColorId_ButtonEnabledColor
:
205 return kButtonEnabledColor
;
206 case kColorId_ButtonHighlightColor
:
207 return kButtonHighlightColor
;
208 case kColorId_ButtonHoverColor
:
209 return kButtonHoverColor
;
212 case kColorId_LabelEnabledColor
:
213 return kLabelEnabledColor
;
214 case kColorId_LabelDisabledColor
:
215 return GetSystemColor(kColorId_ButtonDisabledColor
);
216 case kColorId_LabelBackgroundColor
:
217 return kLabelBackgroundColor
;
220 case kColorId_LinkDisabled
:
221 return kLinkDisabledColor
;
222 case kColorId_LinkEnabled
:
223 return kLinkEnabledColor
;
224 case kColorId_LinkPressed
:
225 return kLinkPressedColor
;
228 case kColorId_TextfieldDefaultColor
:
229 return kTextfieldDefaultColor
;
230 case kColorId_TextfieldDefaultBackground
:
231 return kTextfieldDefaultBackground
;
232 case kColorId_TextfieldReadOnlyColor
:
233 return kTextfieldReadOnlyColor
;
234 case kColorId_TextfieldReadOnlyBackground
:
235 return kTextfieldReadOnlyBackground
;
236 case kColorId_TextfieldSelectionColor
:
237 return kTextfieldSelectionColor
;
238 case kColorId_TextfieldSelectionBackgroundFocused
:
239 return kTextfieldSelectionBackgroundFocused
;
242 case kColorId_TooltipBackground
:
243 return kTooltipBackground
;
244 case kColorId_TooltipText
:
245 return kTooltipTextColor
;
248 case kColorId_TreeBackground
:
249 return kTreeBackground
;
250 case kColorId_TreeText
:
251 return kTreeTextColor
;
252 case kColorId_TreeSelectedText
:
253 case kColorId_TreeSelectedTextUnfocused
:
254 return kTreeSelectedTextColor
;
255 case kColorId_TreeSelectionBackgroundFocused
:
256 case kColorId_TreeSelectionBackgroundUnfocused
:
257 return kTreeSelectionBackgroundColor
;
258 case kColorId_TreeArrow
:
259 return kTreeArrowColor
;
262 case kColorId_TableBackground
:
263 return kTableBackground
;
264 case kColorId_TableText
:
265 return kTableTextColor
;
266 case kColorId_TableSelectedText
:
267 case kColorId_TableSelectedTextUnfocused
:
268 return kTableSelectedTextColor
;
269 case kColorId_TableSelectionBackgroundFocused
:
270 case kColorId_TableSelectionBackgroundUnfocused
:
271 return kTableSelectionBackgroundColor
;
272 case kColorId_TableGroupingIndicatorColor
:
273 return kTableGroupingIndicatorColor
;
276 case kColorId_ResultsTableNormalBackground
:
277 return kTextfieldDefaultBackground
;
278 case kColorId_ResultsTableHoveredBackground
:
279 return kResultsTableHoveredBackground
;
280 case kColorId_ResultsTableSelectedBackground
:
281 return kResultsTableSelectedBackground
;
282 case kColorId_ResultsTableNormalText
:
283 return kResultsTableNormalText
;
284 case kColorId_ResultsTableHoveredText
:
285 return kResultsTableHoveredText
;
286 case kColorId_ResultsTableSelectedText
:
287 return kResultsTableSelectedText
;
288 case kColorId_ResultsTableNormalDimmedText
:
289 return kResultsTableNormalDimmedText
;
290 case kColorId_ResultsTableHoveredDimmedText
:
291 return kResultsTableHoveredDimmedText
;
292 case kColorId_ResultsTableSelectedDimmedText
:
293 return kResultsTableSelectedDimmedText
;
294 case kColorId_ResultsTableNormalUrl
:
295 return kResultsTableNormalUrl
;
296 case kColorId_ResultsTableHoveredUrl
:
297 case kColorId_ResultsTableSelectedUrl
:
298 return kResultsTableSelectedOrHoveredUrl
;
299 case kColorId_ResultsTableNormalDivider
:
300 return kResultsTableNormalDivider
;
301 case kColorId_ResultsTableHoveredDivider
:
302 return kResultsTableHoveredDivider
;
303 case kColorId_ResultsTableSelectedDivider
:
304 return kResultsTableSelectedDivider
;
305 case kColorId_ResultsTablePositiveText
:
306 return kResultsTablePositiveText
;
307 case kColorId_ResultsTablePositiveHoveredText
:
308 return kResultsTablePositiveHoveredText
;
309 case kColorId_ResultsTablePositiveSelectedText
:
310 return kResultsTablePositiveSelectedText
;
311 case kColorId_ResultsTableNegativeText
:
312 return kResultsTableNegativeText
;
313 case kColorId_ResultsTableNegativeHoveredText
:
314 return kResultsTableNegativeHoveredText
;
315 case kColorId_ResultsTableNegativeSelectedText
:
316 return kResultsTableNegativeSelectedText
;
323 return kInvalidColorIdColor
;