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