diff options
Diffstat (limited to 'app/animation_container.h')
-rw-r--r-- | app/animation_container.h | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/app/animation_container.h b/app/animation_container.h index 806b4e1..3d92699 100644 --- a/app/animation_container.h +++ b/app/animation_container.h @@ -12,6 +12,9 @@ #include "base/time.h" #include "base/timer.h" +class AnimationContainerElement; +class AnimationContainerObserver; + // AnimationContainer is used by Animation to manage the underlying timer. // Internally each Animation creates a single AnimationContainer. You can // group a set of Animations into the same AnimationContainer by way of @@ -22,55 +25,22 @@ // AnimationContainer own it. class AnimationContainer : public base::RefCounted<AnimationContainer> { public: - // The observer is notified after every update of the animations managed by - // the container. - class Observer { - public: - // Invoked on every tick of the timer managed by the container and after - // all the animations have updated. - virtual void AnimationContainerProgressed( - AnimationContainer* container) = 0; - - // Invoked when no more animations are being managed by this container. - virtual void AnimationContainerEmpty(AnimationContainer* container) = 0; - - protected: - virtual ~Observer() {} - }; - - // Interface for the elements the AnimationContainer contains. This is - // implemented by Animation. - class Element { - public: - // Sets the start of the animation. This is invoked from - // AnimationContainer::Start. - virtual void SetStartTime(base::TimeTicks start_time) = 0; - - // Invoked when the animation is to progress. - virtual void Step(base::TimeTicks time_now) = 0; - - // Returns the time interval of the animation. If an Element needs to change - // this it should first invoke Stop, then Start. - virtual base::TimeDelta GetTimerInterval() const = 0; - - protected: - virtual ~Element() {} - }; - AnimationContainer(); // Invoked by Animation when it needs to start. Starts the timer if necessary. // NOTE: This is invoked by Animation for you, you shouldn't invoke this // directly. - void Start(Element* animation); + void Start(AnimationContainerElement* animation); // Invoked by Animation when it needs to stop. If there are no more animations // running the timer stops. // NOTE: This is invoked by Animation for you, you shouldn't invoke this // directly. - void Stop(Element* animation); + void Stop(AnimationContainerElement* animation); - void set_observer(Observer* observer) { observer_ = observer; } + void set_observer(AnimationContainerObserver* observer) { + observer_ = observer; + } // The time the last animation ran at. base::TimeTicks last_tick_time() const { return last_tick_time_; } @@ -81,7 +51,7 @@ class AnimationContainer : public base::RefCounted<AnimationContainer> { private: friend class base::RefCounted<AnimationContainer>; - typedef std::set<Element*> Elements; + typedef std::set<AnimationContainerElement*> Elements; ~AnimationContainer(); @@ -108,7 +78,7 @@ class AnimationContainer : public base::RefCounted<AnimationContainer> { base::RepeatingTimer<AnimationContainer> timer_; - Observer* observer_; + AnimationContainerObserver* observer_; DISALLOW_COPY_AND_ASSIGN(AnimationContainer); }; |