summaryrefslogtreecommitdiffstats
path: root/ui/base/animation/throb_animation.h
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 17:33:39 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 17:33:39 +0000
commitf676780687464428e340d008a0d1ca13d9944628 (patch)
tree489e8bd8188e31a7f6c53f15e8d1d9c6ba36d023 /ui/base/animation/throb_animation.h
parent3b65bfd55c56cf8a6db025087d937494f49dc15f (diff)
downloadchromium_src-f676780687464428e340d008a0d1ca13d9944628.zip
chromium_src-f676780687464428e340d008a0d1ca13d9944628.tar.gz
chromium_src-f676780687464428e340d008a0d1ca13d9944628.tar.bz2
Move animation code to new ui/base/animation directory.
BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/6154001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/animation/throb_animation.h')
-rw-r--r--ui/base/animation/throb_animation.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/ui/base/animation/throb_animation.h b/ui/base/animation/throb_animation.h
new file mode 100644
index 0000000..21dc03b
--- /dev/null
+++ b/ui/base/animation/throb_animation.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2011 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.
+
+#ifndef UI_BASE_ANIMATION_THROB_ANIMATION_H_
+#define UI_BASE_ANIMATION_THROB_ANIMATION_H_
+#pragma once
+
+#include "ui/base/animation/slide_animation.h"
+
+namespace ui {
+
+// A subclass of SlideAnimation that can continually slide. All of the Animation
+// methods behave like that of SlideAnimation: transition to the next state.
+// The StartThrobbing method causes the ThrobAnimation to cycle between hidden
+// and shown for a set number of cycles.
+//
+// A ThrobAnimation has two durations: the duration used when behavior like
+// a SlideAnimation, and the duration used when throbbing.
+class ThrobAnimation : public SlideAnimation {
+ public:
+ explicit ThrobAnimation(AnimationDelegate* target);
+ virtual ~ThrobAnimation() {}
+
+ // Starts throbbing. cycles_til_stop gives the number of cycles to do before
+ // stopping. A negative value means "throb indefinitely".
+ void StartThrobbing(int cycles_til_stop);
+
+ // Sets the duration of the slide animation when throbbing.
+ void SetThrobDuration(int duration) { throb_duration_ = duration; }
+
+ // Overridden to reset to the slide duration.
+ virtual void Reset();
+ virtual void Show();
+ virtual void Hide();
+
+ // Overridden to maintain the slide duration.
+ virtual void SetSlideDuration(int duration);
+
+ // The number of cycles remaining until the animation stops.
+ void set_cycles_remaining(int value) { cycles_remaining_ = value; }
+ int cycles_remaining() const { return cycles_remaining_; }
+
+ protected:
+ // Overriden to continually throb (assuming we're throbbing).
+ virtual void Step(base::TimeTicks time_now);
+
+ private:
+ // Resets state such that we behave like SlideAnimation.
+ void ResetForSlide();
+
+ // Duration of the slide animation.
+ int slide_duration_;
+
+ // Duration of the slide animation when throbbing.
+ int throb_duration_;
+
+ // If throbbing, this is the number of cycles left.
+ int cycles_remaining_;
+
+ // Are we throbbing?
+ bool throbbing_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThrobAnimation);
+};
+
+} // namespace ui
+
+#endif // UI_BASE_ANIMATION_THROB_ANIMATION_H_