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

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

Issue 1228923002: Revert vector icon CLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge_aide_oobe_completion
Patch Set: Created 5 years, 5 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/throbber.h ('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/throbber.h" 5 #include "ui/views/controls/throbber.h"
6 6
7 #include "ui/base/resource/resource_bundle.h" 7 #include "ui/base/resource/resource_bundle.h"
8 #include "ui/gfx/animation/tween.h" 8 #include "ui/gfx/animation/tween.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/image/image.h" 10 #include "ui/gfx/image/image.h"
11 #include "ui/gfx/image/image_skia.h" 11 #include "ui/gfx/image/image_skia.h"
12 #include "ui/gfx/paint_throbber.h" 12 #include "ui/gfx/paint_throbber.h"
13 #include "ui/gfx/paint_vector_icon.h"
14 #include "ui/gfx/vector_icons_public.h"
15 #include "ui/native_theme/common_theme.h" 13 #include "ui/native_theme/common_theme.h"
16 #include "ui/native_theme/native_theme.h" 14 #include "ui/native_theme/native_theme.h"
17 #include "ui/resources/grit/ui_resources.h" 15 #include "ui/resources/grit/ui_resources.h"
18 #include "ui/views/resources/grit/views_resources.h" 16 #include "ui/views/resources/grit/views_resources.h"
19 17
20 namespace views { 18 namespace views {
21 19
22 // The default diameter of a Throbber. If you change this, also change 20 Throbber::Throbber() : checked_(false), checkmark_(nullptr) {
23 // kCheckmarkDipSize.
24 static const int kDefaultDiameter = 16;
25 // The size of the checkmark, in DIP. This magic number matches the default
26 // diamater plus padding inherent in the checkmark SVG.
27 static const int kCheckmarkDipSize = 18;
28
29 Throbber::Throbber() : checked_(false) {
30 } 21 }
31 22
32 Throbber::~Throbber() { 23 Throbber::~Throbber() {
33 Stop(); 24 Stop();
34 } 25 }
35 26
36 void Throbber::Start() { 27 void Throbber::Start() {
37 if (IsRunning()) 28 if (IsRunning())
38 return; 29 return;
39 30
(...skipping 14 matching lines...) Expand all
54 45
55 void Throbber::SetChecked(bool checked) { 46 void Throbber::SetChecked(bool checked) {
56 if (checked == checked_) 47 if (checked == checked_)
57 return; 48 return;
58 49
59 checked_ = checked; 50 checked_ = checked;
60 SchedulePaint(); 51 SchedulePaint();
61 } 52 }
62 53
63 gfx::Size Throbber::GetPreferredSize() const { 54 gfx::Size Throbber::GetPreferredSize() const {
55 const int kDefaultDiameter = 16;
64 return gfx::Size(kDefaultDiameter, kDefaultDiameter); 56 return gfx::Size(kDefaultDiameter, kDefaultDiameter);
65 } 57 }
66 58
67 void Throbber::OnPaint(gfx::Canvas* canvas) { 59 void Throbber::OnPaint(gfx::Canvas* canvas) {
68 SkColor color = GetNativeTheme()->GetSystemColor(
69 ui::NativeTheme::kColorId_ThrobberSpinningColor);
70
71 if (!IsRunning()) { 60 if (!IsRunning()) {
72 if (checked_) { 61 if (checked_) {
73 canvas->Translate(gfx::Vector2d((width() - kCheckmarkDipSize) / 2, 62 if (!checkmark_) {
74 (height() - kCheckmarkDipSize) / 2)); 63 checkmark_ = ui::ResourceBundle::GetSharedInstance()
75 gfx::PaintVectorIcon(canvas, gfx::VectorIconId::CHECK_CIRCLE, 64 .GetImageNamed(IDR_CHECKMARK)
76 kCheckmarkDipSize, color); 65 .ToImageSkia();
66 }
67
68 int checkmark_x = (width() - checkmark_->width()) / 2;
69 int checkmark_y = (height() - checkmark_->height()) / 2;
70 canvas->DrawImageInt(*checkmark_, checkmark_x, checkmark_y);
77 } 71 }
78 return; 72 return;
79 } 73 }
80 74
75 SkColor color = GetNativeTheme()->GetSystemColor(
76 ui::NativeTheme::kColorId_ThrobberSpinningColor);
81 base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time_; 77 base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time_;
82 gfx::PaintThrobberSpinning(canvas, GetContentsBounds(), color, elapsed_time); 78 gfx::PaintThrobberSpinning(canvas, GetContentsBounds(), color, elapsed_time);
83 } 79 }
84 80
85 bool Throbber::IsRunning() const { 81 bool Throbber::IsRunning() const {
86 return timer_.IsRunning(); 82 return timer_.IsRunning();
87 } 83 }
88 84
89 // Smoothed throbber --------------------------------------------------------- 85 // Smoothed throbber ---------------------------------------------------------
90 86
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 stop_timer_.Start(FROM_HERE, 118 stop_timer_.Start(FROM_HERE,
123 base::TimeDelta::FromMilliseconds(stop_delay_ms_), this, 119 base::TimeDelta::FromMilliseconds(stop_delay_ms_), this,
124 &SmoothedThrobber::StopDelayOver); 120 &SmoothedThrobber::StopDelayOver);
125 } 121 }
126 122
127 void SmoothedThrobber::StopDelayOver() { 123 void SmoothedThrobber::StopDelayOver() {
128 Throbber::Stop(); 124 Throbber::Stop();
129 } 125 }
130 126
131 } // namespace views 127 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/throbber.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698