Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: ui/views/controls/md_slider.cc

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/image_view.cc ('k') | ui/views/controls/menu/menu_scroll_view_container.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/paint/paint_flags.h"
7 #include "third_party/skia/include/core/SkColor.h" 8 #include "third_party/skia/include/core/SkColor.h"
8 #include "third_party/skia/include/core/SkPaint.h" 9 #include "third_party/skia/include/core/SkPaint.h"
9 #include "ui/gfx/animation/slide_animation.h" 10 #include "ui/gfx/animation/slide_animation.h"
10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/geometry/point.h" 12 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
13 #include "ui/views/controls/slider.h" 14 #include "ui/views/controls/slider.h"
14 15
15 namespace views { 16 namespace views {
16 17
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const int full = GetAnimatingValue() * width; 53 const int full = GetAnimatingValue() * width;
53 const int empty = width - full; 54 const int empty = width - full;
54 const int y = content.height() / 2 - kLineThickness / 2; 55 const int y = content.height() / 2 - kLineThickness / 2;
55 const int x = content.x() + full + kThumbRadius; 56 const int x = content.x() + full + kThumbRadius;
56 const SkColor current_thumb_color = 57 const SkColor current_thumb_color =
57 is_active_ ? kActiveColor : kDisabledColor; 58 is_active_ ? kActiveColor : kDisabledColor;
58 59
59 // Extra space used to hide slider ends behind the thumb. 60 // Extra space used to hide slider ends behind the thumb.
60 const int extra_padding = 1; 61 const int extra_padding = 1;
61 62
62 SkPaint slider_paint; 63 cc::PaintFlags slider_paint;
63 slider_paint.setFlags(SkPaint::kAntiAlias_Flag); 64 slider_paint.setAntiAlias(true);
64 slider_paint.setColor(current_thumb_color); 65 slider_paint.setColor(current_thumb_color);
65 canvas->DrawRoundRect( 66 canvas->DrawRoundRect(
66 gfx::Rect(content.x(), y, full + extra_padding, kLineThickness), 67 gfx::Rect(content.x(), y, full + extra_padding, kLineThickness),
67 kSliderRoundedRadius, slider_paint); 68 kSliderRoundedRadius, slider_paint);
68 slider_paint.setColor(kDisabledColor); 69 slider_paint.setColor(kDisabledColor);
69 canvas->DrawRoundRect(gfx::Rect(x + kThumbRadius - extra_padding, y, 70 canvas->DrawRoundRect(gfx::Rect(x + kThumbRadius - extra_padding, y,
70 empty + extra_padding, kLineThickness), 71 empty + extra_padding, kLineThickness),
71 kSliderRoundedRadius, slider_paint); 72 kSliderRoundedRadius, slider_paint);
72 73
73 gfx::Point thumb_center(x, content.height() / 2); 74 gfx::Point thumb_center(x, content.height() / 2);
74 75
75 // Paint the thumb highlight if it exists. 76 // Paint the thumb highlight if it exists.
76 const int thumb_highlight_radius = 77 const int thumb_highlight_radius =
77 HasFocus() ? kThumbHighlightRadius : thumb_highlight_radius_; 78 HasFocus() ? kThumbHighlightRadius : thumb_highlight_radius_;
78 if (is_active_ && thumb_highlight_radius > kThumbRadius) { 79 if (is_active_ && thumb_highlight_radius > kThumbRadius) {
79 SkPaint highlight; 80 cc::PaintFlags highlight;
80 SkColor kHighlightColor = SkColorSetA(kActiveColor, kHighlightColorAlpha); 81 SkColor kHighlightColor = SkColorSetA(kActiveColor, kHighlightColorAlpha);
81 highlight.setColor(kHighlightColor); 82 highlight.setColor(kHighlightColor);
82 highlight.setFlags(SkPaint::kAntiAlias_Flag); 83 highlight.setFlags(cc::PaintFlags::kAntiAlias_Flag);
83 canvas->DrawCircle(thumb_center, thumb_highlight_radius, highlight); 84 canvas->DrawCircle(thumb_center, thumb_highlight_radius, highlight);
84 } 85 }
85 86
86 // Paint the thumb of the slider. 87 // Paint the thumb of the slider.
87 SkPaint paint; 88 cc::PaintFlags paint;
88 paint.setColor(current_thumb_color); 89 paint.setColor(current_thumb_color);
89 paint.setFlags(SkPaint::kAntiAlias_Flag); 90 paint.setFlags(cc::PaintFlags::kAntiAlias_Flag);
90 91
91 if (!is_active_) { 92 if (!is_active_) {
92 paint.setStrokeWidth(kThumbStroke); 93 paint.setStrokeWidth(kThumbStroke);
93 paint.setStyle(SkPaint::kStroke_Style); 94 paint.setStyle(cc::PaintFlags::kStroke_Style);
94 } 95 }
95 canvas->DrawCircle( 96 canvas->DrawCircle(
96 thumb_center, 97 thumb_center,
97 is_active_ ? kThumbRadius : (kThumbRadius - kThumbStroke / 2), paint); 98 is_active_ ? kThumbRadius : (kThumbRadius - kThumbStroke / 2), paint);
98 } 99 }
99 100
100 const char* MdSlider::GetClassName() const { 101 const char* MdSlider::GetClassName() const {
101 return "MdSlider"; 102 return "MdSlider";
102 } 103 }
103 104
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 Slider::AnimationEnded(animation); 140 Slider::AnimationEnded(animation);
140 return; 141 return;
141 } 142 }
142 if (animation == highlight_animation_.get() && 143 if (animation == highlight_animation_.get() &&
143 !highlight_animation_->IsShowing()) { 144 !highlight_animation_->IsShowing()) {
144 highlight_animation_.reset(); 145 highlight_animation_.reset();
145 } 146 }
146 } 147 }
147 148
148 } // namespace views 149 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/image_view.cc ('k') | ui/views/controls/menu/menu_scroll_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698