summaryrefslogtreecommitdiffstats
path: root/chromium/cc/animation/scrollbar_animation_controller.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/animation/scrollbar_animation_controller.h')
-rw-r--r--chromium/cc/animation/scrollbar_animation_controller.h56
1 files changed, 46 insertions, 10 deletions
diff --git a/chromium/cc/animation/scrollbar_animation_controller.h b/chromium/cc/animation/scrollbar_animation_controller.h
index ecef4fb2d97..ad7f631bb9e 100644
--- a/chromium/cc/animation/scrollbar_animation_controller.h
+++ b/chromium/cc/animation/scrollbar_animation_controller.h
@@ -5,30 +5,66 @@
#ifndef CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
#define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
+#include "base/cancelable_callback.h"
+#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "cc/base/cc_export.h"
#include "ui/gfx/vector2d_f.h"
namespace cc {
+class CC_EXPORT ScrollbarAnimationControllerClient {
+ public:
+ virtual ~ScrollbarAnimationControllerClient() {}
+
+ virtual void PostDelayedScrollbarFade(const base::Closure& start_fade,
+ base::TimeDelta delay) = 0;
+ virtual void SetNeedsScrollbarAnimationFrame() = 0;
+};
+
// This abstract class represents the compositor-side analogy of
// ScrollbarAnimator. Individual platforms should subclass it to provide
// specialized implementation.
class CC_EXPORT ScrollbarAnimationController {
public:
- virtual ~ScrollbarAnimationController() {}
+ virtual ~ScrollbarAnimationController();
+
+ void Animate(base::TimeTicks now);
+
+ virtual void DidScrollBegin();
+ virtual void DidScrollUpdate();
+ virtual void DidScrollEnd();
+ virtual void DidMouseMoveOffScrollbar() {}
+ virtual void DidMouseMoveNear(float distance) {}
+
+ protected:
+ ScrollbarAnimationController(ScrollbarAnimationControllerClient* client,
+ base::TimeDelta delay_before_starting,
+ base::TimeDelta duration);
+
+ virtual void RunAnimationFrame(float progress) = 0;
+
+ void StartAnimation();
+ void StopAnimation();
+
+ private:
+ // Returns how far through the animation we are as a progress value from
+ // 0 to 1.
+ float AnimationProgressAtTime(base::TimeTicks now);
+
+ void PostDelayedFade();
- virtual bool IsAnimating() const = 0;
- virtual base::TimeDelta DelayBeforeStart(base::TimeTicks now) const = 0;
+ ScrollbarAnimationControllerClient* client_;
+ base::TimeTicks last_awaken_time_;
+ base::TimeDelta delay_before_starting_;
+ base::TimeDelta duration_;
+ bool is_animating_;
- virtual bool Animate(base::TimeTicks now) = 0;
- virtual void DidScrollGestureBegin() = 0;
- virtual void DidScrollGestureEnd(base::TimeTicks now) = 0;
- virtual void DidMouseMoveOffScrollbar(base::TimeTicks now) = 0;
+ bool currently_scrolling_;
+ bool scroll_gesture_has_scrolled_;
+ base::CancelableClosure delayed_scrollbar_fade_;
- // Returns true if we should start an animation.
- virtual bool DidScrollUpdate(base::TimeTicks now) = 0;
- virtual bool DidMouseMoveNear(base::TimeTicks now, float distance) = 0;
+ base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
};
} // namespace cc