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

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

Issue 1135263002: stop using (deprecated) SkScalarDiv (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/color_chooser/color_chooser_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 const SkColor bar_colors[] = { 233 const SkColor bar_colors[] = {
234 kBarTopColor, 234 kBarTopColor,
235 kBarTopColor, 235 kBarTopColor,
236 kBarColorStart, 236 kBarColorStart,
237 kBarColorEnd, 237 kBarColorEnd,
238 kBarColorEnd, 238 kBarColorEnd,
239 }; 239 };
240 // We want a thin 1-pixel line for kBarTopColor. 240 // We want a thin 1-pixel line for kBarTopColor.
241 SkScalar scalar_height = SkIntToScalar(bar_height); 241 SkScalar scalar_height = SkIntToScalar(bar_height);
242 SkScalar highlight_width = SkScalarDiv(SK_Scalar1, scalar_height); 242 SkScalar highlight_width = 1 / scalar_height;
243 SkScalar border_width = SkScalarDiv(SkIntToScalar(kBorderWidth), 243 SkScalar border_width = kBorderWidth / scalar_height;
sky 2015/05/12 15:46:54 SKIntToScale(kBorderWidth) here and 286?
244 scalar_height);
245 const SkScalar bar_points[] = { 244 const SkScalar bar_points[] = {
246 0, 245 0,
247 border_width, 246 border_width,
248 border_width + highlight_width, 247 border_width + highlight_width,
249 SK_Scalar1 - border_width, 248 SK_Scalar1 - border_width,
250 SK_Scalar1, 249 SK_Scalar1,
251 }; 250 };
252 251
253 const SkColor disabled_bar_colors[] = { 252 const SkColor disabled_bar_colors[] = {
254 kDisabledBarColorStart, 253 kDisabledBarColorStart,
(...skipping 22 matching lines...) Expand all
277 false); 276 false);
278 277
279 if (enabled()) { 278 if (enabled()) {
280 // Draw the highlight to the right. 279 // Draw the highlight to the right.
281 const SkColor highlight_colors[] = { 280 const SkColor highlight_colors[] = {
282 SkColorSetA(kBarHighlightEnd, 0), 281 SkColorSetA(kBarHighlightEnd, 0),
283 kBarHighlightEnd, 282 kBarHighlightEnd,
284 kBarHighlightEnd, 283 kBarHighlightEnd,
285 }; 284 };
286 const SkScalar highlight_points[] = { 285 const SkScalar highlight_points[] = {
287 0, 286 0, SK_Scalar1 - kBorderWidth / scalar_height, SK_Scalar1,
288 SK_Scalar1 - SkScalarDiv(SkIntToScalar(kBorderWidth), scalar_height),
289 SK_Scalar1,
290 }; 287 };
291 SkPaint paint; 288 SkPaint paint;
292 paint.setStyle(SkPaint::kFill_Style); 289 paint.setStyle(SkPaint::kFill_Style);
293 paint.setFlags(SkPaint::kAntiAlias_Flag); 290 paint.setFlags(SkPaint::kAntiAlias_Flag);
294 291
295 SkPoint p[2]; 292 SkPoint p[2];
296 int highlight_left = 293 int highlight_left =
297 std::max(0, progress_width - kHighlightWidth - kBorderWidth); 294 std::max(0, progress_width - kHighlightWidth - kBorderWidth);
298 p[0].iset(highlight_left, 0); 295 p[0].iset(highlight_left, 0);
299 p[1].iset(progress_width, 0); 296 p[1].iset(progress_width, 0);
(...skipping 14 matching lines...) Expand all
314 // Draw bar stroke 311 // Draw bar stroke
315 StrokeRoundRect(canvas, 312 StrokeRoundRect(canvas,
316 bar_left, bar_top, progress_width, bar_height, 313 bar_left, bar_top, progress_width, bar_height,
317 kCornerRadius, 314 kCornerRadius,
318 enabled() ? kBarBorderColor : kDisabledBarBorderColor, 315 enabled() ? kBarBorderColor : kDisabledBarBorderColor,
319 kBorderWidth); 316 kBorderWidth);
320 } 317 }
321 } 318 }
322 319
323 } // namespace views 320 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/color_chooser/color_chooser_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698