Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: cc/input/scrollbar_animation_controller.h

Issue 2816923002: change overlay scrollbar hover show to hover fade in (Closed)
Patch Set: merge kOverlayScrollbarFadeInDelay and kOverlayScrollbarFadeOutDelay to kOverlayScrollbarFadeDelay Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 class CC_EXPORT ScrollbarAnimationController { 38 class CC_EXPORT ScrollbarAnimationController {
39 public: 39 public:
40 // ScrollbarAnimationController for Android. It only has show & fade out 40 // ScrollbarAnimationController for Android. It only has show & fade 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 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_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,
Evan Stade 2017/04/20 14:33:45 I had envisioned you combining these as well, but
chaopeng 2017/04/20 14:50:38 Now we have fade_in_delay, fade_out_delay and fade
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_out_duration, 59 base::TimeDelta fade_duration,
60 base::TimeDelta thinning_duration); 60 base::TimeDelta thinning_duration);
61 61
62 ~ScrollbarAnimationController(); 62 ~ScrollbarAnimationController();
63 63
64 bool ScrollbarsHidden() const; 64 bool ScrollbarsHidden() const;
65 65
66 bool Animate(base::TimeTicks now); 66 bool Animate(base::TimeTicks now);
67 67
68 // WillUpdateScroll expects to be called even if the scroll position won't 68 // WillUpdateScroll expects to be called even if the scroll position won't
69 // change as a result of the scroll. Only effect Aura Overlay Scrollbar. 69 // change as a result of the scroll. Only effect Aura Overlay Scrollbar.
(...skipping 16 matching lines...) Expand all
86 void DidMouseMoveNear(ScrollbarOrientation, float); 86 void DidMouseMoveNear(ScrollbarOrientation, float);
87 87
88 // Called when Blink wants to show the scrollbars (via 88 // Called when Blink wants to show the scrollbars (via
89 // ScrollableArea::showOverlayScrollbars). 89 // ScrollableArea::showOverlayScrollbars).
90 void DidRequestShowFromMainThread(); 90 void DidRequestShowFromMainThread();
91 91
92 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const; 92 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const;
93 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; 93 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const;
94 bool MouseIsNearAnyScrollbar() const; 94 bool MouseIsNearAnyScrollbar() const;
95 95
96 static constexpr float kMouseMoveDistanceToTriggerShow = 30.0f; 96 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f;
97 97
98 private: 98 private:
99 // Describes whether the current animation should FadeIn or FadeOut.
100 enum AnimationChange { NONE, FADE_IN, FADE_OUT };
101
99 ScrollbarAnimationController(int scroll_layer_id, 102 ScrollbarAnimationController(int scroll_layer_id,
100 ScrollbarAnimationControllerClient* client, 103 ScrollbarAnimationControllerClient* client,
101 base::TimeDelta fade_out_delay, 104 base::TimeDelta fade_out_delay,
102 base::TimeDelta fade_out_resize_delay, 105 base::TimeDelta fade_out_resize_delay,
103 base::TimeDelta fade_out_duration); 106 base::TimeDelta fade_duration);
104 107
105 ScrollbarAnimationController(int scroll_layer_id, 108 ScrollbarAnimationController(int scroll_layer_id,
106 ScrollbarAnimationControllerClient* client, 109 ScrollbarAnimationControllerClient* client,
107 base::TimeDelta show_delay, 110 base::TimeDelta fade_in_delay,
108 base::TimeDelta fade_out_delay, 111 base::TimeDelta fade_out_delay,
109 base::TimeDelta fade_out_resize_delay, 112 base::TimeDelta fade_out_resize_delay,
110 base::TimeDelta fade_out_duration, 113 base::TimeDelta fade_duration,
111 base::TimeDelta thinning_duration); 114 base::TimeDelta thinning_duration);
112 115
113 ScrollbarSet Scrollbars() const; 116 ScrollbarSet Scrollbars() const;
114 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( 117 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
115 ScrollbarOrientation) const; 118 ScrollbarOrientation) const;
116 119
117 // 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
118 // 0 to 1. 121 // 0 to 1.
119 float AnimationProgressAtTime(base::TimeTicks now); 122 float AnimationProgressAtTime(base::TimeTicks now);
120 void RunAnimationFrame(float progress); 123 void RunAnimationFrame(float progress);
121 124
122 void StartAnimation(); 125 void StartAnimation();
123 void StopAnimation(); 126 void StopAnimation();
124 127
125 void Show(); 128 void Show();
126 129
127 void PostDelayedShow(); 130 void PostDelayedAnimation(AnimationChange animation_change, bool on_resize);
128 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
137 ScrollbarAnimationControllerClient* client_; 139 ScrollbarAnimationControllerClient* client_;
138 140
139 base::TimeTicks last_awaken_time_; 141 base::TimeTicks last_awaken_time_;
140 142
141 // show_delay_ is only for the case where the mouse hovers near the screen 143 // fade_in_delay_ is only for the case where the mouse hovers near the screen
142 // edge. 144 // edge.
143 base::TimeDelta show_delay_; 145 base::TimeDelta fade_in_delay_;
144 base::TimeDelta fade_out_delay_; 146 base::TimeDelta fade_out_delay_;
145 base::TimeDelta fade_out_resize_delay_; 147 base::TimeDelta fade_out_resize_delay_;
146 148
149 base::TimeDelta fade_duration_;
150
147 bool need_trigger_scrollbar_show_; 151 bool need_trigger_scrollbar_show_;
148 152
149 bool is_animating_; 153 bool is_animating_;
154 AnimationChange animation_change_;
150 155
151 const int scroll_layer_id_; 156 const int scroll_layer_id_;
152 bool currently_scrolling_; 157 bool currently_scrolling_;
153 bool show_in_fast_scroll_; 158 bool show_in_fast_scroll_;
154 159
155 base::CancelableClosure delayed_scrollbar_show_; 160 base::CancelableClosure delayed_scrollbar_animation_;
156 base::CancelableClosure delayed_scrollbar_fade_out_;
157 161
158 float opacity_; 162 float opacity_;
159 base::TimeDelta fade_out_duration_;
160 163
161 const bool show_scrollbars_on_scroll_gesture_; 164 const bool show_scrollbars_on_scroll_gesture_;
162 const bool need_thinning_animation_; 165 const bool need_thinning_animation_;
163 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 166 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
164 vertical_controller_; 167 vertical_controller_;
165 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 168 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
166 horizontal_controller_; 169 horizontal_controller_;
167 170
168 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 171 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
169 }; 172 };
170 173
171 } // namespace cc 174 } // namespace cc
172 175
173 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 176 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/input/scrollbar_animation_controller.cc » ('j') | ui/native_theme/overlay_scrollbar_constants_aura.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698