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

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

Issue 2692243005: Merge Compositor's ScrollbarAnimationControllers into single class (Closed)
Patch Set: Created 3 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
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 11 matching lines...) Expand all
22 base::TimeDelta delay) = 0; 22 base::TimeDelta delay) = 0;
23 virtual void SetNeedsRedrawForScrollbarAnimation() = 0; 23 virtual void SetNeedsRedrawForScrollbarAnimation() = 0;
24 virtual void SetNeedsAnimateForScrollbarAnimation() = 0; 24 virtual void SetNeedsAnimateForScrollbarAnimation() = 0;
25 virtual void DidChangeScrollbarVisibility() = 0; 25 virtual void DidChangeScrollbarVisibility() = 0;
26 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0; 26 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0;
27 27
28 protected: 28 protected:
29 virtual ~ScrollbarAnimationControllerClient() {} 29 virtual ~ScrollbarAnimationControllerClient() {}
30 }; 30 };
31 31
32 // This abstract class represents the compositor-side analogy of 32 // This class fade in scrollbars when scroll and fade out after an idle delay.
33 // ScrollbarAnimator. Individual platforms should subclass it to provide 33 // The fade animations works on both scrollbars and is controlled in this class
34 // specialized implementation.
35 // This class also passes the mouse state to each 34 // This class also passes the mouse state to each
36 // SingleScrollbarAnimationControllerThinning. The thinning animations are 35 // SingleScrollbarAnimationControllerThinning. The thinning animations are
37 // independent between vertical/horizontal and are managed by the 36 // independent between vertical/horizontal and are managed by the
38 // SingleScrollbarAnimationControllerThinnings. 37 // SingleScrollbarAnimationControllerThinnings.
39 class CC_EXPORT ScrollbarAnimationController { 38 class CC_EXPORT ScrollbarAnimationController {
40 public: 39 public:
41 virtual ~ScrollbarAnimationController(); 40 // ScrollbarAnimationController for Android only fade in/out.
41 static std::unique_ptr<ScrollbarAnimationController>
42 CreateScrollbarAnimationControllerLinearFade(
43 int scroll_layer_id,
44 ScrollbarAnimationControllerClient* client,
45 base::TimeDelta delay_before_starting,
46 base::TimeDelta resize_delay_before_starting,
47 base::TimeDelta fade_duration);
48
49 // ScrollbarAnimationController for Desktop Overlay Scrollbar.
weiliangc 2017/02/15 19:41:15 Could you elaborate more about how this is differe
50 static std::unique_ptr<ScrollbarAnimationController>
51 CreateScrollbarAnimationControllerThinning(
52 int scroll_layer_id,
53 ScrollbarAnimationControllerClient* client,
54 base::TimeDelta delay_before_starting,
55 base::TimeDelta resize_delay_before_starting,
56 base::TimeDelta fade_duration,
57 base::TimeDelta thinning_duration);
58
59 ~ScrollbarAnimationController();
60
61 bool ScrollbarsHidden() const;
42 62
43 bool Animate(base::TimeTicks now); 63 bool Animate(base::TimeTicks now);
44 64
45 virtual void DidScrollBegin(); 65 void DidScrollBegin();
46 virtual void DidScrollUpdate(bool on_resize); 66 void DidScrollUpdate(bool on_resize);
47 virtual void DidScrollEnd(); 67 void DidScrollEnd();
48 virtual bool ScrollbarsHidden() const;
49 virtual bool NeedThinningAnimation() const;
50 68
51 void DidMouseDown(); 69 void DidMouseDown();
52 void DidMouseUp(); 70 void DidMouseUp();
53 void DidMouseLeave(); 71 void DidMouseLeave();
54 void DidMouseMoveNear(ScrollbarOrientation, float); 72 void DidMouseMoveNear(ScrollbarOrientation, float);
55 73
56 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const; 74 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const;
57 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const; 75 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const;
58 bool mouse_is_near_any_scrollbar() const; 76 bool mouse_is_near_any_scrollbar() const;
59 77
60 void set_mouse_move_distance_for_test(float distance); 78 void set_mouse_move_distance_for_test(float distance);
61 79
62 protected: 80 private:
63 ScrollbarAnimationController(int scroll_layer_id, 81 ScrollbarAnimationController(int scroll_layer_id,
64 ScrollbarAnimationControllerClient* client, 82 ScrollbarAnimationControllerClient* client,
65 base::TimeDelta delay_before_starting, 83 base::TimeDelta delay_before_starting,
66 base::TimeDelta resize_delay_before_starting); 84 base::TimeDelta resize_delay_before_starting,
85 base::TimeDelta fade_duration);
67 86
68 virtual void RunAnimationFrame(float progress) = 0; 87 ScrollbarAnimationController(int scroll_layer_id,
69 virtual const base::TimeDelta& Duration() = 0; 88 ScrollbarAnimationControllerClient* client,
70 virtual void ApplyOpacityToScrollbars(float opacity) = 0; 89 base::TimeDelta delay_before_starting,
90 base::TimeDelta resize_delay_before_starting,
91 base::TimeDelta fade_duration,
92 base::TimeDelta thinning_duration);
93
94 ScrollbarSet Scrollbars() const;
95 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
96 ScrollbarOrientation) const;
97
98 // Returns how far through the animation we are as a progress value from
99 // 0 to 1.
100 float AnimationProgressAtTime(base::TimeTicks now);
101 void RunAnimationFrame(float progress);
71 102
72 void StartAnimation(); 103 void StartAnimation();
73 void StopAnimation(); 104 void StopAnimation();
74 ScrollbarSet Scrollbars() const;
75 105
76 ScrollbarAnimationControllerClient* client_; 106 ScrollbarAnimationControllerClient* client_;
77 107
78 void PostDelayedAnimationTask(bool on_resize); 108 void PostDelayedAnimationTask(bool on_resize);
79 109
80 int scroll_layer_id() const { return scroll_layer_id_; }
81
82 bool animating_fade() const { return is_animating_; }
83
84 bool Captured() const; 110 bool Captured() const;
85 111
86 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 112 void ApplyOpacityToScrollbars(float opacity);
87 vertical_controller_;
88 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
89 horizontal_controller_;
90
91 private:
92 // Returns how far through the animation we are as a progress value from
93 // 0 to 1.
94 float AnimationProgressAtTime(base::TimeTicks now);
95
96 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
97 ScrollbarOrientation) const;
98 113
99 base::TimeTicks last_awaken_time_; 114 base::TimeTicks last_awaken_time_;
100 base::TimeDelta delay_before_starting_; 115 base::TimeDelta delay_before_starting_;
101 base::TimeDelta resize_delay_before_starting_; 116 base::TimeDelta resize_delay_before_starting_;
102 117
103 bool is_animating_; 118 bool is_animating_;
104 119
105 int scroll_layer_id_; 120 int scroll_layer_id_;
106 bool currently_scrolling_; 121 bool currently_scrolling_;
107 bool scroll_gesture_has_scrolled_; 122 bool scroll_gesture_has_scrolled_;
123
108 base::CancelableClosure delayed_scrollbar_fade_; 124 base::CancelableClosure delayed_scrollbar_fade_;
125 float opacity_;
126 base::TimeDelta fade_duration_;
127
128 bool need_thinning_animation_;
weiliangc 2017/02/15 19:41:15 Make this const to show it is not changed outside
129 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
130 vertical_controller_;
131 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
132 horizontal_controller_;
109 133
110 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 134 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
111 }; 135 };
112 136
113 } // namespace cc 137 } // namespace cc
114 138
115 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 139 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698