OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/md_slider.h" | 5 #include "ui/views/controls/md_slider.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkColor.h" | 7 #include "third_party/skia/include/core/SkColor.h" |
8 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
9 #include "ui/gfx/animation/slide_animation.h" | 9 #include "ui/gfx/animation/slide_animation.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 gfx::Rect(content.x(), y, full + extra_padding, kLineThickness), | 66 gfx::Rect(content.x(), y, full + extra_padding, kLineThickness), |
67 kSliderRoundedRadius, slider_paint); | 67 kSliderRoundedRadius, slider_paint); |
68 slider_paint.setColor(kDisabledColor); | 68 slider_paint.setColor(kDisabledColor); |
69 canvas->DrawRoundRect(gfx::Rect(x + kThumbRadius - extra_padding, y, | 69 canvas->DrawRoundRect(gfx::Rect(x + kThumbRadius - extra_padding, y, |
70 empty + extra_padding, kLineThickness), | 70 empty + extra_padding, kLineThickness), |
71 kSliderRoundedRadius, slider_paint); | 71 kSliderRoundedRadius, slider_paint); |
72 | 72 |
73 gfx::Point thumb_center(x, content.height() / 2); | 73 gfx::Point thumb_center(x, content.height() / 2); |
74 | 74 |
75 // Paint the thumb highlight if it exists. | 75 // Paint the thumb highlight if it exists. |
76 if (is_active_ && thumb_highlight_radius_ > kThumbRadius) { | 76 const int thumb_highlight_radius = |
| 77 HasFocus() ? kThumbHighlightRadius : thumb_highlight_radius_; |
| 78 if (is_active_ && thumb_highlight_radius > kThumbRadius) { |
77 SkPaint highlight; | 79 SkPaint highlight; |
78 SkColor kHighlightColor = SkColorSetA(kActiveColor, kHighlightColorAlpha); | 80 SkColor kHighlightColor = SkColorSetA(kActiveColor, kHighlightColorAlpha); |
79 highlight.setColor(kHighlightColor); | 81 highlight.setColor(kHighlightColor); |
80 highlight.setFlags(SkPaint::kAntiAlias_Flag); | 82 highlight.setFlags(SkPaint::kAntiAlias_Flag); |
81 canvas->DrawCircle(thumb_center, thumb_highlight_radius_, highlight); | 83 canvas->DrawCircle(thumb_center, thumb_highlight_radius, highlight); |
82 } | 84 } |
83 | 85 |
84 // Paint the thumb of the slider. | 86 // Paint the thumb of the slider. |
85 SkPaint paint; | 87 SkPaint paint; |
86 paint.setColor(current_thumb_color); | 88 paint.setColor(current_thumb_color); |
87 paint.setFlags(SkPaint::kAntiAlias_Flag); | 89 paint.setFlags(SkPaint::kAntiAlias_Flag); |
88 | 90 |
89 if (!is_active_) { | 91 if (!is_active_) { |
90 paint.setStrokeWidth(kThumbStroke); | 92 paint.setStrokeWidth(kThumbStroke); |
91 paint.setStyle(SkPaint::kStroke_Style); | 93 paint.setStyle(SkPaint::kStroke_Style); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 Slider::AnimationEnded(animation); | 139 Slider::AnimationEnded(animation); |
138 return; | 140 return; |
139 } | 141 } |
140 if (animation == highlight_animation_.get() && | 142 if (animation == highlight_animation_.get() && |
141 !highlight_animation_->IsShowing()) { | 143 !highlight_animation_->IsShowing()) { |
142 highlight_animation_.reset(); | 144 highlight_animation_.reset(); |
143 } | 145 } |
144 } | 146 } |
145 | 147 |
146 } // namespace views | 148 } // namespace views |
OLD | NEW |