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/geometry/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(bool on_resize
);
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 resize_delay_before_starting
,
44 base::TimeDelta duration
);
46 virtual void RunAnimationFrame(float progress
) = 0;
48 void StartAnimation();
52 // Returns how far through the animation we are as a progress value from
54 float AnimationProgressAtTime(base::TimeTicks now
);
56 void PostDelayedFade(bool on_resize
);
58 ScrollbarAnimationControllerClient
* client_
;
59 base::TimeTicks last_awaken_time_
;
60 base::TimeDelta delay_before_starting_
;
61 base::TimeDelta resize_delay_before_starting_
;
62 base::TimeDelta duration_
;
65 bool currently_scrolling_
;
66 bool scroll_gesture_has_scrolled_
;
67 base::CancelableClosure delayed_scrollbar_fade_
;
69 base::WeakPtrFactory
<ScrollbarAnimationController
> weak_factory_
;
74 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_