Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: app/animation_container.h

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/animation.cc ('k') | app/animation_container.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/animation_container.h
diff --git a/app/animation_container.h b/app/animation_container.h
index fcb3fadd3b6eb72f9c5c07e34f14831d8c573676..98abf289606598df0090c1f6d3493bd2ca93d221 100644
--- a/app/animation_container.h
+++ b/app/animation_container.h
@@ -11,8 +11,6 @@
#include "base/time.h"
#include "base/timer.h"
-class Animation;
-
// 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
@@ -36,31 +34,53 @@ class AnimationContainer : public base::RefCounted<AnimationContainer> {
virtual void AnimationContainerEmpty(AnimationContainer* container) = 0;
};
+ // 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);
+
+ // 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 set_observer(Observer* observer) { observer_ = observer; }
// The time the last animation ran at.
base::TimeTicks last_tick_time() const { return last_tick_time_; }
// Are there any timers running?
- bool is_running() const { return !animations_.empty(); }
+ bool is_running() const { return !elements_.empty(); }
private:
- friend class Animation;
friend class base::RefCounted<AnimationContainer>;
- typedef std::set<Animation*> Animations;
+ typedef std::set<Element*> Elements;
~AnimationContainer();
- // Invoked by Animation when it needs to start. Starts the timer if necessary.
- void Start(Animation* animation);
-
- // Invoked by Animation when it needs to stop. If there are no more animations
- // running the timer stops.
- void Stop(Animation* animation);
-
// Timer callback method.
void Run();
@@ -76,8 +96,8 @@ class AnimationContainer : public base::RefCounted<AnimationContainer> {
// . The time the last animation ran at (::Run was invoked).
base::TimeTicks last_tick_time_;
- // Set of animations being managed.
- Animations animations_;
+ // Set of elements (animations) being managed.
+ Elements elements_;
// Minimum interval the timers run at.
base::TimeDelta min_timer_interval_;
« no previous file with comments | « app/animation.cc ('k') | app/animation_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698