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

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

Issue 9562038: ui/gfx: Make gfx::Canvas inherit from gfx::CanvasSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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 | Annotate | Revision Log
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 182
183 gfx::Size ProgressBar::GetPreferredSize() { 183 gfx::Size ProgressBar::GetPreferredSize() {
184 return gfx::Size(100, 16); 184 return gfx::Size(100, 16);
185 } 185 }
186 186
187 std::string ProgressBar::GetClassName() const { 187 std::string ProgressBar::GetClassName() const {
188 return kViewClassName; 188 return kViewClassName;
189 } 189 }
190 190
191 void ProgressBar::OnPaint(gfx::Canvas* canvas) { 191 void ProgressBar::OnPaint(gfx::CanvasSkia* canvas) {
192 const double capped_value = std::min( 192 const double capped_value = std::min(
193 std::max(current_value_, min_display_value_), max_display_value_); 193 std::max(current_value_, min_display_value_), max_display_value_);
194 const double capped_fraction = 194 const double capped_fraction =
195 (capped_value - min_display_value_) / 195 (capped_value - min_display_value_) /
196 (max_display_value_ - min_display_value_); 196 (max_display_value_ - min_display_value_);
197 const int progress_width = static_cast<int>(width() * capped_fraction + 0.5); 197 const int progress_width = static_cast<int>(width() * capped_fraction + 0.5);
198 198
199 #if defined(OS_CHROMEOS) 199 #if defined(OS_CHROMEOS)
200 const SkColor background_colors[] = { 200 const SkColor background_colors[] = {
201 SkColorSetRGB(0xBB, 0xBB, 0xBB), 201 SkColorSetRGB(0xBB, 0xBB, 0xBB),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (progress_width > 1) { 295 if (progress_width > 1) {
296 FillRoundRect(canvas, 0, 0, progress_width, height(), kCornerRadius, 296 FillRoundRect(canvas, 0, 0, progress_width, height(), kCornerRadius,
297 kBarColorStart, kBarColorEnd, false); 297 kBarColorStart, kBarColorEnd, false);
298 } 298 }
299 StrokeRoundRect(canvas, 0, 0, width(), height(), kCornerRadius, 299 StrokeRoundRect(canvas, 0, 0, width(), height(), kCornerRadius,
300 kBorderColor, kBorderWidth); 300 kBorderColor, kBorderWidth);
301 #endif 301 #endif
302 } 302 }
303 303
304 } // namespace views 304 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698