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

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

Issue 2716453005: Aura Overlay Scrollbars appear when mouse hovers over scroller edge (Closed)
Patch Set: change trigger to 30px 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 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 fade in/out 40 // ScrollbarAnimationController for Android. It only has fade in/out
41 // animation. 41 // animation.
42 static std::unique_ptr<ScrollbarAnimationController> 42 static std::unique_ptr<ScrollbarAnimationController>
43 CreateScrollbarAnimationControllerAndroid( 43 CreateScrollbarAnimationControllerAndroid(
44 int scroll_layer_id, 44 int scroll_layer_id,
45 ScrollbarAnimationControllerClient* client, 45 ScrollbarAnimationControllerClient* client,
46 base::TimeDelta delay_before_starting, 46 base::TimeDelta fade_out_delay,
47 base::TimeDelta resize_delay_before_starting, 47 base::TimeDelta fade_out_resize_delay,
48 base::TimeDelta fade_duration); 48 base::TimeDelta fade_out_duration);
49 49
50 // ScrollbarAnimationController for Desktop Overlay Scrollbar. It has fade in/ 50 // ScrollbarAnimationController for Desktop Overlay Scrollbar. It has fade in/
51 // out animation and thinning animation. 51 // 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 delay_before_starting, 56 base::TimeDelta fade_in_delay,
57 base::TimeDelta resize_delay_before_starting, 57 base::TimeDelta fade_out_delay,
58 base::TimeDelta fade_duration, 58 base::TimeDelta fade_out_resize_delay,
59 base::TimeDelta fade_out_duration,
59 base::TimeDelta thinning_duration); 60 base::TimeDelta thinning_duration);
60 61
61 ~ScrollbarAnimationController(); 62 ~ScrollbarAnimationController();
62 63
63 bool ScrollbarsHidden() const; 64 bool ScrollbarsHidden() const;
64 65
65 bool Animate(base::TimeTicks now); 66 bool Animate(base::TimeTicks now);
66 67
67 void DidScrollBegin(); 68 void DidScrollBegin();
68 void DidScrollUpdate(bool on_resize); 69 void DidScrollUpdate(bool on_resize);
69 void DidScrollEnd(); 70 void DidScrollEnd();
70 71
71 void DidMouseDown(); 72 void DidMouseDown();
72 void DidMouseUp(); 73 void DidMouseUp();
73 void DidMouseLeave(); 74 void DidMouseLeave();
74 void DidMouseMoveNear(ScrollbarOrientation, float); 75 void DidMouseMoveNear(ScrollbarOrientation, float);
75 76
76 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const; 77 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const;
77 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const; 78 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const;
78 bool mouse_is_near_any_scrollbar() const; 79 bool mouse_is_near_any_scrollbar() const;
79 80
81 static constexpr float kMouseMoveDistanceToTriggerFadeInAnimation = 30.0f;
82
80 private: 83 private:
81 ScrollbarAnimationController(int scroll_layer_id, 84 ScrollbarAnimationController(int scroll_layer_id,
82 ScrollbarAnimationControllerClient* client, 85 ScrollbarAnimationControllerClient* client,
83 base::TimeDelta delay_before_starting, 86 base::TimeDelta fade_out_delay,
84 base::TimeDelta resize_delay_before_starting, 87 base::TimeDelta fade_out_resize_delay,
85 base::TimeDelta fade_duration); 88 base::TimeDelta fade_out_duration);
86 89
87 ScrollbarAnimationController(int scroll_layer_id, 90 ScrollbarAnimationController(int scroll_layer_id,
88 ScrollbarAnimationControllerClient* client, 91 ScrollbarAnimationControllerClient* client,
89 base::TimeDelta delay_before_starting, 92 base::TimeDelta fade_in_delay,
90 base::TimeDelta resize_delay_before_starting, 93 base::TimeDelta fade_out_delay,
91 base::TimeDelta fade_duration, 94 base::TimeDelta fade_out_resize_delay,
95 base::TimeDelta fade_out_duration,
92 base::TimeDelta thinning_duration); 96 base::TimeDelta thinning_duration);
93 97
94 ScrollbarSet Scrollbars() const; 98 ScrollbarSet Scrollbars() const;
95 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController( 99 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
96 ScrollbarOrientation) const; 100 ScrollbarOrientation) const;
97 101
98 // Returns how far through the animation we are as a progress value from 102 // Returns how far through the animation we are as a progress value from
99 // 0 to 1. 103 // 0 to 1.
100 float AnimationProgressAtTime(base::TimeTicks now); 104 float AnimationProgressAtTime(base::TimeTicks now);
101 void RunAnimationFrame(float progress); 105 void RunAnimationFrame(float progress);
102 106
103 void StartAnimation(); 107 void StartAnimation();
104 void StopAnimation(); 108 void StopAnimation();
105 109
106 ScrollbarAnimationControllerClient* client_; 110 void FadeIn();
107 111
108 void PostDelayedAnimationTask(bool on_resize); 112 void PostDelayedFadeIn();
113 void PostDelayedFadeOut(bool on_resize);
109 114
110 bool Captured() const; 115 bool Captured() const;
111 116
117 bool CalcNeedTriggerScrollbarFadeIn(ScrollbarOrientation orientation,
118 float distance) const;
119
112 void ApplyOpacityToScrollbars(float opacity); 120 void ApplyOpacityToScrollbars(float opacity);
113 121
122 ScrollbarAnimationControllerClient* client_;
123
114 base::TimeTicks last_awaken_time_; 124 base::TimeTicks last_awaken_time_;
115 base::TimeDelta delay_before_starting_; 125
116 base::TimeDelta resize_delay_before_starting_; 126 // fade_in_delay_ is only for the case where the mouse hovers near the screen
127 // edge.
128 base::TimeDelta fade_in_delay_;
129 base::TimeDelta fade_out_delay_;
130 base::TimeDelta fade_out_resize_delay_;
131
132 bool need_trigger_scrollbar_fade_in_;
117 133
118 bool is_animating_; 134 bool is_animating_;
119 135
120 const int scroll_layer_id_; 136 const int scroll_layer_id_;
121 bool currently_scrolling_; 137 bool currently_scrolling_;
122 bool scroll_gesture_has_scrolled_; 138 bool scroll_gesture_has_scrolled_;
123 139
124 base::CancelableClosure delayed_scrollbar_fade_; 140 base::CancelableClosure delayed_scrollbar_fade_in_;
141 base::CancelableClosure delayed_scrollbar_fade_out_;
142
125 float opacity_; 143 float opacity_;
126 base::TimeDelta fade_duration_; 144 base::TimeDelta fade_out_duration_;
127 145
128 const bool need_thinning_animation_; 146 const bool need_thinning_animation_;
129 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 147 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
130 vertical_controller_; 148 vertical_controller_;
131 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 149 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
132 horizontal_controller_; 150 horizontal_controller_;
133 151
134 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 152 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
135 }; 153 };
136 154
137 } // namespace cc 155 } // namespace cc
138 156
139 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 157 #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