OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/throbber.h" | 5 #include "views/controls/throbber.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 Throbber::~Throbber() { | 27 Throbber::~Throbber() { |
28 Stop(); | 28 Stop(); |
29 } | 29 } |
30 | 30 |
31 void Throbber::Start() { | 31 void Throbber::Start() { |
32 if (running_) | 32 if (running_) |
33 return; | 33 return; |
34 | 34 |
35 start_time_ = Time::Now(); | 35 start_time_ = Time::Now(); |
36 | 36 |
37 timer_.Start(FROM_HERE, frame_time_ - TimeDelta::FromMilliseconds(10), | 37 timer_.Start(frame_time_ - TimeDelta::FromMilliseconds(10), |
38 this, &Throbber::Run); | 38 this, &Throbber::Run); |
39 | 39 |
40 running_ = true; | 40 running_ = true; |
41 | 41 |
42 SchedulePaint(); // paint right away | 42 SchedulePaint(); // paint right away |
43 } | 43 } |
44 | 44 |
45 void Throbber::Stop() { | 45 void Throbber::Stop() { |
46 if (!running_) | 46 if (!running_) |
47 return; | 47 return; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 start_delay_ms_(kStartDelay), | 103 start_delay_ms_(kStartDelay), |
104 stop_delay_ms_(kStopDelay) { | 104 stop_delay_ms_(kStopDelay) { |
105 } | 105 } |
106 | 106 |
107 SmoothedThrobber::~SmoothedThrobber() {} | 107 SmoothedThrobber::~SmoothedThrobber() {} |
108 | 108 |
109 void SmoothedThrobber::Start() { | 109 void SmoothedThrobber::Start() { |
110 stop_timer_.Stop(); | 110 stop_timer_.Stop(); |
111 | 111 |
112 if (!running_ && !start_timer_.IsRunning()) { | 112 if (!running_ && !start_timer_.IsRunning()) { |
113 start_timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(start_delay_ms_), | 113 start_timer_.Start(TimeDelta::FromMilliseconds(start_delay_ms_), this, |
114 this, &SmoothedThrobber::StartDelayOver); | 114 &SmoothedThrobber::StartDelayOver); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 void SmoothedThrobber::StartDelayOver() { | 118 void SmoothedThrobber::StartDelayOver() { |
119 Throbber::Start(); | 119 Throbber::Start(); |
120 } | 120 } |
121 | 121 |
122 void SmoothedThrobber::Stop() { | 122 void SmoothedThrobber::Stop() { |
123 if (!running_) | 123 if (!running_) |
124 start_timer_.Stop(); | 124 start_timer_.Stop(); |
125 | 125 |
126 stop_timer_.Stop(); | 126 stop_timer_.Stop(); |
127 stop_timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(stop_delay_ms_), | 127 stop_timer_.Start(TimeDelta::FromMilliseconds(stop_delay_ms_), this, |
128 this, &SmoothedThrobber::StopDelayOver); | 128 &SmoothedThrobber::StopDelayOver); |
129 } | 129 } |
130 | 130 |
131 void SmoothedThrobber::StopDelayOver() { | 131 void SmoothedThrobber::StopDelayOver() { |
132 Throbber::Stop(); | 132 Throbber::Stop(); |
133 } | 133 } |
134 | 134 |
135 // Checkmark throbber --------------------------------------------------------- | 135 // Checkmark throbber --------------------------------------------------------- |
136 | 136 |
137 CheckmarkThrobber::CheckmarkThrobber() | 137 CheckmarkThrobber::CheckmarkThrobber() |
138 : Throbber(kFrameTimeMs, false), | 138 : Throbber(kFrameTimeMs, false), |
(...skipping 30 matching lines...) Expand all Loading... |
169 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 169 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
170 checkmark_ = rb.GetBitmapNamed(IDR_INPUT_GOOD); | 170 checkmark_ = rb.GetBitmapNamed(IDR_INPUT_GOOD); |
171 initialized = true; | 171 initialized = true; |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 // static | 175 // static |
176 SkBitmap* CheckmarkThrobber::checkmark_ = NULL; | 176 SkBitmap* CheckmarkThrobber::checkmark_ = NULL; |
177 | 177 |
178 } // namespace views | 178 } // namespace views |
OLD | NEW |