summaryrefslogtreecommitdiffstats
path: root/app/throb_animation.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 04:52:11 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 04:52:11 +0000
commit220705c2b06962462e471b28ad85c76c0f9c3080 (patch)
treecfc44266116bbf2acc3a4fae32625c4481c8243e /app/throb_animation.cc
parent1b8d02f181d089ee670f2ba72089c3722f679d5f (diff)
downloadchromium_src-220705c2b06962462e471b28ad85c76c0f9c3080.zip
chromium_src-220705c2b06962462e471b28ad85c76c0f9c3080.tar.gz
chromium_src-220705c2b06962462e471b28ad85c76c0f9c3080.tar.bz2
Move *Animation to app/
http://crbug.com/11387 Review URL: http://codereview.chromium.org/109001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15275 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/throb_animation.cc')
-rw-r--r--app/throb_animation.cc68
1 files changed, 68 insertions, 0 deletions
diff --git a/app/throb_animation.cc b/app/throb_animation.cc
new file mode 100644
index 0000000..28b5763
--- /dev/null
+++ b/app/throb_animation.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "app/throb_animation.h"
+
+static const int kDefaultThrobDurationMS = 400;
+
+ThrobAnimation::ThrobAnimation(AnimationDelegate* target)
+ : SlideAnimation(target),
+ slide_duration_(GetSlideDuration()),
+ throb_duration_(kDefaultThrobDurationMS),
+ cycles_remaining_(0),
+ throbbing_(false) {
+}
+
+void ThrobAnimation::StartThrobbing(int cycles_til_stop) {
+ cycles_remaining_ = cycles_til_stop;
+ throbbing_ = true;
+ SlideAnimation::SetSlideDuration(throb_duration_);
+ if (IsAnimating())
+ return; // We're already running, we'll cycle when current loop finishes.
+
+ if (IsShowing())
+ SlideAnimation::Hide();
+ else
+ SlideAnimation::Show();
+ cycles_remaining_ = cycles_til_stop;
+}
+
+void ThrobAnimation::Reset() {
+ ResetForSlide();
+ SlideAnimation::Reset();
+}
+
+void ThrobAnimation::Show() {
+ ResetForSlide();
+ SlideAnimation::Show();
+}
+
+void ThrobAnimation::Hide() {
+ ResetForSlide();
+ SlideAnimation::Hide();
+}
+
+void ThrobAnimation::Step() {
+ Animation::Step();
+ if (!IsAnimating() && throbbing_) {
+ // Were throbbing a finished a cycle. Start the next cycle unless we're at
+ // the end of the cycles, in which case we stop.
+ cycles_remaining_--;
+ if (IsShowing()) {
+ // We want to stop hidden, hence this doesn't check cycles_remaining_.
+ SlideAnimation::Hide();
+ } else if (cycles_remaining_ > 0) {
+ SlideAnimation::Show();
+ } else {
+ // We're done throbbing.
+ throbbing_ = false;
+ }
+ }
+}
+
+void ThrobAnimation::ResetForSlide() {
+ SlideAnimation::SetSlideDuration(slide_duration_);
+ cycles_remaining_ = 0;
+ throbbing_ = false;
+}