| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ | 5 #ifndef CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ |
| 6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ | 6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 virtual ~ScrollbarAnimationControllerClient() {} | 30 virtual ~ScrollbarAnimationControllerClient() {} |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 // This abstract class represents the compositor-side analogy of | 33 // This abstract class represents the compositor-side analogy of |
| 34 // ScrollbarAnimator. Individual platforms should subclass it to provide | 34 // ScrollbarAnimator. Individual platforms should subclass it to provide |
| 35 // specialized implementation. | 35 // specialized implementation. |
| 36 class CC_EXPORT ScrollbarAnimationController { | 36 class CC_EXPORT ScrollbarAnimationController { |
| 37 public: | 37 public: |
| 38 virtual ~ScrollbarAnimationController(); | 38 virtual ~ScrollbarAnimationController(); |
| 39 | 39 |
| 40 bool Animate(base::TimeTicks now); | 40 virtual bool Animate(base::TimeTicks now); |
| 41 | 41 |
| 42 virtual void DidScrollBegin(); | 42 virtual void DidScrollBegin(); |
| 43 virtual void DidScrollUpdate(bool on_resize); | 43 virtual void DidScrollUpdate(bool on_resize); |
| 44 virtual void DidScrollEnd(); | 44 virtual void DidScrollEnd(); |
| 45 virtual void DidMouseDown() {} | 45 virtual void DidMouseDown() {} |
| 46 virtual void DidMouseUp() {} | 46 virtual void DidMouseUp() {} |
| 47 virtual void DidMouseLeave() {} | 47 virtual void DidMouseLeave() {} |
| 48 virtual void DidMouseMoveNear(float distance) {} | 48 virtual void DidMouseMoveNear(ScrollbarOrientation, float) {} |
| 49 virtual bool ScrollbarsHidden() const; | 49 virtual bool ScrollbarsHidden() const; |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 ScrollbarAnimationController(int scroll_layer_id, | 52 ScrollbarAnimationController(int scroll_layer_id, |
| 53 ScrollbarAnimationControllerClient* client, | 53 ScrollbarAnimationControllerClient* client, |
| 54 base::TimeDelta delay_before_starting, | 54 base::TimeDelta delay_before_starting, |
| 55 base::TimeDelta resize_delay_before_starting); | 55 base::TimeDelta resize_delay_before_starting); |
| 56 | 56 |
| 57 virtual void RunAnimationFrame(float progress) = 0; | 57 virtual void RunAnimationFrame(float progress) = 0; |
| 58 virtual const base::TimeDelta& Duration() = 0; | 58 virtual const base::TimeDelta& Duration() = 0; |
| 59 | 59 |
| 60 void StartAnimation(); | 60 void StartAnimation(); |
| 61 void StopAnimation(); | 61 void StopAnimation(); |
| 62 ScrollbarSet Scrollbars() const; | 62 ScrollbarSet Scrollbars() const; |
| 63 | 63 |
| 64 ScrollbarAnimationControllerClient* client_; | 64 ScrollbarAnimationControllerClient* client_; |
| 65 | 65 |
| 66 void PostDelayedAnimationTask(bool on_resize); | 66 void PostDelayedAnimationTask(bool on_resize); |
| 67 | 67 |
| 68 int scroll_layer_id() const { return scroll_layer_id_; } | 68 int scroll_layer_id() const { return scroll_layer_id_; } |
| 69 | 69 |
| 70 bool animating_fade() const { return is_animating_; } |
| 71 |
| 70 private: | 72 private: |
| 71 // Returns how far through the animation we are as a progress value from | 73 // Returns how far through the animation we are as a progress value from |
| 72 // 0 to 1. | 74 // 0 to 1. |
| 73 float AnimationProgressAtTime(base::TimeTicks now); | 75 float AnimationProgressAtTime(base::TimeTicks now); |
| 74 | 76 |
| 75 base::TimeTicks last_awaken_time_; | 77 base::TimeTicks last_awaken_time_; |
| 76 base::TimeDelta delay_before_starting_; | 78 base::TimeDelta delay_before_starting_; |
| 77 base::TimeDelta resize_delay_before_starting_; | 79 base::TimeDelta resize_delay_before_starting_; |
| 78 | 80 |
| 79 bool is_animating_; | 81 bool is_animating_; |
| 80 | 82 |
| 81 int scroll_layer_id_; | 83 int scroll_layer_id_; |
| 82 bool currently_scrolling_; | 84 bool currently_scrolling_; |
| 83 bool scroll_gesture_has_scrolled_; | 85 bool scroll_gesture_has_scrolled_; |
| 84 base::CancelableClosure delayed_scrollbar_fade_; | 86 base::CancelableClosure delayed_scrollbar_fade_; |
| 85 | 87 |
| 86 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; | 88 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 } // namespace cc | 91 } // namespace cc |
| 90 | 92 |
| 91 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ | 93 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ |
| OLD | NEW |