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

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

Issue 2680943002: ui: Clean up naming of paint-related identifiers (Closed)
Patch Set: 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 "cc/paint/paint_flags.h"
8 #include "third_party/skia/include/core/SkColor.h" 8 #include "third_party/skia/include/core/SkColor.h"
9 #include "third_party/skia/include/core/SkPaint.h" 9 #include "third_party/skia/include/core/SkPaint.h"
10 #include "ui/gfx/animation/slide_animation.h" 10 #include "ui/gfx/animation/slide_animation.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const int full = GetAnimatingValue() * width; 53 const int full = GetAnimatingValue() * width;
54 const int empty = width - full; 54 const int empty = width - full;
55 const int y = content.height() / 2 - kLineThickness / 2; 55 const int y = content.height() / 2 - kLineThickness / 2;
56 const int x = content.x() + full + kThumbRadius; 56 const int x = content.x() + full + kThumbRadius;
57 const SkColor current_thumb_color = 57 const SkColor current_thumb_color =
58 is_active_ ? kActiveColor : kDisabledColor; 58 is_active_ ? kActiveColor : kDisabledColor;
59 59
60 // Extra space used to hide slider ends behind the thumb. 60 // Extra space used to hide slider ends behind the thumb.
61 const int extra_padding = 1; 61 const int extra_padding = 1;
62 62
63 cc::PaintFlags slider_paint; 63 cc::PaintFlags slider_flags;
64 slider_paint.setAntiAlias(true); 64 slider_flags.setAntiAlias(true);
65 slider_paint.setColor(current_thumb_color); 65 slider_flags.setColor(current_thumb_color);
66 canvas->DrawRoundRect( 66 canvas->DrawRoundRect(
67 gfx::Rect(content.x(), y, full + extra_padding, kLineThickness), 67 gfx::Rect(content.x(), y, full + extra_padding, kLineThickness),
68 kSliderRoundedRadius, slider_paint); 68 kSliderRoundedRadius, slider_flags);
69 slider_paint.setColor(kDisabledColor); 69 slider_flags.setColor(kDisabledColor);
70 canvas->DrawRoundRect(gfx::Rect(x + kThumbRadius - extra_padding, y, 70 canvas->DrawRoundRect(gfx::Rect(x + kThumbRadius - extra_padding, y,
71 empty + extra_padding, kLineThickness), 71 empty + extra_padding, kLineThickness),
72 kSliderRoundedRadius, slider_paint); 72 kSliderRoundedRadius, slider_flags);
73 73
74 gfx::Point thumb_center(x, content.height() / 2); 74 gfx::Point thumb_center(x, content.height() / 2);
75 75
76 // Paint the thumb highlight if it exists. 76 // Paint the thumb highlight if it exists.
77 const int thumb_highlight_radius = 77 const int thumb_highlight_radius =
78 HasFocus() ? kThumbHighlightRadius : thumb_highlight_radius_; 78 HasFocus() ? kThumbHighlightRadius : thumb_highlight_radius_;
79 if (is_active_ && thumb_highlight_radius > kThumbRadius) { 79 if (is_active_ && thumb_highlight_radius > kThumbRadius) {
80 cc::PaintFlags highlight; 80 cc::PaintFlags highlight;
81 SkColor kHighlightColor = SkColorSetA(kActiveColor, kHighlightColorAlpha); 81 SkColor kHighlightColor = SkColorSetA(kActiveColor, kHighlightColorAlpha);
82 highlight.setColor(kHighlightColor); 82 highlight.setColor(kHighlightColor);
83 highlight.setFlags(cc::PaintFlags::kAntiAlias_Flag); 83 highlight.setFlags(cc::PaintFlags::kAntiAlias_Flag);
84 canvas->DrawCircle(thumb_center, thumb_highlight_radius, highlight); 84 canvas->DrawCircle(thumb_center, thumb_highlight_radius, highlight);
85 } 85 }
86 86
87 // Paint the thumb of the slider. 87 // Paint the thumb of the slider.
88 cc::PaintFlags paint; 88 cc::PaintFlags flags;
89 paint.setColor(current_thumb_color); 89 flags.setColor(current_thumb_color);
90 paint.setFlags(cc::PaintFlags::kAntiAlias_Flag); 90 flags.setFlags(cc::PaintFlags::kAntiAlias_Flag);
91 91
92 if (!is_active_) { 92 if (!is_active_) {
93 paint.setStrokeWidth(kThumbStroke); 93 flags.setStrokeWidth(kThumbStroke);
94 paint.setStyle(cc::PaintFlags::kStroke_Style); 94 flags.setStyle(cc::PaintFlags::kStroke_Style);
95 } 95 }
96 canvas->DrawCircle( 96 canvas->DrawCircle(
97 thumb_center, 97 thumb_center,
98 is_active_ ? kThumbRadius : (kThumbRadius - kThumbStroke / 2), paint); 98 is_active_ ? kThumbRadius : (kThumbRadius - kThumbStroke / 2), flags);
99 } 99 }
100 100
101 const char* MdSlider::GetClassName() const { 101 const char* MdSlider::GetClassName() const {
102 return "MdSlider"; 102 return "MdSlider";
103 } 103 }
104 104
105 void MdSlider::UpdateState(bool control_on) { 105 void MdSlider::UpdateState(bool control_on) {
106 is_active_ = control_on; 106 is_active_ = control_on;
107 SchedulePaint(); 107 SchedulePaint();
108 } 108 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Slider::AnimationEnded(animation); 140 Slider::AnimationEnded(animation);
141 return; 141 return;
142 } 142 }
143 if (animation == highlight_animation_.get() && 143 if (animation == highlight_animation_.get() &&
144 !highlight_animation_->IsShowing()) { 144 !highlight_animation_->IsShowing()) {
145 highlight_animation_.reset(); 145 highlight_animation_.reset();
146 } 146 }
147 } 147 }
148 148
149 } // 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