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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // DidScrollUpdate expects to be called only if the scroll position change. | 69 // DidScrollUpdate expects to be called only if the scroll position change. |
70 // Effect both Android and Aura Overlay Scrollbar. | 70 // Effect both Android and Aura Overlay Scrollbar. |
71 void DidScrollUpdate(); | 71 void DidScrollUpdate(); |
72 | 72 |
73 void DidScrollBegin(); | 73 void DidScrollBegin(); |
74 void DidScrollEnd(); | 74 void DidScrollEnd(); |
75 | 75 |
76 void DidMouseDown(); | 76 void DidMouseDown(); |
77 void DidMouseUp(); | 77 void DidMouseUp(); |
78 void DidMouseLeave(); | 78 void DidMouseLeave(); |
79 void DidMouseMoveNear(ScrollbarOrientation, float); | 79 void DidMouseMove(const gfx::PointF& device_viewport_point); |
80 | 80 |
81 // Called when Blink wants to show the scrollbars (via | 81 // Called when Blink wants to show the scrollbars (via |
82 // ScrollableArea::showOverlayScrollbars). | 82 // ScrollableArea::showOverlayScrollbars). |
83 void DidRequestShowFromMainThread(); | 83 void DidRequestShowFromMainThread(); |
84 | 84 |
85 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const; | 85 // These methods are public for testing. |
| 86 bool MouseIsOverScrollbarThumb(ScrollbarOrientation orientation) const; |
| 87 bool MouseIsNearScrollbarThumb(ScrollbarOrientation orientation) const; |
86 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; | 88 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; |
87 bool MouseIsNearAnyScrollbar() const; | 89 bool MouseIsNearAnyScrollbar() const; |
88 | 90 |
89 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f; | 91 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f; |
90 | 92 |
91 private: | 93 private: |
92 // Describes whether the current animation should FadeIn or FadeOut. | 94 // Describes whether the current animation should FadeIn or FadeOut. |
93 enum AnimationChange { NONE, FADE_IN, FADE_OUT }; | 95 enum AnimationChange { NONE, FADE_IN, FADE_OUT }; |
94 | 96 |
95 ScrollbarAnimationController(ElementId scroll_element_id, | 97 ScrollbarAnimationController(ElementId scroll_element_id, |
(...skipping 18 matching lines...) Expand all Loading... |
114 | 116 |
115 void StartAnimation(); | 117 void StartAnimation(); |
116 void StopAnimation(); | 118 void StopAnimation(); |
117 | 119 |
118 void Show(); | 120 void Show(); |
119 | 121 |
120 void PostDelayedAnimation(AnimationChange animation_change); | 122 void PostDelayedAnimation(AnimationChange animation_change); |
121 | 123 |
122 bool Captured() const; | 124 bool Captured() const; |
123 | 125 |
124 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation, | |
125 float distance) const; | |
126 | |
127 void ApplyOpacityToScrollbars(float opacity); | 126 void ApplyOpacityToScrollbars(float opacity); |
128 | 127 |
129 ScrollbarAnimationControllerClient* client_; | 128 ScrollbarAnimationControllerClient* client_; |
130 | 129 |
131 base::TimeTicks last_awaken_time_; | 130 base::TimeTicks last_awaken_time_; |
132 | 131 |
133 base::TimeDelta fade_delay_; | 132 base::TimeDelta fade_delay_; |
134 | 133 |
135 base::TimeDelta fade_duration_; | 134 base::TimeDelta fade_duration_; |
136 | 135 |
137 bool need_trigger_scrollbar_show_; | 136 bool need_trigger_scrollbar_fade_in_; |
138 | 137 |
139 bool is_animating_; | 138 bool is_animating_; |
140 AnimationChange animation_change_; | 139 AnimationChange animation_change_; |
141 | 140 |
142 const ElementId scroll_element_id_; | 141 const ElementId scroll_element_id_; |
143 bool currently_scrolling_; | 142 bool currently_scrolling_; |
144 bool show_in_fast_scroll_; | 143 bool show_in_fast_scroll_; |
145 | 144 |
146 base::CancelableClosure delayed_scrollbar_animation_; | 145 base::CancelableClosure delayed_scrollbar_animation_; |
147 | 146 |
148 float opacity_; | 147 float opacity_; |
149 | 148 |
150 const bool show_scrollbars_on_scroll_gesture_; | 149 const bool show_scrollbars_on_scroll_gesture_; |
151 const bool need_thinning_animation_; | 150 const bool need_thinning_animation_; |
| 151 |
152 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 152 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
153 vertical_controller_; | 153 vertical_controller_; |
154 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 154 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
155 horizontal_controller_; | 155 horizontal_controller_; |
156 | 156 |
157 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; | 157 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; |
158 }; | 158 }; |
159 | 159 |
160 } // namespace cc | 160 } // namespace cc |
161 | 161 |
162 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ | 162 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ |
OLD | NEW |