| 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_linux.h" | 5 #include "ui/gfx/native_theme_linux.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "grit/gfx_resources.h" | 11 #include "grit/gfx_resources.h" |
| 11 #include "third_party/skia/include/effects/SkGradientShader.h" | 12 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/color_utils.h" | 14 #include "ui/gfx/color_utils.h" |
| 14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 15 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 16 | 17 |
| 17 namespace gfx { | 18 namespace gfx { |
| 18 | 19 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 static const SkColor kSliderThumbLightGrey = SkColorSetRGB(0xf4, 0xf2, 0xef); | 37 static const SkColor kSliderThumbLightGrey = SkColorSetRGB(0xf4, 0xf2, 0xef); |
| 37 static const SkColor kSliderThumbDarkGrey = SkColorSetRGB(0xea, 0xe5, 0xe0); | 38 static const SkColor kSliderThumbDarkGrey = SkColorSetRGB(0xea, 0xe5, 0xe0); |
| 38 static const SkColor kSliderThumbBorderDarkGrey = | 39 static const SkColor kSliderThumbBorderDarkGrey = |
| 39 SkColorSetRGB(0x9d, 0x96, 0x8e); | 40 SkColorSetRGB(0x9d, 0x96, 0x8e); |
| 40 | 41 |
| 41 // static | 42 // static |
| 42 const NativeTheme* NativeTheme::instance() { | 43 const NativeTheme* NativeTheme::instance() { |
| 43 return NativeThemeLinux::instance(); | 44 return NativeThemeLinux::instance(); |
| 44 } | 45 } |
| 45 | 46 |
| 47 static base::LazyInstance<NativeThemeLinux> g_native_theme( |
| 48 base::LINKER_INITIALIZED); |
| 49 |
| 50 NativeThemeLinux::NativeThemeLinux() { |
| 51 } |
| 52 |
| 53 NativeThemeLinux::~NativeThemeLinux() { |
| 54 } |
| 55 |
| 46 #if !defined(OS_CHROMEOS) | 56 #if !defined(OS_CHROMEOS) |
| 47 // Chromeos has a different look. | 57 // Chromeos has a different look. |
| 48 // static | 58 // static |
| 49 const NativeThemeLinux* NativeThemeLinux::instance() { | 59 const NativeThemeLinux* NativeThemeLinux::instance() { |
| 50 // The global NativeThemeLinux instance. | 60 return g_native_theme.Pointer(); |
| 51 static NativeThemeLinux s_native_theme; | |
| 52 return &s_native_theme; | |
| 53 } | 61 } |
| 54 #endif | 62 #endif |
| 55 | 63 |
| 56 // Get lightness adjusted color. | 64 // Get lightness adjusted color. |
| 57 static SkColor BrightenColor(const color_utils::HSL& hsl, SkAlpha alpha, | 65 static SkColor BrightenColor(const color_utils::HSL& hsl, |
| 58 double lightness_amount) { | 66 SkAlpha alpha, |
| 67 double lightness_amount) { |
| 59 color_utils::HSL adjusted = hsl; | 68 color_utils::HSL adjusted = hsl; |
| 60 adjusted.l += lightness_amount; | 69 adjusted.l += lightness_amount; |
| 61 if (adjusted.l > 1.0) | 70 if (adjusted.l > 1.0) |
| 62 adjusted.l = 1.0; | 71 adjusted.l = 1.0; |
| 63 if (adjusted.l < 0.0) | 72 if (adjusted.l < 0.0) |
| 64 adjusted.l = 0.0; | 73 adjusted.l = 0.0; |
| 65 | 74 |
| 66 return color_utils::HSLToSkColor(adjusted, alpha); | 75 return color_utils::HSLToSkColor(adjusted, alpha); |
| 67 } | 76 } |
| 68 | 77 |
| 69 NativeThemeLinux::NativeThemeLinux() { | |
| 70 } | |
| 71 | |
| 72 NativeThemeLinux::~NativeThemeLinux() { | |
| 73 } | |
| 74 | |
| 75 gfx::Size NativeThemeLinux::GetPartSize(Part part, | 78 gfx::Size NativeThemeLinux::GetPartSize(Part part, |
| 76 State state, | 79 State state, |
| 77 const ExtraParams& extra) const { | 80 const ExtraParams& extra) const { |
| 78 switch (part) { | 81 switch (part) { |
| 79 case kScrollbarDownArrow: | 82 case kScrollbarDownArrow: |
| 80 case kScrollbarUpArrow: | 83 case kScrollbarUpArrow: |
| 81 return gfx::Size(scrollbar_width_, button_length_); | 84 return gfx::Size(scrollbar_width_, button_length_); |
| 82 case kScrollbarLeftArrow: | 85 case kScrollbarLeftArrow: |
| 83 case kScrollbarRightArrow: | 86 case kScrollbarRightArrow: |
| 84 return gfx::Size(button_length_, scrollbar_width_); | 87 return gfx::Size(button_length_, scrollbar_width_); |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5); | 929 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5); |
| 927 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5); | 930 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5); |
| 928 | 931 |
| 929 if (hsv1[2] + hsv2[2] > 1.0) | 932 if (hsv1[2] + hsv2[2] > 1.0) |
| 930 diff = -diff; | 933 diff = -diff; |
| 931 | 934 |
| 932 return SaturateAndBrighten(hsv2, -0.2, diff); | 935 return SaturateAndBrighten(hsv2, -0.2, diff); |
| 933 } | 936 } |
| 934 | 937 |
| 935 } // namespace gfx | 938 } // namespace gfx |
| OLD | NEW |