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 25 matching lines...) Expand all Loading... |
36 // independent between vertical/horizontal and are managed by the | 36 // independent between vertical/horizontal and are managed by the |
37 // SingleScrollbarAnimationControllerThinnings. | 37 // SingleScrollbarAnimationControllerThinnings. |
38 class CC_EXPORT ScrollbarAnimationController { | 38 class CC_EXPORT ScrollbarAnimationController { |
39 public: | 39 public: |
40 // ScrollbarAnimationController for Android. It only has fade in/out | 40 // ScrollbarAnimationController for Android. It only has fade in/out |
41 // animation. | 41 // animation. |
42 static std::unique_ptr<ScrollbarAnimationController> | 42 static std::unique_ptr<ScrollbarAnimationController> |
43 CreateScrollbarAnimationControllerAndroid( | 43 CreateScrollbarAnimationControllerAndroid( |
44 int scroll_layer_id, | 44 int scroll_layer_id, |
45 ScrollbarAnimationControllerClient* client, | 45 ScrollbarAnimationControllerClient* client, |
46 base::TimeDelta delay_before_starting, | 46 base::TimeDelta fade_out_delay, |
47 base::TimeDelta resize_delay_before_starting, | 47 base::TimeDelta fade_out_resize_delay, |
48 base::TimeDelta fade_duration); | 48 base::TimeDelta fade_out_duration); |
49 | 49 |
50 // ScrollbarAnimationController for Desktop Overlay Scrollbar. It has fade in/ | 50 // ScrollbarAnimationController for Desktop Overlay Scrollbar. It has fade in/ |
51 // out animation and thinning animation. | 51 // out animation and thinning animation. |
52 static std::unique_ptr<ScrollbarAnimationController> | 52 static std::unique_ptr<ScrollbarAnimationController> |
53 CreateScrollbarAnimationControllerAuraOverlay( | 53 CreateScrollbarAnimationControllerAuraOverlay( |
54 int scroll_layer_id, | 54 int scroll_layer_id, |
55 ScrollbarAnimationControllerClient* client, | 55 ScrollbarAnimationControllerClient* client, |
56 base::TimeDelta delay_before_starting, | 56 base::TimeDelta fade_in_delay, |
57 base::TimeDelta resize_delay_before_starting, | 57 base::TimeDelta fade_out_delay, |
58 base::TimeDelta fade_duration, | 58 base::TimeDelta fade_out_resize_delay, |
| 59 base::TimeDelta fade_out_duration, |
59 base::TimeDelta thinning_duration); | 60 base::TimeDelta thinning_duration); |
60 | 61 |
61 ~ScrollbarAnimationController(); | 62 ~ScrollbarAnimationController(); |
62 | 63 |
63 bool ScrollbarsHidden() const; | 64 bool ScrollbarsHidden() const; |
64 | 65 |
65 bool Animate(base::TimeTicks now); | 66 bool Animate(base::TimeTicks now); |
66 | 67 |
67 void DidScrollBegin(); | 68 void DidScrollBegin(); |
68 void DidScrollUpdate(bool on_resize); | 69 void DidScrollUpdate(bool on_resize); |
69 void DidScrollEnd(); | 70 void DidScrollEnd(); |
70 | 71 |
71 void DidMouseDown(); | 72 void DidMouseDown(); |
72 void DidMouseUp(); | 73 void DidMouseUp(); |
73 void DidMouseLeave(); | 74 void DidMouseLeave(); |
74 void DidMouseMoveNear(ScrollbarOrientation, float); | 75 void DidMouseMoveNear(ScrollbarOrientation, float); |
75 | 76 |
76 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const; | 77 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const; |
77 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const; | 78 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const; |
78 bool mouse_is_near_any_scrollbar() const; | 79 bool mouse_is_near_any_scrollbar() const; |
79 | 80 |
80 private: | 81 private: |
81 ScrollbarAnimationController(int scroll_layer_id, | 82 ScrollbarAnimationController(int scroll_layer_id, |
82 ScrollbarAnimationControllerClient* client, | 83 ScrollbarAnimationControllerClient* client, |
83 base::TimeDelta delay_before_starting, | 84 base::TimeDelta fade_out_delay, |
84 base::TimeDelta resize_delay_before_starting, | 85 base::TimeDelta fade_out_resize_delay, |
85 base::TimeDelta fade_duration); | 86 base::TimeDelta fade_out_duration); |
86 | 87 |
87 ScrollbarAnimationController(int scroll_layer_id, | 88 ScrollbarAnimationController(int scroll_layer_id, |
88 ScrollbarAnimationControllerClient* client, | 89 ScrollbarAnimationControllerClient* client, |
89 base::TimeDelta delay_before_starting, | 90 base::TimeDelta fade_in_delay, |
90 base::TimeDelta resize_delay_before_starting, | 91 base::TimeDelta fade_out_delay, |
91 base::TimeDelta fade_duration, | 92 base::TimeDelta fade_out_resize_delay, |
| 93 base::TimeDelta fade_out_duration, |
92 base::TimeDelta thinning_duration); | 94 base::TimeDelta thinning_duration); |
93 | 95 |
94 ScrollbarSet Scrollbars() const; | 96 ScrollbarSet Scrollbars() const; |
95 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( | 97 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( |
96 ScrollbarOrientation) const; | 98 ScrollbarOrientation) const; |
97 | 99 |
98 // Returns how far through the animation we are as a progress value from | 100 // Returns how far through the animation we are as a progress value from |
99 // 0 to 1. | 101 // 0 to 1. |
100 float AnimationProgressAtTime(base::TimeTicks now); | 102 float AnimationProgressAtTime(base::TimeTicks now); |
101 void RunAnimationFrame(float progress); | 103 void RunAnimationFrame(float progress); |
102 | 104 |
103 void StartAnimation(); | 105 void StartAnimation(); |
104 void StopAnimation(); | 106 void StopAnimation(); |
105 | 107 |
106 ScrollbarAnimationControllerClient* client_; | 108 void FadeIn(); |
107 | 109 |
108 void PostDelayedAnimationTask(bool on_resize); | 110 void PostDelayedFadeIn(); |
| 111 void PostDelayedFadeOut(bool on_resize); |
109 | 112 |
110 bool Captured() const; | 113 bool Captured() const; |
111 | 114 |
| 115 bool CalcNeedTriggerScrollbarFadeIn(ScrollbarOrientation orientation, |
| 116 float distance) const; |
| 117 |
112 void ApplyOpacityToScrollbars(float opacity); | 118 void ApplyOpacityToScrollbars(float opacity); |
113 | 119 |
| 120 ScrollbarAnimationControllerClient* client_; |
| 121 |
114 base::TimeTicks last_awaken_time_; | 122 base::TimeTicks last_awaken_time_; |
115 base::TimeDelta delay_before_starting_; | 123 |
116 base::TimeDelta resize_delay_before_starting_; | 124 // fade_in_delay_ is only for the case where the mouse hovers near the screen |
| 125 // edge. |
| 126 base::TimeDelta fade_in_delay_; |
| 127 base::TimeDelta fade_out_delay_; |
| 128 base::TimeDelta fade_out_resize_delay_; |
| 129 |
| 130 bool need_trigger_scrollbar_fade_in_; |
117 | 131 |
118 bool is_animating_; | 132 bool is_animating_; |
119 | 133 |
120 const int scroll_layer_id_; | 134 const int scroll_layer_id_; |
121 bool currently_scrolling_; | 135 bool currently_scrolling_; |
122 bool scroll_gesture_has_scrolled_; | 136 bool scroll_gesture_has_scrolled_; |
123 | 137 |
124 base::CancelableClosure delayed_scrollbar_fade_; | 138 base::CancelableClosure delayed_scrollbar_fade_in_; |
| 139 base::CancelableClosure delayed_scrollbar_fade_out_; |
| 140 |
125 float opacity_; | 141 float opacity_; |
126 base::TimeDelta fade_duration_; | 142 base::TimeDelta fade_out_duration_; |
127 | 143 |
128 const bool need_thinning_animation_; | 144 const bool need_thinning_animation_; |
129 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 145 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
130 vertical_controller_; | 146 vertical_controller_; |
131 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 147 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
132 horizontal_controller_; | 148 horizontal_controller_; |
133 | 149 |
134 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; | 150 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; |
135 }; | 151 }; |
136 | 152 |
137 } // namespace cc | 153 } // namespace cc |
138 | 154 |
139 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ | 155 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ |
OLD | NEW |