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

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

Issue 2816923002: change overlay scrollbar hover show to hover fade in (Closed)
Patch Set: combine fade_in_delay and fade_out_delay to fade_delay 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
« no previous file with comments | « no previous file | cc/input/scrollbar_animation_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 25 matching lines...) Expand all
36 // independent between vertical/horizontal and are managed by the 36 // independent between vertical/horizontal and are managed by the
37 // SingleScrollbarAnimationControllerThinnings. 37 // SingleScrollbarAnimationControllerThinnings.
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 ElementId scroll_element_id, 44 ElementId scroll_element_id,
45 ScrollbarAnimationControllerClient* client, 45 ScrollbarAnimationControllerClient* client,
46 base::TimeDelta fade_out_delay, 46 base::TimeDelta fade_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 ElementId scroll_element_id, 54 ElementId scroll_element_id,
55 ScrollbarAnimationControllerClient* client, 55 ScrollbarAnimationControllerClient* client,
56 base::TimeDelta show_delay, 56 base::TimeDelta fade_delay,
57 base::TimeDelta fade_out_delay,
58 base::TimeDelta fade_out_resize_delay, 57 base::TimeDelta fade_out_resize_delay,
59 base::TimeDelta fade_out_duration, 58 base::TimeDelta fade_duration,
60 base::TimeDelta thinning_duration); 59 base::TimeDelta thinning_duration);
61 60
62 ~ScrollbarAnimationController(); 61 ~ScrollbarAnimationController();
63 62
64 bool ScrollbarsHidden() const; 63 bool ScrollbarsHidden() const;
65 64
66 bool Animate(base::TimeTicks now); 65 bool Animate(base::TimeTicks now);
67 66
68 // WillUpdateScroll expects to be called even if the scroll position won't 67 // 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. 68 // change as a result of the scroll. Only effect Aura Overlay Scrollbar.
(...skipping 16 matching lines...) Expand all
86 void DidMouseMoveNear(ScrollbarOrientation, float); 85 void DidMouseMoveNear(ScrollbarOrientation, float);
87 86
88 // Called when Blink wants to show the scrollbars (via 87 // Called when Blink wants to show the scrollbars (via
89 // ScrollableArea::showOverlayScrollbars). 88 // ScrollableArea::showOverlayScrollbars).
90 void DidRequestShowFromMainThread(); 89 void DidRequestShowFromMainThread();
91 90
92 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const; 91 bool MouseIsOverScrollbar(ScrollbarOrientation orientation) const;
93 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const; 92 bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const;
94 bool MouseIsNearAnyScrollbar() const; 93 bool MouseIsNearAnyScrollbar() const;
95 94
96 static constexpr float kMouseMoveDistanceToTriggerShow = 30.0f; 95 static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f;
97 96
98 private: 97 private:
99 ScrollbarAnimationController(ElementId scroll_element_id, 98 // Describes whether the current animation should FadeIn or FadeOut.
100 ScrollbarAnimationControllerClient* client, 99 enum AnimationChange { NONE, FADE_IN, FADE_OUT };
101 base::TimeDelta fade_out_delay,
102 base::TimeDelta fade_out_resize_delay,
103 base::TimeDelta fade_out_duration);
104 100
105 ScrollbarAnimationController(ElementId scroll_element_id, 101 ScrollbarAnimationController(ElementId scroll_element_id,
106 ScrollbarAnimationControllerClient* client, 102 ScrollbarAnimationControllerClient* client,
107 base::TimeDelta show_delay, 103 base::TimeDelta fade_delay,
108 base::TimeDelta fade_out_delay,
109 base::TimeDelta fade_out_resize_delay, 104 base::TimeDelta fade_out_resize_delay,
110 base::TimeDelta fade_out_duration, 105 base::TimeDelta fade_duration);
106
107 ScrollbarAnimationController(ElementId scroll_element_id,
108 ScrollbarAnimationControllerClient* client,
109 base::TimeDelta fade_delay,
110 base::TimeDelta fade_out_resize_delay,
111 base::TimeDelta fade_duration,
111 base::TimeDelta thinning_duration); 112 base::TimeDelta thinning_duration);
112 113
113 ScrollbarSet Scrollbars() const; 114 ScrollbarSet Scrollbars() const;
114 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( 115 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
115 ScrollbarOrientation) const; 116 ScrollbarOrientation) const;
116 117
117 // Returns how far through the animation we are as a progress value from 118 // Returns how far through the animation we are as a progress value from
118 // 0 to 1. 119 // 0 to 1.
119 float AnimationProgressAtTime(base::TimeTicks now); 120 float AnimationProgressAtTime(base::TimeTicks now);
120 void RunAnimationFrame(float progress); 121 void RunAnimationFrame(float progress);
121 122
122 void StartAnimation(); 123 void StartAnimation();
123 void StopAnimation(); 124 void StopAnimation();
124 125
125 void Show(); 126 void Show();
126 127
127 void PostDelayedShow(); 128 void PostDelayedAnimation(AnimationChange animation_change, bool on_resize);
128 void PostDelayedFadeOut(bool on_resize);
129 129
130 bool Captured() const; 130 bool Captured() const;
131 131
132 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation, 132 bool CalcNeedTriggerScrollbarShow(ScrollbarOrientation orientation,
133 float distance) const; 133 float distance) const;
134 134
135 void ApplyOpacityToScrollbars(float opacity); 135 void ApplyOpacityToScrollbars(float opacity);
136 136
137 ScrollbarAnimationControllerClient* client_; 137 ScrollbarAnimationControllerClient* client_;
138 138
139 base::TimeTicks last_awaken_time_; 139 base::TimeTicks last_awaken_time_;
140 140
141 // show_delay_ is only for the case where the mouse hovers near the screen 141 base::TimeDelta fade_delay_;
142 // edge.
143 base::TimeDelta show_delay_;
144 base::TimeDelta fade_out_delay_;
145 base::TimeDelta fade_out_resize_delay_; 142 base::TimeDelta fade_out_resize_delay_;
146 143
144 base::TimeDelta fade_duration_;
145
147 bool need_trigger_scrollbar_show_; 146 bool need_trigger_scrollbar_show_;
148 147
149 bool is_animating_; 148 bool is_animating_;
149 AnimationChange animation_change_;
150 150
151 const ElementId scroll_element_id_; 151 const ElementId scroll_element_id_;
152 bool currently_scrolling_; 152 bool currently_scrolling_;
153 bool show_in_fast_scroll_; 153 bool show_in_fast_scroll_;
154 154
155 base::CancelableClosure delayed_scrollbar_show_; 155 base::CancelableClosure delayed_scrollbar_animation_;
156 base::CancelableClosure delayed_scrollbar_fade_out_;
157 156
158 float opacity_; 157 float opacity_;
159 base::TimeDelta fade_out_duration_;
160 158
161 const bool show_scrollbars_on_scroll_gesture_; 159 const bool show_scrollbars_on_scroll_gesture_;
162 const bool need_thinning_animation_; 160 const bool need_thinning_animation_;
163 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 161 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
164 vertical_controller_; 162 vertical_controller_;
165 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 163 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
166 horizontal_controller_; 164 horizontal_controller_;
167 165
168 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 166 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
169 }; 167 };
170 168
171 } // namespace cc 169 } // namespace cc
172 170
173 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 171 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/input/scrollbar_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698