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

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 fade-in and fade-out to same code method 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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:
100 // Describes whether the current animation should FadeIn or FadeOut.
101 enum AnimationChange { NONE, FADE_IN, FADE_OUT };
102
99 ScrollbarAnimationController(int scroll_layer_id, 103 ScrollbarAnimationController(int scroll_layer_id,
100 ScrollbarAnimationControllerClient* client, 104 ScrollbarAnimationControllerClient* client,
101 base::TimeDelta fade_out_delay, 105 base::TimeDelta fade_out_delay,
102 base::TimeDelta fade_out_resize_delay, 106 base::TimeDelta fade_out_resize_delay,
103 base::TimeDelta fade_out_duration); 107 base::TimeDelta fade_out_duration);
104 108
105 ScrollbarAnimationController(int scroll_layer_id, 109 ScrollbarAnimationController(int scroll_layer_id,
106 ScrollbarAnimationControllerClient* client, 110 ScrollbarAnimationControllerClient* client,
107 base::TimeDelta show_delay, 111 base::TimeDelta fade_in_delay,
108 base::TimeDelta fade_out_delay, 112 base::TimeDelta fade_out_delay,
109 base::TimeDelta fade_out_resize_delay, 113 base::TimeDelta fade_out_resize_delay,
114 base::TimeDelta fade_in_duration,
110 base::TimeDelta fade_out_duration, 115 base::TimeDelta fade_out_duration,
111 base::TimeDelta thinning_duration); 116 base::TimeDelta thinning_duration);
112 117
113 ScrollbarSet Scrollbars() const; 118 ScrollbarSet Scrollbars() const;
114 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( 119 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
115 ScrollbarOrientation) const; 120 ScrollbarOrientation) const;
116 121
117 // Returns how far through the animation we are as a progress value from 122 // Returns how far through the animation we are as a progress value from
118 // 0 to 1. 123 // 0 to 1.
119 float AnimationProgressAtTime(base::TimeTicks now); 124 float AnimationProgressAtTime(base::TimeTicks now);
120 void RunAnimationFrame(float progress); 125 void RunAnimationFrame(float progress);
121 126
122 void StartAnimation(); 127 void StartAnimation();
123 void StopAnimation(); 128 void StopAnimation();
124 129
125 void Show(); 130 void Show();
126 131
127 void PostDelayedShow(); 132 void PostDelayedAnimation(AnimationChange animation_change, bool on_resize);
128 void PostDelayedFadeOut(bool on_resize);
129 133
130 bool Captured() const; 134 bool Captured() const;
131 135
132 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation, 136 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation,
133 float distance) const; 137 float distance) const;
134 138
135 void ApplyOpacityToScrollbars(float opacity); 139 void ApplyOpacityToScrollbars(float opacity);
136 140
137 ScrollbarAnimationControllerClient* client_; 141 ScrollbarAnimationControllerClient* client_;
138 142
139 base::TimeTicks last_awaken_time_; 143 base::TimeTicks last_awaken_time_;
140 144
141 // show_delay_ is only for the case where the mouse hovers near the screen 145 // fade_in_delay_ is only for the case where the mouse hovers near the screen
142 // edge. 146 // edge.
143 base::TimeDelta show_delay_; 147 base::TimeDelta fade_in_delay_;
144 base::TimeDelta fade_out_delay_; 148 base::TimeDelta fade_out_delay_;
145 base::TimeDelta fade_out_resize_delay_; 149 base::TimeDelta fade_out_resize_delay_;
146 150
151 base::TimeDelta fade_in_duration_;
152 base::TimeDelta fade_out_duration_;
153
147 bool need_trigger_scrollbar_show_; 154 bool need_trigger_scrollbar_show_;
148 155
149 bool is_animating_; 156 bool is_animating_;
157 AnimationChange animation_change_;
150 158
151 const int scroll_layer_id_; 159 const int scroll_layer_id_;
152 bool currently_scrolling_; 160 bool currently_scrolling_;
153 bool show_in_fast_scroll_; 161 bool show_in_fast_scroll_;
154 162
155 base::CancelableClosure delayed_scrollbar_show_; 163 base::CancelableClosure delayed_scrollbar_animation_;
156 base::CancelableClosure delayed_scrollbar_fade_out_;
157 164
158 float opacity_; 165 float opacity_;
159 base::TimeDelta fade_out_duration_;
160 166
161 const bool show_scrollbars_on_scroll_gesture_; 167 const bool show_scrollbars_on_scroll_gesture_;
162 const bool need_thinning_animation_; 168 const bool need_thinning_animation_;
163 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 169 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
164 vertical_controller_; 170 vertical_controller_;
165 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 171 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
166 horizontal_controller_; 172 horizontal_controller_;
167 173
168 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 174 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
169 }; 175 };
170 176
171 } // namespace cc 177 } // namespace cc
172 178
173 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 179 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/input/scrollbar_animation_controller.cc » ('j') | cc/input/scrollbar_animation_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698