OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/animation/tween.h" | 10 #include "ui/gfx/animation/tween.h" |
11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
12 #include "ui/gfx/image/image.h" | 12 #include "ui/gfx/image/image.h" |
13 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
14 #include "ui/gfx/paint_throbber.h" | 14 #include "ui/gfx/paint_throbber.h" |
15 #include "ui/gfx/paint_vector_icon.h" | 15 #include "ui/gfx/paint_vector_icon.h" |
16 #include "ui/gfx/vector_icons_public.h" | |
17 #include "ui/native_theme/common_theme.h" | 16 #include "ui/native_theme/common_theme.h" |
18 #include "ui/native_theme/native_theme.h" | 17 #include "ui/native_theme/native_theme.h" |
19 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
| 19 #include "ui/vector_icons/vector_icons.h" |
20 #include "ui/views/resources/grit/views_resources.h" | 20 #include "ui/views/resources/grit/views_resources.h" |
21 | 21 |
22 namespace views { | 22 namespace views { |
23 | 23 |
24 // The default diameter of a Throbber. If you change this, also change | 24 // The default diameter of a Throbber. If you change this, also change |
25 // kCheckmarkDipSize. | 25 // kCheckmarkDipSize. |
26 static const int kDefaultDiameter = 16; | 26 static const int kDefaultDiameter = 16; |
27 // The size of the checkmark, in DIP. This magic number matches the default | 27 // The size of the checkmark, in DIP. This magic number matches the default |
28 // diamater plus padding inherent in the checkmark SVG. | 28 // diamater plus padding inherent in the checkmark SVG. |
29 static const int kCheckmarkDipSize = 18; | 29 static const int kCheckmarkDipSize = 18; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 void Throbber::OnPaint(gfx::Canvas* canvas) { | 69 void Throbber::OnPaint(gfx::Canvas* canvas) { |
70 SkColor color = GetNativeTheme()->GetSystemColor( | 70 SkColor color = GetNativeTheme()->GetSystemColor( |
71 ui::NativeTheme::kColorId_ThrobberSpinningColor); | 71 ui::NativeTheme::kColorId_ThrobberSpinningColor); |
72 | 72 |
73 if (!IsRunning()) { | 73 if (!IsRunning()) { |
74 if (checked_) { | 74 if (checked_) { |
75 canvas->Translate(gfx::Vector2d((width() - kCheckmarkDipSize) / 2, | 75 canvas->Translate(gfx::Vector2d((width() - kCheckmarkDipSize) / 2, |
76 (height() - kCheckmarkDipSize) / 2)); | 76 (height() - kCheckmarkDipSize) / 2)); |
77 gfx::PaintVectorIcon(canvas, gfx::VectorIconId::CHECK_CIRCLE, | 77 gfx::PaintVectorIcon(canvas, ui::kCheckCircleIcon, kCheckmarkDipSize, |
78 kCheckmarkDipSize, color); | 78 color); |
79 } | 79 } |
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time_; | 83 base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time_; |
84 gfx::PaintThrobberSpinning(canvas, GetContentsBounds(), color, elapsed_time); | 84 gfx::PaintThrobberSpinning(canvas, GetContentsBounds(), color, elapsed_time); |
85 } | 85 } |
86 | 86 |
87 bool Throbber::IsRunning() const { | 87 bool Throbber::IsRunning() const { |
88 return timer_.IsRunning(); | 88 return timer_.IsRunning(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 stop_timer_.Start(FROM_HERE, | 124 stop_timer_.Start(FROM_HERE, |
125 base::TimeDelta::FromMilliseconds(stop_delay_ms_), this, | 125 base::TimeDelta::FromMilliseconds(stop_delay_ms_), this, |
126 &SmoothedThrobber::StopDelayOver); | 126 &SmoothedThrobber::StopDelayOver); |
127 } | 127 } |
128 | 128 |
129 void SmoothedThrobber::StopDelayOver() { | 129 void SmoothedThrobber::StopDelayOver() { |
130 Throbber::Stop(); | 130 Throbber::Stop(); |
131 } | 131 } |
132 | 132 |
133 } // namespace views | 133 } // namespace views |
OLD | NEW |