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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 // DidResize expects to be called when clip layer size changed or scroll layer | 75 // DidResize expects to be called when clip layer size changed or scroll layer |
76 // size changed. | 76 // size changed. |
77 void DidResize(); | 77 void DidResize(); |
78 | 78 |
79 void DidScrollBegin(); | 79 void DidScrollBegin(); |
80 void DidScrollEnd(); | 80 void DidScrollEnd(); |
81 | 81 |
82 void DidMouseDown(); | 82 void DidMouseDown(); |
83 void DidMouseUp(); | 83 void DidMouseUp(); |
84 void DidMouseLeave(); | 84 void DidMouseLeave(); |
85 void DidMouseMoveNear(ScrollbarOrientation, float); | 85 void DidMouseMove(const gfx::PointF& device_viewport_point); |
86 | 86 |
87 // Called when Blink wants to show the scrollbars (via | 87 // Called when Blink wants to show the scrollbars (via |
88 // ScrollableArea::showOverlayScrollbars). | 88 // ScrollableArea::showOverlayScrollbars). |
89 void DidRequestShowFromMainThread(); | 89 void DidRequestShowFromMainThread(); |
90 | 90 |
91 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const; | 91 bool MouseIsOverScrollbarThumb(ScrollbarOrientation orientation) const; |
92 bool MouseIsNearScrollbarThumb(ScrollbarOrientation orientation) const; | |
92 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; | 93 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; |
93 bool MouseIsNearAnyScrollbar() const; | 94 bool MouseIsNearAnyScrollbar() const; |
94 | 95 |
95 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f; | 96 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f; |
96 | 97 |
97 private: | 98 private: |
98 // Describes whether the current animation should FadeIn or FadeOut. | 99 // Describes whether the current animation should FadeIn or FadeOut. |
99 enum AnimationChange { NONE, FADE_IN, FADE_OUT }; | 100 enum AnimationChange { NONE, FADE_IN, FADE_OUT }; |
100 | 101 |
101 ScrollbarAnimationController(ElementId scroll_element_id, | 102 ScrollbarAnimationController(ElementId scroll_element_id, |
102 ScrollbarAnimationControllerClient* client, | 103 ScrollbarAnimationControllerClient* client, |
103 base::TimeDelta fade_delay, | 104 base::TimeDelta fade_delay, |
104 base::TimeDelta fade_out_resize_delay, | 105 base::TimeDelta fade_out_resize_delay, |
105 base::TimeDelta fade_duration); | 106 base::TimeDelta fade_duration); |
106 | 107 |
107 ScrollbarAnimationController(ElementId scroll_element_id, | 108 ScrollbarAnimationController(ElementId scroll_element_id, |
108 ScrollbarAnimationControllerClient* client, | 109 ScrollbarAnimationControllerClient* client, |
109 base::TimeDelta fade_delay, | 110 base::TimeDelta fade_delay, |
110 base::TimeDelta fade_out_resize_delay, | 111 base::TimeDelta fade_out_resize_delay, |
111 base::TimeDelta fade_duration, | 112 base::TimeDelta fade_duration, |
112 base::TimeDelta thinning_duration); | 113 base::TimeDelta thinning_duration); |
113 | 114 |
114 ScrollbarSet Scrollbars() const; | 115 ScrollbarSet Scrollbars() const; |
116 ScrollbarLayerImplBase* GetScrollbar(ScrollbarOrientation orientation) const; | |
115 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( | 117 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( |
116 ScrollbarOrientation) const; | 118 ScrollbarOrientation) const; |
117 | 119 |
118 // Returns how far through the animation we are as a progress value from | 120 // Returns how far through the animation we are as a progress value from |
119 // 0 to 1. | 121 // 0 to 1. |
120 float AnimationProgressAtTime(base::TimeTicks now); | 122 float AnimationProgressAtTime(base::TimeTicks now); |
121 void RunAnimationFrame(float progress); | 123 void RunAnimationFrame(float progress); |
122 | 124 |
123 void StartAnimation(); | 125 void StartAnimation(); |
124 void StopAnimation(); | 126 void StopAnimation(); |
125 | 127 |
126 void Show(); | 128 void Show(); |
127 | 129 |
128 void PostDelayedAnimation(AnimationChange animation_change, bool on_resize); | 130 void PostDelayedAnimation(AnimationChange animation_change, bool on_resize); |
129 | 131 |
130 bool Captured() const; | 132 bool Captured() const; |
131 | 133 |
132 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation, | |
133 float distance) const; | |
134 | |
135 void ApplyOpacityToScrollbars(float opacity); | 134 void ApplyOpacityToScrollbars(float opacity); |
136 | 135 |
137 ScrollbarAnimationControllerClient* client_; | 136 ScrollbarAnimationControllerClient* client_; |
138 | 137 |
139 base::TimeTicks last_awaken_time_; | 138 base::TimeTicks last_awaken_time_; |
140 | 139 |
141 base::TimeDelta fade_delay_; | 140 base::TimeDelta fade_delay_; |
142 base::TimeDelta fade_out_resize_delay_; | 141 base::TimeDelta fade_out_resize_delay_; |
143 | 142 |
144 base::TimeDelta fade_duration_; | 143 base::TimeDelta fade_duration_; |
145 | 144 |
146 bool need_trigger_scrollbar_show_; | 145 bool need_trigger_scrollbar_fade_in_; |
147 | 146 |
148 bool is_animating_; | 147 bool is_animating_; |
149 AnimationChange animation_change_; | 148 AnimationChange animation_change_; |
150 | 149 |
151 const ElementId scroll_element_id_; | 150 const ElementId scroll_element_id_; |
152 bool currently_scrolling_; | 151 bool currently_scrolling_; |
153 bool show_in_fast_scroll_; | 152 bool show_in_fast_scroll_; |
154 | 153 |
155 base::CancelableClosure delayed_scrollbar_animation_; | 154 base::CancelableClosure delayed_scrollbar_animation_; |
156 | 155 |
157 float opacity_; | 156 float opacity_; |
158 | 157 |
159 const bool show_scrollbars_on_scroll_gesture_; | 158 const bool show_scrollbars_on_scroll_gesture_; |
160 const bool need_thinning_animation_; | 159 const bool need_thinning_animation_; |
160 | |
161 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 161 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
162 vertical_controller_; | 162 scrollbar_controllers_[2]; |
bokan
2017/04/28 14:15:17
Please keep these as vertical_controller_ and hori
| |
163 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 163 |
164 horizontal_controller_; | 164 bool mouse_is_near_scrollbar_[2]; |
bokan
2017/04/28 14:15:17
Lets move this into the thinning controller, pass
| |
165 | 165 |
166 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; | 166 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; |
167 }; | 167 }; |
168 | 168 |
169 } // namespace cc | 169 } // namespace cc |
170 | 170 |
171 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ | 171 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ |
OLD | NEW |