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

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

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: add tests Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 5 #ifndef CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
6 #define CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 6 #define CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "cc/cc_export.h" 12 #include "cc/cc_export.h"
13 #include "cc/input/scrollbar.h" 13 #include "cc/input/scrollbar.h"
14 #include "cc/layers/layer_impl.h" 14 #include "cc/layers/layer_impl.h"
15 #include "cc/layers/scrollbar_layer_impl_base.h" 15 #include "cc/layers/scrollbar_layer_impl_base.h"
16 #include "ui/gfx/geometry/vector2d_f.h" 16 #include "ui/gfx/geometry/vector2d_f.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 class ScrollbarAnimationControllerClient; 20 class ScrollbarAnimationControllerClient;
21 21
22 // ScrollbarAnimationControllerThinning for one scrollbar 22 // ScrollbarAnimationControllerThinning for one scrollbar
23 class CC_EXPORT SingleScrollbarAnimationControllerThinning { 23 class CC_EXPORT SingleScrollbarAnimationControllerThinning {
24 public: 24 public:
25 static constexpr float kIdleThicknessScale = 0.4f; 25 static constexpr float kIdleThicknessScale = 0.4f;
26 static constexpr float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f; 26 static constexpr float kMouseMoveDistanceToTriggerExpand = 25.f;
27 27
28 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create( 28 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create(
29 ElementId scroll_element_id, 29 ElementId scroll_element_id,
30 ScrollbarOrientation orientation, 30 ScrollbarOrientation orientation,
31 ScrollbarAnimationControllerClient* client, 31 ScrollbarAnimationControllerClient* client,
32 base::TimeDelta thinning_duration); 32 base::TimeDelta thinning_duration);
33 33
34 ~SingleScrollbarAnimationControllerThinning() {} 34 ~SingleScrollbarAnimationControllerThinning() {}
35 35
36 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } 36 bool mouse_is_over_scrollbar_thumb() const {
37 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } 37 return mouse_is_over_scrollbar_thumb_;
38 }
39 bool mouse_is_near_scrollbar_thumb() const {
40 return mouse_is_near_scrollbar_thumb_;
41 }
38 bool captured() const { return captured_; } 42 bool captured() const { return captured_; }
39 43
40 bool Animate(base::TimeTicks now); 44 bool Animate(base::TimeTicks now);
41 void StartAnimation(); 45 void StartAnimation();
42 void StopAnimation(); 46 void StopAnimation();
43 47
44 void UpdateThumbThicknessScale(); 48 void UpdateThumbThicknessScale();
45 49
46 void DidMouseDown(); 50 void DidMouseDown();
47 void DidMouseUp(); 51 void DidMouseUp();
48 void DidMouseLeave(); 52 void DidMouseLeave();
49 void DidMouseMoveNear(float distance); 53 void DidMouseMove(float distance_to_thumb);
50 54
51 private: 55 private:
52 SingleScrollbarAnimationControllerThinning( 56 SingleScrollbarAnimationControllerThinning(
53 ElementId scroll_element_id, 57 ElementId scroll_element_id,
54 ScrollbarOrientation orientation, 58 ScrollbarOrientation orientation,
55 ScrollbarAnimationControllerClient* client, 59 ScrollbarAnimationControllerClient* client,
56 base::TimeDelta thinning_duration); 60 base::TimeDelta thinning_duration);
57 61
58 float AnimationProgressAtTime(base::TimeTicks now); 62 float AnimationProgressAtTime(base::TimeTicks now);
59 void RunAnimationFrame(float progress); 63 void RunAnimationFrame(float progress);
(...skipping 13 matching lines...) Expand all
73 77
74 ScrollbarAnimationControllerClient* client_; 78 ScrollbarAnimationControllerClient* client_;
75 79
76 base::TimeTicks last_awaken_time_; 80 base::TimeTicks last_awaken_time_;
77 bool is_animating_; 81 bool is_animating_;
78 82
79 ElementId scroll_element_id_; 83 ElementId scroll_element_id_;
80 84
81 ScrollbarOrientation orientation_; 85 ScrollbarOrientation orientation_;
82 bool captured_; 86 bool captured_;
83 bool mouse_is_over_scrollbar_; 87 bool mouse_is_over_scrollbar_thumb_;
84 bool mouse_is_near_scrollbar_; 88 bool mouse_is_near_scrollbar_thumb_;
85 // Are we narrowing or thickening the bars. 89 // Are we narrowing or thickening the bars.
86 AnimationChange thickness_change_; 90 AnimationChange thickness_change_;
87 91
88 base::TimeDelta thinning_duration_; 92 base::TimeDelta thinning_duration_;
89 93
90 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning); 94 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning);
91 }; 95 };
92 96
93 } // namespace cc 97 } // namespace cc
94 98
95 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 99 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698