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/views/controls/button/label_button_border.h" | 5 #include "ui/views/controls/button/label_button_border.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "third_party/skia/include/core/SkPaint.h" | 9 #include "third_party/skia/include/core/SkPaint.h" |
10 #include "third_party/skia/include/effects/SkLerpXfermode.h" | 10 #include "third_party/skia/include/effects/SkLerpXfermode.h" |
11 #include "ui/base/animation/animation.h" | |
12 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/gfx/animation/animation.h" |
13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
15 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
16 #include "ui/gfx/sys_color_change_listener.h" | 16 #include "ui/gfx/sys_color_change_listener.h" |
17 #include "ui/native_theme/native_theme.h" | 17 #include "ui/native_theme/native_theme.h" |
18 #include "ui/views/controls/button/label_button.h" | 18 #include "ui/views/controls/button/label_button.h" |
19 #include "ui/views/native_theme_delegate.h" | 19 #include "ui/views/native_theme_delegate.h" |
20 | 20 |
21 namespace views { | 21 namespace views { |
22 | 22 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 LabelButtonBorder::~LabelButtonBorder() {} | 112 LabelButtonBorder::~LabelButtonBorder() {} |
113 | 113 |
114 void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) { | 114 void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) { |
115 const NativeThemeDelegate* native_theme_delegate = | 115 const NativeThemeDelegate* native_theme_delegate = |
116 static_cast<const LabelButton*>(&view); | 116 static_cast<const LabelButton*>(&view); |
117 ui::NativeTheme::Part part = native_theme_delegate->GetThemePart(); | 117 ui::NativeTheme::Part part = native_theme_delegate->GetThemePart(); |
118 gfx::Rect rect(native_theme_delegate->GetThemePaintRect()); | 118 gfx::Rect rect(native_theme_delegate->GetThemePaintRect()); |
119 ui::NativeTheme::ExtraParams extra; | 119 ui::NativeTheme::ExtraParams extra; |
120 const ui::NativeTheme* theme = view.GetNativeTheme(); | 120 const ui::NativeTheme* theme = view.GetNativeTheme(); |
121 const ui::Animation* animation = native_theme_delegate->GetThemeAnimation(); | 121 const gfx::Animation* animation = native_theme_delegate->GetThemeAnimation(); |
122 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); | 122 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); |
123 | 123 |
124 if (animation && animation->is_animating()) { | 124 if (animation && animation->is_animating()) { |
125 // Linearly interpolate background and foreground painters during animation. | 125 // Linearly interpolate background and foreground painters during animation. |
126 const SkRect sk_rect = gfx::RectToSkRect(rect); | 126 const SkRect sk_rect = gfx::RectToSkRect(rect); |
127 canvas->sk_canvas()->saveLayer(&sk_rect, NULL); | 127 canvas->sk_canvas()->saveLayer(&sk_rect, NULL); |
128 state = native_theme_delegate->GetBackgroundThemeState(&extra); | 128 state = native_theme_delegate->GetBackgroundThemeState(&extra); |
129 PaintHelper(this, canvas, theme, part, state, rect, extra); | 129 PaintHelper(this, canvas, theme, part, state, rect, extra); |
130 | 130 |
131 SkPaint paint; | 131 SkPaint paint; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return painters_[focused ? 1 : 0][state].get(); | 163 return painters_[focused ? 1 : 0][state].get(); |
164 } | 164 } |
165 | 165 |
166 void LabelButtonBorder::SetPainter(bool focused, | 166 void LabelButtonBorder::SetPainter(bool focused, |
167 Button::ButtonState state, | 167 Button::ButtonState state, |
168 Painter* painter) { | 168 Painter* painter) { |
169 painters_[focused ? 1 : 0][state].reset(painter); | 169 painters_[focused ? 1 : 0][state].reset(painter); |
170 } | 170 } |
171 | 171 |
172 } // namespace views | 172 } // namespace views |
OLD | NEW |