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/native_theme/common_theme.h" | 5 #include "ui/native_theme/common_theme.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
11 #include "ui/gfx/color_utils.h" | 11 #include "ui/gfx/color_utils.h" |
12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
13 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
14 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
15 #include "ui/gfx/sys_color_change_listener.h" | |
16 #include "ui/resources/grit/ui_resources.h" | 15 #include "ui/resources/grit/ui_resources.h" |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
20 // Theme colors returned by GetSystemColor(). | 19 // Theme colors returned by GetSystemColor(). |
21 | 20 |
22 // MenuItem: | 21 // MenuItem: |
23 const SkColor kMenuBackgroundColor = SK_ColorWHITE; | 22 const SkColor kMenuBackgroundColor = SK_ColorWHITE; |
24 const SkColor kMenuHighlightBackgroundColor = SkColorSetRGB(0x42, 0x81, 0xF4); | 23 const SkColor kMenuHighlightBackgroundColor = SkColorSetRGB(0x42, 0x81, 0xF4); |
25 const SkColor kMenuInvertedSchemeHighlightBackgroundColor = | 24 const SkColor kMenuInvertedSchemeHighlightBackgroundColor = |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 case NativeTheme::kColorId_ThrobberWaitingColor: | 116 case NativeTheme::kColorId_ThrobberWaitingColor: |
118 *color = kThrobberWaitingColor; | 117 *color = kThrobberWaitingColor; |
119 break; | 118 break; |
120 case NativeTheme::kColorId_ThrobberLightColor: | 119 case NativeTheme::kColorId_ThrobberLightColor: |
121 *color = kThrobberLightColor; | 120 *color = kThrobberLightColor; |
122 break; | 121 break; |
123 default: | 122 default: |
124 return false; | 123 return false; |
125 } | 124 } |
126 | 125 |
127 if (gfx::IsInvertedColorScheme()) { | 126 if (color_utils::IsInvertedColorScheme()) { |
128 switch (color_id) { | 127 switch (color_id) { |
129 case NativeTheme::kColorId_FocusedMenuItemBackgroundColor: | 128 case NativeTheme::kColorId_FocusedMenuItemBackgroundColor: |
130 *color = kMenuInvertedSchemeHighlightBackgroundColor; | 129 *color = kMenuInvertedSchemeHighlightBackgroundColor; |
131 break; | 130 break; |
132 default: | 131 default: |
133 *color = color_utils::InvertColor(*color); | 132 *color = color_utils::InvertColor(*color); |
134 } | 133 } |
135 } | 134 } |
136 return true; | 135 return true; |
137 } | 136 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // static | 217 // static |
219 scoped_ptr<gfx::Canvas> CommonThemeCreateCanvas(SkCanvas* sk_canvas) { | 218 scoped_ptr<gfx::Canvas> CommonThemeCreateCanvas(SkCanvas* sk_canvas) { |
220 // TODO(pkotwicz): Do something better and don't infer device | 219 // TODO(pkotwicz): Do something better and don't infer device |
221 // scale factor from canvas scale. | 220 // scale factor from canvas scale. |
222 SkMatrix m = sk_canvas->getTotalMatrix(); | 221 SkMatrix m = sk_canvas->getTotalMatrix(); |
223 float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); | 222 float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); |
224 return make_scoped_ptr(new gfx::Canvas(sk_canvas, device_scale)); | 223 return make_scoped_ptr(new gfx::Canvas(sk_canvas, device_scale)); |
225 } | 224 } |
226 | 225 |
227 } // namespace ui | 226 } // namespace ui |
OLD | NEW |