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 // These methods are public for testing. |
| 92 bool MouseIsOverScrollbarThumb(ScrollbarOrientation orientation) const; |
| 93 bool MouseIsNearScrollbarThumb(ScrollbarOrientation orientation) const; |
92 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; | 94 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; |
93 bool MouseIsNearAnyScrollbar() const; | 95 bool MouseIsNearAnyScrollbar() const; |
94 | 96 |
95 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f; | 97 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f; |
96 | 98 |
97 private: | 99 private: |
98 // Describes whether the current animation should FadeIn or FadeOut. | 100 // Describes whether the current animation should FadeIn or FadeOut. |
99 enum AnimationChange { NONE, FADE_IN, FADE_OUT }; | 101 enum AnimationChange { NONE, FADE_IN, FADE_OUT }; |
100 | 102 |
101 ScrollbarAnimationController(ElementId scroll_element_id, | 103 ScrollbarAnimationController(ElementId scroll_element_id, |
(...skipping 20 matching lines...) Expand all Loading... |
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 vertical_controller_; |
163 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 163 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
164 horizontal_controller_; | 164 horizontal_controller_; |
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 |