| 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/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 { | 17 namespace { |
| 18 | 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 kDefaultFocusedBorderColor= SkColorSetRGB(0x4D, 0x90, 0xFE); |
| 22 const SkColor kDefaultUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9); |
| 23 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); |
| 24 |
| 19 // These are the default dimensions of radio buttons and checkboxes. | 25 // These are the default dimensions of radio buttons and checkboxes. |
| 20 const int kCheckboxAndRadioWidth = 13; | 26 const int kCheckboxAndRadioWidth = 13; |
| 21 const int kCheckboxAndRadioHeight = 13; | 27 const int kCheckboxAndRadioHeight = 13; |
| 22 | 28 |
| 23 // These sizes match the sizes in Chromium Win. | 29 // These sizes match the sizes in Chromium Win. |
| 24 const int kSliderThumbWidth = 11; | 30 const int kSliderThumbWidth = 11; |
| 25 const int kSliderThumbHeight = 21; | 31 const int kSliderThumbHeight = 21; |
| 26 | 32 |
| 27 const SkColor kSliderTrackBackgroundColor = | 33 const SkColor kSliderTrackBackgroundColor = |
| 28 SkColorSetRGB(0xe3, 0xdd, 0xd8); | 34 SkColorSetRGB(0xe3, 0xdd, 0xd8); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 case kTrackbarTrack: | 201 case kTrackbarTrack: |
| 196 case kWindowResizeGripper: | 202 case kWindowResizeGripper: |
| 197 NOTIMPLEMENTED(); | 203 NOTIMPLEMENTED(); |
| 198 break; | 204 break; |
| 199 default: | 205 default: |
| 200 NOTREACHED() << "Unknown theme part: " << part; | 206 NOTREACHED() << "Unknown theme part: " << part; |
| 201 break; | 207 break; |
| 202 } | 208 } |
| 203 } | 209 } |
| 204 | 210 |
| 211 SkColor NativeThemeBase::GetSystemColor(ColorId color_id) const { |
| 212 // This implementation returns hardcoded colors. It's used by NativeThemeAura |
| 213 // and NativeThemeChromeos and overridden by NativeThemeGtk. |
| 214 switch (color_id) { |
| 215 case kColorId_DialogBackground: |
| 216 return kDefaultDialogBackgroundColor; |
| 217 case kColorId_FocusedBorderColor: |
| 218 return kDefaultFocusedBorderColor; |
| 219 case kColorId_UnfocusedBorderColor: |
| 220 return kDefaultUnfocusedBorderColor; |
| 221 default: |
| 222 NOTREACHED() << "Invalid color_id: " << color_id; |
| 223 break; |
| 224 } |
| 225 return kInvalidColorIdColor; |
| 226 } |
| 227 |
| 205 NativeThemeBase::NativeThemeBase() { | 228 NativeThemeBase::NativeThemeBase() { |
| 206 } | 229 } |
| 207 | 230 |
| 208 NativeThemeBase::~NativeThemeBase() { | 231 NativeThemeBase::~NativeThemeBase() { |
| 209 } | 232 } |
| 210 | 233 |
| 211 void NativeThemeBase::PaintArrowButton( | 234 void NativeThemeBase::PaintArrowButton( |
| 212 SkCanvas* canvas, | 235 SkCanvas* canvas, |
| 213 const gfx::Rect& rect, Part direction, State state) const { | 236 const gfx::Rect& rect, Part direction, State state) const { |
| 214 int widthMiddle, lengthMiddle; | 237 int widthMiddle, lengthMiddle; |
| (...skipping 770 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); | 1008 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); | 1009 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
| 987 | 1010 |
| 988 if (hsv1[2] + hsv2[2] > 1.0) | 1011 if (hsv1[2] + hsv2[2] > 1.0) |
| 989 diff = -diff; | 1012 diff = -diff; |
| 990 | 1013 |
| 991 return SaturateAndBrighten(hsv2, -0.2f, diff); | 1014 return SaturateAndBrighten(hsv2, -0.2f, diff); |
| 992 } | 1015 } |
| 993 | 1016 |
| 994 } // namespace gfx | 1017 } // namespace gfx |
| OLD | NEW |