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

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

Issue 960873002: Update from https://crrev.com/318214 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « cc/BUILD.gn ('k') | cc/animation/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_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_ 5 #ifndef CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
6 #define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_ 6 #define CC_ANIMATION_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"
11 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/layers/layer_impl.h"
12 #include "ui/gfx/geometry/vector2d_f.h" 13 #include "ui/gfx/geometry/vector2d_f.h"
13 14
14 namespace cc { 15 namespace cc {
15 16
17 class ScrollbarAnimationController;
18
16 class CC_EXPORT ScrollbarAnimationControllerClient { 19 class CC_EXPORT ScrollbarAnimationControllerClient {
17 public: 20 public:
21 virtual void StartAnimatingScrollbarAnimationController(
22 ScrollbarAnimationController* controller) = 0;
23 virtual void StopAnimatingScrollbarAnimationController(
24 ScrollbarAnimationController* controller) = 0;
25 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task,
26 base::TimeDelta delay) = 0;
27 virtual void SetNeedsRedrawForScrollbarAnimation() = 0;
28
29 protected:
18 virtual ~ScrollbarAnimationControllerClient() {} 30 virtual ~ScrollbarAnimationControllerClient() {}
19
20 virtual void PostDelayedScrollbarFade(const base::Closure& start_fade,
21 base::TimeDelta delay) = 0;
22 virtual void SetNeedsScrollbarAnimationFrame() = 0;
23 }; 31 };
24 32
25 // This abstract class represents the compositor-side analogy of 33 // This abstract class represents the compositor-side analogy of
26 // ScrollbarAnimator. Individual platforms should subclass it to provide 34 // ScrollbarAnimator. Individual platforms should subclass it to provide
27 // specialized implementation. 35 // specialized implementation.
28 class CC_EXPORT ScrollbarAnimationController { 36 class CC_EXPORT ScrollbarAnimationController {
29 public: 37 public:
30 virtual ~ScrollbarAnimationController(); 38 virtual ~ScrollbarAnimationController();
31 39
32 void Animate(base::TimeTicks now); 40 void Animate(base::TimeTicks now);
33 41
34 virtual void DidScrollBegin(); 42 virtual void DidScrollBegin();
35 virtual void DidScrollUpdate(bool on_resize); 43 virtual void DidScrollUpdate(bool on_resize);
36 virtual void DidScrollEnd(); 44 virtual void DidScrollEnd();
37 virtual void DidMouseMoveOffScrollbar() {} 45 virtual void DidMouseMoveOffScrollbar() {}
38 virtual void DidMouseMoveNear(float distance) {} 46 virtual void DidMouseMoveNear(float distance) {}
39 47
40 protected: 48 protected:
41 ScrollbarAnimationController(ScrollbarAnimationControllerClient* client, 49 ScrollbarAnimationController(LayerImpl* scroll_layer,
50 ScrollbarAnimationControllerClient* client,
42 base::TimeDelta delay_before_starting, 51 base::TimeDelta delay_before_starting,
43 base::TimeDelta resize_delay_before_starting, 52 base::TimeDelta resize_delay_before_starting,
44 base::TimeDelta duration); 53 base::TimeDelta duration);
45 54
46 virtual void RunAnimationFrame(float progress) = 0; 55 virtual void RunAnimationFrame(float progress) = 0;
47 56
48 void StartAnimation(); 57 void StartAnimation();
49 void StopAnimation(); 58 void StopAnimation();
50 59
60 LayerImpl* scroll_layer_;
61 ScrollbarAnimationControllerClient* client_;
62
51 private: 63 private:
52 // Returns how far through the animation we are as a progress value from 64 // Returns how far through the animation we are as a progress value from
53 // 0 to 1. 65 // 0 to 1.
54 float AnimationProgressAtTime(base::TimeTicks now); 66 float AnimationProgressAtTime(base::TimeTicks now);
55 67
56 void PostDelayedFade(bool on_resize); 68 void PostDelayedAnimationTask(bool on_resize);
57 69
58 ScrollbarAnimationControllerClient* client_;
59 base::TimeTicks last_awaken_time_; 70 base::TimeTicks last_awaken_time_;
60 base::TimeDelta delay_before_starting_; 71 base::TimeDelta delay_before_starting_;
61 base::TimeDelta resize_delay_before_starting_; 72 base::TimeDelta resize_delay_before_starting_;
62 base::TimeDelta duration_; 73 base::TimeDelta duration_;
74
63 bool is_animating_; 75 bool is_animating_;
64 76
65 bool currently_scrolling_; 77 bool currently_scrolling_;
66 bool scroll_gesture_has_scrolled_; 78 bool scroll_gesture_has_scrolled_;
67 base::CancelableClosure delayed_scrollbar_fade_; 79 base::CancelableClosure delayed_scrollbar_fade_;
68 80
69 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 81 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
70 }; 82 };
71 83
72 } // namespace cc 84 } // namespace cc
73 85
74 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_ 86 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « cc/BUILD.gn ('k') | cc/animation/scrollbar_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698