Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 base::TimeDelta fade_out_delay, | 46 base::TimeDelta fade_out_delay, |
| 47 base::TimeDelta fade_out_resize_delay, | 47 base::TimeDelta fade_out_resize_delay, |
| 48 base::TimeDelta fade_out_duration); | 48 base::TimeDelta fade_out_duration); |
| 49 | 49 |
| 50 // ScrollbarAnimationController for Desktop Overlay Scrollbar. It has show & | 50 // ScrollbarAnimationController for Desktop Overlay Scrollbar. It has show & |
| 51 // fade out animation and thinning animation. | 51 // fade 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 show_delay, | 56 base::TimeDelta fade_in_delay, |
| 57 base::TimeDelta fade_out_delay, | 57 base::TimeDelta fade_out_delay, |
| 58 base::TimeDelta fade_out_resize_delay, | 58 base::TimeDelta fade_out_resize_delay, |
| 59 base::TimeDelta fade_in_duration, | |
| 59 base::TimeDelta fade_out_duration, | 60 base::TimeDelta fade_out_duration, |
| 60 base::TimeDelta thinning_duration); | 61 base::TimeDelta thinning_duration); |
| 61 | 62 |
| 62 ~ScrollbarAnimationController(); | 63 ~ScrollbarAnimationController(); |
| 63 | 64 |
| 64 bool ScrollbarsHidden() const; | 65 bool ScrollbarsHidden() const; |
| 65 | 66 |
| 66 bool Animate(base::TimeTicks now); | 67 bool Animate(base::TimeTicks now); |
| 67 | 68 |
| 68 // WillUpdateScroll expects to be called even if the scroll position won't | 69 // WillUpdateScroll expects to be called even if the scroll position won't |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 86 void DidMouseMoveNear(ScrollbarOrientation, float); | 87 void DidMouseMoveNear(ScrollbarOrientation, float); |
| 87 | 88 |
| 88 // Called when Blink wants to show the scrollbars (via | 89 // Called when Blink wants to show the scrollbars (via |
| 89 // ScrollableArea::showOverlayScrollbars). | 90 // ScrollableArea::showOverlayScrollbars). |
| 90 void DidRequestShowFromMainThread(); | 91 void DidRequestShowFromMainThread(); |
| 91 | 92 |
| 92 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const; | 93 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const; |
| 93 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; | 94 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; |
| 94 bool MouseIsNearAnyScrollbar() const; | 95 bool MouseIsNearAnyScrollbar() const; |
| 95 | 96 |
| 96 static constexpr float kMouseMoveDistanceToTriggerShow = 30.0f; | 97 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f; |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 ScrollbarAnimationController(int scroll_layer_id, | 100 ScrollbarAnimationController(int scroll_layer_id, |
| 100 ScrollbarAnimationControllerClient* client, | 101 ScrollbarAnimationControllerClient* client, |
| 101 base::TimeDelta fade_out_delay, | 102 base::TimeDelta fade_out_delay, |
| 102 base::TimeDelta fade_out_resize_delay, | 103 base::TimeDelta fade_out_resize_delay, |
| 103 base::TimeDelta fade_out_duration); | 104 base::TimeDelta fade_out_duration); |
| 104 | 105 |
| 105 ScrollbarAnimationController(int scroll_layer_id, | 106 ScrollbarAnimationController(int scroll_layer_id, |
| 106 ScrollbarAnimationControllerClient* client, | 107 ScrollbarAnimationControllerClient* client, |
| 107 base::TimeDelta show_delay, | 108 base::TimeDelta fade_in_delay, |
| 108 base::TimeDelta fade_out_delay, | 109 base::TimeDelta fade_out_delay, |
| 109 base::TimeDelta fade_out_resize_delay, | 110 base::TimeDelta fade_out_resize_delay, |
| 111 base::TimeDelta fade_in_duration, | |
| 110 base::TimeDelta fade_out_duration, | 112 base::TimeDelta fade_out_duration, |
| 111 base::TimeDelta thinning_duration); | 113 base::TimeDelta thinning_duration); |
| 112 | 114 |
| 113 ScrollbarSet Scrollbars() const; | 115 ScrollbarSet Scrollbars() const; |
| 114 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( | 116 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( |
| 115 ScrollbarOrientation) const; | 117 ScrollbarOrientation) const; |
| 116 | 118 |
| 117 // Returns how far through the animation we are as a progress value from | 119 // Returns how far through the animation we are as a progress value from |
| 118 // 0 to 1. | 120 // 0 to 1. |
| 119 float AnimationProgressAtTime(base::TimeTicks now); | 121 float AnimationProgressAtTime(base::TimeTicks now); |
| 120 void RunAnimationFrame(float progress); | 122 void RunAnimationFrame(float progress); |
| 121 | 123 |
| 122 void StartAnimation(); | 124 void StartAnimation(); |
| 123 void StopAnimation(); | 125 void StopAnimation(); |
| 124 | 126 |
| 125 void Show(); | 127 void Show(); |
| 126 | 128 |
| 127 void PostDelayedShow(); | 129 void PostDelayedFadeIn(); |
| 128 void PostDelayedFadeOut(bool on_resize); | 130 void PostDelayedFadeOut(bool on_resize); |
| 129 | 131 |
| 130 bool Captured() const; | 132 bool Captured() const; |
| 131 | 133 |
| 132 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation, | 134 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation, |
| 133 float distance) const; | 135 float distance) const; |
| 134 | 136 |
| 135 void ApplyOpacityToScrollbars(float opacity); | 137 void ApplyOpacityToScrollbars(float opacity); |
| 136 | 138 |
| 139 // Describes whether the current animation should FadeIn or FadeOut. | |
| 140 enum AnimationChange { NONE, FADE_IN, FADE_OUT }; | |
| 141 | |
| 137 ScrollbarAnimationControllerClient* client_; | 142 ScrollbarAnimationControllerClient* client_; |
| 138 | 143 |
| 139 base::TimeTicks last_awaken_time_; | 144 base::TimeTicks last_awaken_time_; |
| 140 | 145 |
| 141 // show_delay_ is only for the case where the mouse hovers near the screen | 146 // show_delay_ is only for the case where the mouse hovers near the screen |
|
bokan
2017/04/13 15:31:40
nit: update comment.
| |
| 142 // edge. | 147 // edge. |
| 143 base::TimeDelta show_delay_; | 148 base::TimeDelta fade_in_delay_; |
| 144 base::TimeDelta fade_out_delay_; | 149 base::TimeDelta fade_out_delay_; |
| 145 base::TimeDelta fade_out_resize_delay_; | 150 base::TimeDelta fade_out_resize_delay_; |
| 146 | 151 |
| 152 base::TimeDelta fade_in_duration_; | |
| 153 base::TimeDelta fade_out_duration_; | |
| 154 | |
| 147 bool need_trigger_scrollbar_show_; | 155 bool need_trigger_scrollbar_show_; |
| 148 | 156 |
| 149 bool is_animating_; | 157 bool is_animating_; |
| 158 AnimationChange animation_change_; | |
| 150 | 159 |
| 151 const int scroll_layer_id_; | 160 const int scroll_layer_id_; |
| 152 bool currently_scrolling_; | 161 bool currently_scrolling_; |
| 153 bool show_in_fast_scroll_; | 162 bool show_in_fast_scroll_; |
| 154 | 163 |
| 155 base::CancelableClosure delayed_scrollbar_show_; | 164 base::CancelableClosure delayed_scrollbar_fade_in_; |
| 156 base::CancelableClosure delayed_scrollbar_fade_out_; | 165 base::CancelableClosure delayed_scrollbar_fade_out_; |
| 157 | 166 |
| 158 float opacity_; | 167 float opacity_; |
| 159 base::TimeDelta fade_out_duration_; | |
| 160 | 168 |
| 161 const bool show_scrollbars_on_scroll_gesture_; | 169 const bool show_scrollbars_on_scroll_gesture_; |
| 162 const bool need_thinning_animation_; | 170 const bool need_thinning_animation_; |
| 163 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 171 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
| 164 vertical_controller_; | 172 vertical_controller_; |
| 165 std::unique_ptr<SingleScrollbarAnimationControllerThinning> | 173 std::unique_ptr<SingleScrollbarAnimationControllerThinning> |
| 166 horizontal_controller_; | 174 horizontal_controller_; |
| 167 | 175 |
| 168 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; | 176 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; |
| 169 }; | 177 }; |
| 170 | 178 |
| 171 } // namespace cc | 179 } // namespace cc |
| 172 | 180 |
| 173 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ | 181 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ |
| OLD | NEW |