diff options
author | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-27 11:08:50 +0000 |
---|---|---|
committer | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-27 11:08:50 +0000 |
commit | 302cf651a0d929717107fc6a4f1d533074058cfa (patch) | |
tree | 43eee8f7825e4df1fb0c5e0942a822c34e53353d /views | |
parent | 68c549897be6b4a479eb09a325bc6019d19d7c20 (diff) | |
download | chromium_src-302cf651a0d929717107fc6a4f1d533074058cfa.zip chromium_src-302cf651a0d929717107fc6a4f1d533074058cfa.tar.gz chromium_src-302cf651a0d929717107fc6a4f1d533074058cfa.tar.bz2 |
Show spinner on network response in OOBE welcome screen, account creation screen.
Block buttons/keyboard on login window when sign in is in process.
BUG= http://crosbug.com/2573, http://crosbug.com/2528
TEST=Run through OOBE screens and observe spinner when network response is more than 0.5 seconds.
Review URL: http://codereview.chromium.org/1755006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/throbber.cc | 21 | ||||
-rw-r--r-- | views/controls/throbber.h | 14 |
2 files changed, 27 insertions, 8 deletions
diff --git a/views/controls/throbber.cc b/views/controls/throbber.cc index bc5fa04..112f43b 100644 --- a/views/controls/throbber.cc +++ b/views/controls/throbber.cc @@ -21,11 +21,7 @@ Throbber::Throbber(int frame_time_ms, paint_while_stopped_(paint_while_stopped), frames_(NULL), frame_time_(TimeDelta::FromMilliseconds(frame_time_ms)) { - ResourceBundle &rb = ResourceBundle::GetSharedInstance(); - frames_ = rb.GetBitmapNamed(IDR_THROBBER); - DCHECK(frames_->width() > 0 && frames_->height() > 0); - DCHECK(frames_->width() % frames_->height() == 0); - frame_count_ = frames_->width() / frames_->height(); + SetFrames(ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_THROBBER)); } Throbber::~Throbber() { @@ -56,6 +52,13 @@ void Throbber::Stop() { SchedulePaint(); // Important if we're not painting while stopped } +void Throbber::SetFrames(SkBitmap* frames) { + frames_ = frames; + DCHECK(frames_->width() > 0 && frames_->height() > 0); + DCHECK(frames_->width() % frames_->height() == 0); + frame_count_ = frames_->width() / frames_->height(); +} + void Throbber::Run() { DCHECK(running_); @@ -95,14 +98,16 @@ static const int kStopDelay = 50; SmoothedThrobber::SmoothedThrobber(int frame_time_ms) - : Throbber(frame_time_ms, /* paint_while_stopped= */ false) { + : Throbber(frame_time_ms, /* paint_while_stopped= */ false), + start_delay_ms_(kStartDelay), + stop_delay_ms_(kStopDelay) { } void SmoothedThrobber::Start() { stop_timer_.Stop(); if (!running_ && !start_timer_.IsRunning()) { - start_timer_.Start(TimeDelta::FromMilliseconds(kStartDelay), this, + start_timer_.Start(TimeDelta::FromMilliseconds(start_delay_ms_), this, &SmoothedThrobber::StartDelayOver); } } @@ -116,7 +121,7 @@ void SmoothedThrobber::Stop() { start_timer_.Stop(); stop_timer_.Stop(); - stop_timer_.Start(TimeDelta::FromMilliseconds(kStopDelay), this, + stop_timer_.Start(TimeDelta::FromMilliseconds(stop_delay_ms_), this, &SmoothedThrobber::StopDelayOver); } diff --git a/views/controls/throbber.h b/views/controls/throbber.h index 53d669f..e5d0490 100644 --- a/views/controls/throbber.h +++ b/views/controls/throbber.h @@ -23,12 +23,16 @@ class Throbber : public View { // If |paint_while_stopped| is false, this view will be invisible when not // running. Throbber(int frame_time_ms, bool paint_while_stopped); + Throbber(int frame_time_ms, bool paint_while_stopped, SkBitmap* frames); virtual ~Throbber(); // Start and stop the throbber animation virtual void Start(); virtual void Stop(); + // Set custom throbber frames. Otherwise IDR_THROBBER is loaded. + void SetFrames(SkBitmap* frames); + // overridden from View virtual gfx::Size GetPreferredSize(); virtual void Paint(gfx::Canvas* canvas); @@ -57,10 +61,14 @@ class Throbber : public View { class SmoothedThrobber : public Throbber { public: SmoothedThrobber(int frame_delay_ms); + SmoothedThrobber(int frame_delay_ms, SkBitmap* frames); virtual void Start(); virtual void Stop(); + void set_start_delay_ms(int value) { start_delay_ms_ = value; } + void set_stop_delay_ms(int value) { stop_delay_ms_ = value; } + private: // Called when the startup-delay timer fires // This function starts the actual throbbing. @@ -70,6 +78,12 @@ class SmoothedThrobber : public Throbber { // This function stops the actual throbbing. void StopDelayOver(); + // Delay after work starts before starting throbber, in milliseconds. + int start_delay_ms_; + + // Delay after work stops before stopping, in milliseconds. + int stop_delay_ms_; + base::OneShotTimer<SmoothedThrobber> start_timer_; base::OneShotTimer<SmoothedThrobber> stop_timer_; |