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

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

Issue 2611013002: Show Overlay Scrollbar when GestureScrollUpdate (Closed)
Patch Set: bokan comments addressed Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "cc/input/scrollbar_animation_controller.h" 5 #include "cc/input/scrollbar_animation_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "cc/trees/layer_tree_impl.h" 10 #include "cc/trees/layer_tree_impl.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return animated; 162 return animated;
163 } 163 }
164 164
165 float ScrollbarAnimationController::AnimationProgressAtTime( 165 float ScrollbarAnimationController::AnimationProgressAtTime(
166 base::TimeTicks now) { 166 base::TimeTicks now) {
167 base::TimeDelta delta = now - last_awaken_time_; 167 base::TimeDelta delta = now - last_awaken_time_;
168 float progress = delta.InSecondsF() / fade_out_duration_.InSecondsF(); 168 float progress = delta.InSecondsF() / fade_out_duration_.InSecondsF();
169 return std::max(std::min(progress, 1.f), 0.f); 169 return std::max(std::min(progress, 1.f), 0.f);
170 } 170 }
171 171
172 void ScrollbarAnimationController::DidScrollBegin() {
173 currently_scrolling_ = true;
174 }
175
176 void ScrollbarAnimationController::RunAnimationFrame(float progress) { 172 void ScrollbarAnimationController::RunAnimationFrame(float progress) {
177 ApplyOpacityToScrollbars(1.f - progress); 173 ApplyOpacityToScrollbars(1.f - progress);
178 client_->SetNeedsRedrawForScrollbarAnimation(); 174 client_->SetNeedsRedrawForScrollbarAnimation();
179 if (progress == 1.f) 175 if (progress == 1.f)
180 StopAnimation(); 176 StopAnimation();
181 } 177 }
182 178
183 void ScrollbarAnimationController::DidScrollUpdate(bool on_resize) { 179 void ScrollbarAnimationController::DidScrollBegin() {
180 currently_scrolling_ = true;
181 }
182
183 void ScrollbarAnimationController::DidScrollEnd() {
184 bool has_scrolled = scroll_gesture_has_scrolled_;
185 scroll_gesture_has_scrolled_ = false;
186
187 currently_scrolling_ = false;
188
189 // We don't fade out scrollbar if they need thinning animation and mouse is
190 // near.
191 if (need_thinning_animation_ && mouse_is_near_any_scrollbar())
192 return;
193
194 if (has_scrolled)
195 PostDelayedFadeOut(false);
196 }
197
198 void ScrollbarAnimationController::WillUpdateScroll() {
184 if (need_thinning_animation_ && Captured()) 199 if (need_thinning_animation_ && Captured())
185 return; 200 return;
186 201
187 StopAnimation(); 202 StopAnimation();
188 203
189 // As an optimization, we avoid spamming fade delay tasks during active fast 204 // As an optimization, we avoid spamming fade delay tasks during active fast
190 // scrolls. But if we're not within one, we need to post every scroll update. 205 // scrolls. But if we're not within one, we need to post every scroll update.
191 if (!currently_scrolling_) { 206 if (!currently_scrolling_) {
192 // We don't fade out scrollbar if they need thinning animation and mouse is 207 // We don't fade out scrollbar if they need thinning animation and mouse is
193 // near. 208 // near.
194 if (!need_thinning_animation_ || !mouse_is_near_any_scrollbar()) 209 if (!need_thinning_animation_ || !mouse_is_near_any_scrollbar())
195 PostDelayedFadeOut(on_resize); 210 PostDelayedFadeOut(false);
196 } else { 211 } else {
197 scroll_gesture_has_scrolled_ = true; 212 scroll_gesture_has_scrolled_ = true;
198 } 213 }
199 214
200 FadeIn(); 215 FadeIn();
201 216
202 if (need_thinning_animation_) { 217 if (need_thinning_animation_) {
203 vertical_controller_->UpdateThumbThicknessScale(); 218 vertical_controller_->UpdateThumbThicknessScale();
204 horizontal_controller_->UpdateThumbThicknessScale(); 219 horizontal_controller_->UpdateThumbThicknessScale();
205 } 220 }
206 } 221 }
207 222
208 void ScrollbarAnimationController::DidScrollEnd() { 223 void ScrollbarAnimationController::DidResize() {
209 bool has_scrolled = scroll_gesture_has_scrolled_; 224 StopAnimation();
210 scroll_gesture_has_scrolled_ = false; 225 FadeIn();
211 226 // We should use the gesture delay rather than the resize delay if we're in a
212 currently_scrolling_ = false; 227 // gesture scroll, even if it is resizing.
213 228 PostDelayedFadeOut(!currently_scrolling_);
214 // We don't fade out scrollbar if they need thinning animation and mouse is
215 // near.
216 if (need_thinning_animation_ && mouse_is_near_any_scrollbar())
217 return;
218
219 if (has_scrolled)
220 PostDelayedFadeOut(false);
221 } 229 }
222 230
223 void ScrollbarAnimationController::DidMouseDown() { 231 void ScrollbarAnimationController::DidMouseDown() {
224 if (!need_thinning_animation_ || ScrollbarsHidden()) 232 if (!need_thinning_animation_ || ScrollbarsHidden())
225 return; 233 return;
226 234
227 vertical_controller_->DidMouseDown(); 235 vertical_controller_->DidMouseDown();
228 horizontal_controller_->DidMouseDown(); 236 horizontal_controller_->DidMouseDown();
229 } 237 }
230 238
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 bool previouslyVisible = opacity_ > 0.0f; 371 bool previouslyVisible = opacity_ > 0.0f;
364 bool currentlyVisible = opacity > 0.0f; 372 bool currentlyVisible = opacity > 0.0f;
365 373
366 opacity_ = opacity; 374 opacity_ = opacity;
367 375
368 if (previouslyVisible != currentlyVisible) 376 if (previouslyVisible != currentlyVisible)
369 client_->DidChangeScrollbarVisibility(); 377 client_->DidChangeScrollbarVisibility();
370 } 378 }
371 379
372 } // namespace cc 380 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698