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

Unified Diff: ui/gfx/compositor/layer_animator.h

Issue 8395046: Allows observers to be notified when layer animations complete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge with master Created 9 years, 2 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
Index: ui/gfx/compositor/layer_animator.h
diff --git a/ui/gfx/compositor/layer_animator.h b/ui/gfx/compositor/layer_animator.h
index e6751ffc12c69c1e3e27221cdd31ed887418db58..7aaa2db54f0e24388ce4c798f13d24980d6187d6 100644
--- a/ui/gfx/compositor/layer_animator.h
+++ b/ui/gfx/compositor/layer_animator.h
@@ -11,6 +11,7 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
#include "base/time.h"
#include "ui/base/animation/animation_container_element.h"
#include "ui/gfx/compositor/compositor_export.h"
@@ -24,7 +25,8 @@ namespace ui {
class Animation;
class Layer;
class LayerAnimationSequence;
-class LayerAnimatorDelegate;
+class LayerAnimationDelegate;
+class LayerAnimationObserver;
class Transform;
// When a property of layer needs to be changed it is set by way of
@@ -62,7 +64,7 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement {
// Sets the layer animation delegate the animator is associated with. The
// animator does not own the delegate.
- void SetDelegate(LayerAnimatorDelegate* delegate);
+ void SetDelegate(LayerAnimationDelegate* delegate);
// Sets the animation preemption strategy. This determines the behaviour if
// a property is set during an animation. The default is
@@ -85,14 +87,6 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement {
// animation sequences.
void ScheduleTogether(const std::vector<LayerAnimationSequence*>& animations);
- // These are cover functions that create sequences for you to wrap the given
- // elements. These sequences are then passed to the corresponding function
- // above.
- void StartAnimationElement(LayerAnimationElement* element);
- void ScheduleAnimationElement(LayerAnimationElement* element);
- void ScheduleElementsTogether(
- const std::vector<LayerAnimationElement*>& element);
-
// Returns true if there is an animation in the queue (animations remain in
// the queue until they complete).
bool is_animating() const { return !animation_queue_.empty(); }
@@ -112,6 +106,11 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement {
}
base::TimeTicks get_last_step_time_for_test() { return last_step_time_; }
+ // These functions are used for adding or removing observers from the observer
+ // list. The observers are notified when animations end.
+ void AddObserver(LayerAnimationObserver* observer);
+ void RemoveObserver(LayerAnimationObserver* observer);
+
// Scoped settings allow you to temporarily change the animator's settings and
// these changes are reverted when the object is destroyed. NOTE: when the
// settings object is created, it applies the default transition duration
@@ -121,20 +120,22 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement {
explicit ScopedSettings(LayerAnimator* animator);
virtual ~ScopedSettings();
+ void AddObserver(LayerAnimationObserver* observer);
void SetTransitionDuration(base::TimeDelta duration);
private:
LayerAnimator* animator_;
base::TimeDelta old_transition_duration_;
+ std::vector<LayerAnimationObserver*> observers_;
DISALLOW_COPY_AND_ASSIGN(ScopedSettings);
};
protected:
- LayerAnimatorDelegate* delegate() { return delegate_; }
+ LayerAnimationDelegate* delegate() { return delegate_; }
private:
- friend class TransientSettings;
+ friend class ScopedSettings;
// We need to keep track of the start time of every running animation.
struct RunningAnimation {
@@ -211,11 +212,17 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement {
// allowed to finish.
void GetTargetValue(LayerAnimationElement::TargetValue* target) const;
+ // Notifies the observers that the sequence has ended.
+ void NotifyAnimationEnded(LayerAnimationSequence* sequence);
+
+ // Associates observers_ with sequence
+ void AddObserversToSequence(LayerAnimationSequence* sequence);
+
// This is the queue of animations to run.
AnimationQueue animation_queue_;
// The target of all layer animations.
- LayerAnimatorDelegate* delegate_;
+ LayerAnimationDelegate* delegate_;
// The currently running animations.
RunningAnimations running_animations_;
@@ -236,6 +243,9 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement {
// and allows for manual stepping.
bool disable_timer_for_test_;
+ // These parties are notified when layer animations end.
sky 2011/10/27 19:29:19 parties -> observers
+ ObserverList<LayerAnimationObserver> observers_;
+
DISALLOW_COPY_AND_ASSIGN(LayerAnimator);
};

Powered by Google App Engine
This is Rietveld 408576698