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

Side by Side Diff: ui/views/controls/progress_bar.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
OLDNEW
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/progress_bar.h" 5 #include "ui/views/controls/progress_bar.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 void ProgressBar::OnPaint(gfx::Canvas* canvas) { 70 void ProgressBar::OnPaint(gfx::Canvas* canvas) {
71 if (IsIndeterminate()) 71 if (IsIndeterminate())
72 return OnPaintIndeterminate(canvas); 72 return OnPaintIndeterminate(canvas);
73 73
74 gfx::Rect content_bounds = GetContentsBounds(); 74 gfx::Rect content_bounds = GetContentsBounds();
75 75
76 // Draw background. 76 // Draw background.
77 SkPath background_path; 77 SkPath background_path;
78 AddPossiblyRoundRectToPath(content_bounds, &background_path); 78 AddPossiblyRoundRectToPath(content_bounds, &background_path);
79 cc::PaintFlags background_paint; 79 cc::PaintFlags background_flags;
80 background_paint.setStyle(cc::PaintFlags::kFill_Style); 80 background_flags.setStyle(cc::PaintFlags::kFill_Style);
81 background_paint.setAntiAlias(true); 81 background_flags.setAntiAlias(true);
82 background_paint.setColor(GetBackgroundColor()); 82 background_flags.setColor(GetBackgroundColor());
83 canvas->DrawPath(background_path, background_paint); 83 canvas->DrawPath(background_path, background_flags);
84 84
85 // Draw slice. 85 // Draw slice.
86 SkPath slice_path; 86 SkPath slice_path;
87 const int slice_width = static_cast<int>( 87 const int slice_width = static_cast<int>(
88 content_bounds.width() * std::min(current_value_, 1.0) + 0.5); 88 content_bounds.width() * std::min(current_value_, 1.0) + 0.5);
89 if (slice_width < 1) 89 if (slice_width < 1)
90 return; 90 return;
91 91
92 gfx::Rect slice_bounds = content_bounds; 92 gfx::Rect slice_bounds = content_bounds;
93 slice_bounds.set_width(slice_width); 93 slice_bounds.set_width(slice_width);
94 AddPossiblyRoundRectToPath(slice_bounds, &slice_path); 94 AddPossiblyRoundRectToPath(slice_bounds, &slice_path);
95 95
96 cc::PaintFlags slice_paint; 96 cc::PaintFlags slice_flags;
97 slice_paint.setStyle(cc::PaintFlags::kFill_Style); 97 slice_flags.setStyle(cc::PaintFlags::kFill_Style);
98 slice_paint.setAntiAlias(true); 98 slice_flags.setAntiAlias(true);
99 slice_paint.setColor(GetForegroundColor()); 99 slice_flags.setColor(GetForegroundColor());
100 canvas->DrawPath(slice_path, slice_paint); 100 canvas->DrawPath(slice_path, slice_flags);
101 } 101 }
102 102
103 void ProgressBar::SetValue(double value) { 103 void ProgressBar::SetValue(double value) {
104 double adjusted_value = (value < 0.0 || value > 1.0) ? -1.0 : value; 104 double adjusted_value = (value < 0.0 || value > 1.0) ? -1.0 : value;
105 105
106 if (adjusted_value == current_value_) 106 if (adjusted_value == current_value_)
107 return; 107 return;
108 108
109 current_value_ = adjusted_value; 109 current_value_ = adjusted_value;
110 if (IsIndeterminate()) { 110 if (IsIndeterminate()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 bool ProgressBar::IsIndeterminate() { 144 bool ProgressBar::IsIndeterminate() {
145 return current_value_ < 0.0; 145 return current_value_ < 0.0;
146 } 146 }
147 147
148 void ProgressBar::OnPaintIndeterminate(gfx::Canvas* canvas) { 148 void ProgressBar::OnPaintIndeterminate(gfx::Canvas* canvas) {
149 gfx::Rect content_bounds = GetContentsBounds(); 149 gfx::Rect content_bounds = GetContentsBounds();
150 150
151 // Draw background. 151 // Draw background.
152 SkPath background_path; 152 SkPath background_path;
153 AddPossiblyRoundRectToPath(content_bounds, &background_path); 153 AddPossiblyRoundRectToPath(content_bounds, &background_path);
154 cc::PaintFlags background_paint; 154 cc::PaintFlags background_flags;
155 background_paint.setStyle(cc::PaintFlags::kFill_Style); 155 background_flags.setStyle(cc::PaintFlags::kFill_Style);
156 background_paint.setAntiAlias(true); 156 background_flags.setAntiAlias(true);
157 background_paint.setColor(GetBackgroundColor()); 157 background_flags.setColor(GetBackgroundColor());
158 canvas->DrawPath(background_path, background_paint); 158 canvas->DrawPath(background_path, background_flags);
159 159
160 // Draw slice. 160 // Draw slice.
161 SkPath slice_path; 161 SkPath slice_path;
162 double time = indeterminate_bar_animation_->GetCurrentValue(); 162 double time = indeterminate_bar_animation_->GetCurrentValue();
163 163
164 // The animation spec corresponds to the material design lite's parameter. 164 // The animation spec corresponds to the material design lite's parameter.
165 // (cf. https://github.com/google/material-design-lite/) 165 // (cf. https://github.com/google/material-design-lite/)
166 double bar1_left; 166 double bar1_left;
167 double bar1_width; 167 double bar1_width;
168 double bar2_left; 168 double bar2_left;
(...skipping 23 matching lines...) Expand all
192 content_bounds.width() * std::min(1.0, bar2_left + bar2_width)); 192 content_bounds.width() * std::min(1.0, bar2_left + bar2_width));
193 193
194 gfx::Rect slice_bounds = content_bounds; 194 gfx::Rect slice_bounds = content_bounds;
195 slice_bounds.set_x(content_bounds.x() + bar1_start_x); 195 slice_bounds.set_x(content_bounds.x() + bar1_start_x);
196 slice_bounds.set_width(bar1_end_x - bar1_start_x); 196 slice_bounds.set_width(bar1_end_x - bar1_start_x);
197 AddPossiblyRoundRectToPath(slice_bounds, &slice_path); 197 AddPossiblyRoundRectToPath(slice_bounds, &slice_path);
198 slice_bounds.set_x(content_bounds.x() + bar2_start_x); 198 slice_bounds.set_x(content_bounds.x() + bar2_start_x);
199 slice_bounds.set_width(bar2_end_x - bar2_start_x); 199 slice_bounds.set_width(bar2_end_x - bar2_start_x);
200 AddPossiblyRoundRectToPath(slice_bounds, &slice_path); 200 AddPossiblyRoundRectToPath(slice_bounds, &slice_path);
201 201
202 cc::PaintFlags slice_paint; 202 cc::PaintFlags slice_flags;
203 slice_paint.setStyle(cc::PaintFlags::kFill_Style); 203 slice_flags.setStyle(cc::PaintFlags::kFill_Style);
204 slice_paint.setAntiAlias(true); 204 slice_flags.setAntiAlias(true);
205 slice_paint.setColor(GetForegroundColor()); 205 slice_flags.setColor(GetForegroundColor());
206 canvas->DrawPath(slice_path, slice_paint); 206 canvas->DrawPath(slice_path, slice_flags);
207 } 207 }
208 208
209 } // namespace views 209 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_scroll_view_container.cc ('k') | ui/views/controls/scrollbar/cocoa_scroll_bar.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698