| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 #ifndef APP_THROB_ANIMATION_H_ | 5 #ifndef APP_THROB_ANIMATION_H_ |
| 6 #define APP_THROB_ANIMATION_H_ | 6 #define APP_THROB_ANIMATION_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/slide_animation.h" | 9 #include "ui/base/animation/throb_animation.h" |
| 10 | 10 |
| 11 // A subclass of SlideAnimation that can continually slide. All of the Animation | 11 using ui::ThrobAnimation; |
| 12 // methods behave like that of SlideAnimation: transition to the next state. | |
| 13 // The StartThrobbing method causes the ThrobAnimation to cycle between hidden | |
| 14 // and shown for a set number of cycles. | |
| 15 // | |
| 16 // A ThrobAnimation has two durations: the duration used when behavior like | |
| 17 // a SlideAnimation, and the duration used when throbbing. | |
| 18 class ThrobAnimation : public SlideAnimation { | |
| 19 public: | |
| 20 explicit ThrobAnimation(AnimationDelegate* target); | |
| 21 virtual ~ThrobAnimation() {} | |
| 22 | |
| 23 // Starts throbbing. cycles_til_stop gives the number of cycles to do before | |
| 24 // stopping. A negative value means "throb indefinitely". | |
| 25 void StartThrobbing(int cycles_til_stop); | |
| 26 | |
| 27 // Sets the duration of the slide animation when throbbing. | |
| 28 void SetThrobDuration(int duration) { throb_duration_ = duration; } | |
| 29 | |
| 30 // Overridden to reset to the slide duration. | |
| 31 virtual void Reset(); | |
| 32 virtual void Show(); | |
| 33 virtual void Hide(); | |
| 34 | |
| 35 // Overridden to maintain the slide duration. | |
| 36 virtual void SetSlideDuration(int duration); | |
| 37 | |
| 38 // The number of cycles remaining until the animation stops. | |
| 39 void set_cycles_remaining(int value) { cycles_remaining_ = value; } | |
| 40 int cycles_remaining() const { return cycles_remaining_; } | |
| 41 | |
| 42 protected: | |
| 43 // Overriden to continually throb (assuming we're throbbing). | |
| 44 virtual void Step(base::TimeTicks time_now); | |
| 45 | |
| 46 private: | |
| 47 // Resets state such that we behave like SlideAnimation. | |
| 48 void ResetForSlide(); | |
| 49 | |
| 50 // Duration of the slide animation. | |
| 51 int slide_duration_; | |
| 52 | |
| 53 // Duration of the slide animation when throbbing. | |
| 54 int throb_duration_; | |
| 55 | |
| 56 // If throbbing, this is the number of cycles left. | |
| 57 int cycles_remaining_; | |
| 58 | |
| 59 // Are we throbbing? | |
| 60 bool throbbing_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(ThrobAnimation); | |
| 63 }; | |
| 64 | 12 |
| 65 #endif // APP_THROB_ANIMATION_H_ | 13 #endif // APP_THROB_ANIMATION_H_ |
| OLD | NEW |