From 220705c2b06962462e471b28ad85c76c0f9c3080 Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" Date: Tue, 5 May 2009 04:52:11 +0000 Subject: 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 --- app/throb_animation.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 app/throb_animation.h (limited to 'app/throb_animation.h') diff --git a/app/throb_animation.h b/app/throb_animation.h new file mode 100644 index 0000000..637e8e0 --- /dev/null +++ b/app/throb_animation.h @@ -0,0 +1,59 @@ +// 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. + +#ifndef APP_THROB_ANIMATION_H_ +#define APP_THROB_ANIMATION_H_ + +#include "app/slide_animation.h" + +// 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. + 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(); + + // Overriden to continually throb (assuming we're throbbing). + virtual void Step(); + + // Overridden to maintain the slide duration. + virtual void SetSlideDuration(int duration) { slide_duration_ = duration; } + + 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); +}; + +#endif // APP_THROB_ANIMATION_H_ -- cgit v1.1