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