1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
6 #define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
8 #include "base/cancelable_callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h"
11 #include "cc/base/cc_export.h"
12 #include "ui/gfx/vector2d_f.h"
16 class CC_EXPORT ScrollbarAnimationControllerClient {
18 virtual ~ScrollbarAnimationControllerClient() {}
20 virtual void PostDelayedScrollbarFade(const base::Closure& start_fade,
21 base::TimeDelta delay) = 0;
22 virtual void SetNeedsScrollbarAnimationFrame() = 0;
25 // This abstract class represents the compositor-side analogy of
26 // ScrollbarAnimator. Individual platforms should subclass it to provide
27 // specialized implementation.
28 class CC_EXPORT ScrollbarAnimationController {
30 virtual ~ScrollbarAnimationController();
32 void Animate(base::TimeTicks now);
34 virtual void DidScrollBegin();
35 virtual void DidScrollUpdate();
36 virtual void DidScrollEnd();
37 virtual void DidMouseMoveOffScrollbar() {}
38 virtual void DidMouseMoveNear(float distance) {}
41 ScrollbarAnimationController(ScrollbarAnimationControllerClient* client,
42 base::TimeDelta delay_before_starting,
43 base::TimeDelta duration);
45 virtual void RunAnimationFrame(float progress) = 0;
47 void StartAnimation();
51 // Returns how far through the animation we are as a progress value from
53 float AnimationProgressAtTime(base::TimeTicks now);
55 void PostDelayedFade();
57 ScrollbarAnimationControllerClient* client_;
58 base::TimeTicks last_awaken_time_;
59 base::TimeDelta delay_before_starting_;
60 base::TimeDelta duration_;
63 bool currently_scrolling_;
64 bool scroll_gesture_has_scrolled_;
65 base::CancelableClosure delayed_scrollbar_fade_;
67 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
72 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_