OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/native_theme_base.h" | 5 #include "ui/gfx/native_theme_base.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "grit/gfx_resources.h" | 10 #include "grit/gfx_resources.h" |
11 #include "third_party/skia/include/effects/SkGradientShader.h" | 11 #include "third_party/skia/include/effects/SkGradientShader.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/gfx/color_utils.h" | 13 #include "ui/gfx/color_utils.h" |
14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
15 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
16 | 16 |
17 namespace { | |
18 | |
19 // Hardcoded colors for use when there is no system theme (Aura, ChromeOS). | |
20 const SkColor kDefaultDialogBackgroundColor = SkColorSetRGB(200, 200, 200); | |
21 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); | |
22 | |
23 } // namespace | |
24 | |
17 namespace gfx { | 25 namespace gfx { |
18 | 26 |
19 unsigned int NativeThemeBase::button_length_ = 14; | 27 unsigned int NativeThemeBase::button_length_ = 14; |
20 #if defined(TOUCH_UI) | 28 #if defined(TOUCH_UI) |
21 unsigned int NativeThemeBase::scrollbar_width_ = 0; | 29 unsigned int NativeThemeBase::scrollbar_width_ = 0; |
22 #else | 30 #else |
23 unsigned int NativeThemeBase::scrollbar_width_ = 15; | 31 unsigned int NativeThemeBase::scrollbar_width_ = 15; |
24 #endif | 32 #endif |
25 | 33 |
26 // These are the default dimensions of radio buttons and checkboxes. | 34 // These are the default dimensions of radio buttons and checkboxes. |
(...skipping 23 matching lines...) Expand all Loading... | |
50 | 58 |
51 return color_utils::HSLToSkColor(adjusted, alpha); | 59 return color_utils::HSLToSkColor(adjusted, alpha); |
52 } | 60 } |
53 | 61 |
54 NativeThemeBase::NativeThemeBase() { | 62 NativeThemeBase::NativeThemeBase() { |
55 } | 63 } |
56 | 64 |
57 NativeThemeBase::~NativeThemeBase() { | 65 NativeThemeBase::~NativeThemeBase() { |
58 } | 66 } |
59 | 67 |
68 // This implementation returns hardcoded colors. It's used by NativeThemeAura | |
69 // and NativeThemeChromeos and overridden by NativeThemeGtk. | |
Ben Goodger (Google)
2011/11/21 18:59:59
comment moves inside function.
benrg
2011/11/21 19:54:20
Done.
| |
70 SkColor NativeThemeBase::GetSystemColor(ColorId color_id) const { | |
Ben Goodger (Google)
2011/11/21 18:59:59
order in .cc must match .h
benrg
2011/11/21 19:54:20
Independently for each protection level, I guess;
Ben Goodger (Google)
2011/11/22 15:49:50
Sort of, it's in the Chrome-specific overrides:
h
benrg
2011/11/22 21:43:49
In the newest patch set, NativeThemeBase::GetSyste
| |
71 switch (color_id) { | |
72 case kDialogBackgroundColorId: | |
73 return kDefaultDialogBackgroundColor; | |
74 default: | |
75 NOTREACHED() << "Invalid color_id: " << color_id; | |
76 break; | |
77 } | |
78 return kInvalidColorIdColor; | |
79 } | |
80 | |
60 gfx::Size NativeThemeBase::GetPartSize(Part part, | 81 gfx::Size NativeThemeBase::GetPartSize(Part part, |
61 State state, | 82 State state, |
62 const ExtraParams& extra) const { | 83 const ExtraParams& extra) const { |
63 switch (part) { | 84 switch (part) { |
64 // Please keep these in the order of NativeTheme::Part. | 85 // Please keep these in the order of NativeTheme::Part. |
65 case kCheckbox: | 86 case kCheckbox: |
66 return gfx::Size(kCheckboxAndRadioWidth, kCheckboxAndRadioHeight); | 87 return gfx::Size(kCheckboxAndRadioWidth, kCheckboxAndRadioHeight); |
67 case kInnerSpinButton: | 88 case kInnerSpinButton: |
68 return gfx::Size(scrollbar_width_, 0); | 89 return gfx::Size(scrollbar_width_, 0); |
69 case kMenuList: | 90 case kMenuList: |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); | 1006 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); |
986 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); | 1007 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
987 | 1008 |
988 if (hsv1[2] + hsv2[2] > 1.0) | 1009 if (hsv1[2] + hsv2[2] > 1.0) |
989 diff = -diff; | 1010 diff = -diff; |
990 | 1011 |
991 return SaturateAndBrighten(hsv2, -0.2f, diff); | 1012 return SaturateAndBrighten(hsv2, -0.2f, diff); |
992 } | 1013 } |
993 | 1014 |
994 } // namespace gfx | 1015 } // namespace gfx |
OLD | NEW |