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 gfx { | 17 namespace gfx { |
18 | 18 |
19 namespace { | |
20 // Hardcoded colors for use when there is no system theme (Aura, ChromeOS). | |
21 const SkColor kDefaultDialogBackgroundColor = SkColorSetRGB(200, 200, 200); | |
22 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); | |
James Cook
2011/11/19 03:02:46
I like this name better.
| |
23 } | |
James Cook
2011/11/19 03:02:46
The style guide likes namespaces to end with two s
benrg
2011/11/21 18:32:40
Done.
| |
24 | |
19 unsigned int NativeThemeBase::button_length_ = 14; | 25 unsigned int NativeThemeBase::button_length_ = 14; |
20 #if defined(TOUCH_UI) | 26 #if defined(TOUCH_UI) |
21 unsigned int NativeThemeBase::scrollbar_width_ = 0; | 27 unsigned int NativeThemeBase::scrollbar_width_ = 0; |
22 #else | 28 #else |
23 unsigned int NativeThemeBase::scrollbar_width_ = 15; | 29 unsigned int NativeThemeBase::scrollbar_width_ = 15; |
24 #endif | 30 #endif |
25 | 31 |
26 // These are the default dimensions of radio buttons and checkboxes. | 32 // These are the default dimensions of radio buttons and checkboxes. |
27 static const int kCheckboxAndRadioWidth = 13; | 33 static const int kCheckboxAndRadioWidth = 13; |
28 static const int kCheckboxAndRadioHeight = 13; | 34 static const int kCheckboxAndRadioHeight = 13; |
(...skipping 21 matching lines...) Expand all Loading... | |
50 | 56 |
51 return color_utils::HSLToSkColor(adjusted, alpha); | 57 return color_utils::HSLToSkColor(adjusted, alpha); |
52 } | 58 } |
53 | 59 |
54 NativeThemeBase::NativeThemeBase() { | 60 NativeThemeBase::NativeThemeBase() { |
55 } | 61 } |
56 | 62 |
57 NativeThemeBase::~NativeThemeBase() { | 63 NativeThemeBase::~NativeThemeBase() { |
58 } | 64 } |
59 | 65 |
66 // This implementation returns hardcoded colors. It's used by NativeThemeAura | |
67 // and NativeThemeChromeos and overridden by NativeThemeGtk. | |
68 SkColor NativeThemeBase::GetSystemColor(ColorId color_id) const { | |
69 switch (color_id) { | |
70 case kDialogBackgroundColorId: | |
71 return kDefaultDialogBackgroundColor; | |
72 default: | |
73 NOTREACHED() << "Invalid color_id: " << color_id; | |
74 break; | |
75 } | |
76 return kInvalidColorIdColor; | |
77 } | |
78 | |
60 gfx::Size NativeThemeBase::GetPartSize(Part part, | 79 gfx::Size NativeThemeBase::GetPartSize(Part part, |
61 State state, | 80 State state, |
62 const ExtraParams& extra) const { | 81 const ExtraParams& extra) const { |
63 switch (part) { | 82 switch (part) { |
64 // Please keep these in the order of NativeTheme::Part. | 83 // Please keep these in the order of NativeTheme::Part. |
65 case kCheckbox: | 84 case kCheckbox: |
66 return gfx::Size(kCheckboxAndRadioWidth, kCheckboxAndRadioHeight); | 85 return gfx::Size(kCheckboxAndRadioWidth, kCheckboxAndRadioHeight); |
67 case kInnerSpinButton: | 86 case kInnerSpinButton: |
68 return gfx::Size(scrollbar_width_, 0); | 87 return gfx::Size(scrollbar_width_, 0); |
69 case kMenuList: | 88 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); | 1004 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); | 1005 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
987 | 1006 |
988 if (hsv1[2] + hsv2[2] > 1.0) | 1007 if (hsv1[2] + hsv2[2] > 1.0) |
989 diff = -diff; | 1008 diff = -diff; |
990 | 1009 |
991 return SaturateAndBrighten(hsv2, -0.2f, diff); | 1010 return SaturateAndBrighten(hsv2, -0.2f, diff); |
992 } | 1011 } |
993 | 1012 |
994 } // namespace gfx | 1013 } // namespace gfx |
OLD | NEW |