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

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

Issue 2824693002: Refactor LayerTreeImpl's scrollbar map to be keyed on element ids (Closed)
Patch Set: rebase Created 3 years, 8 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 kDefaultMouseMoveDistanceToTriggerAnimation = 25.f;
27 27
28 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create( 28 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create(
29 int scroll_layer_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() const { return mouse_is_over_scrollbar_; }
37 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } 37 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; }
38 bool captured() const { return captured_; } 38 bool captured() const { return captured_; }
39 39
40 bool Animate(base::TimeTicks now); 40 bool Animate(base::TimeTicks now);
41 void StartAnimation(); 41 void StartAnimation();
42 void StopAnimation(); 42 void StopAnimation();
43 43
44 void UpdateThumbThicknessScale(); 44 void UpdateThumbThicknessScale();
45 45
46 void DidMouseDown(); 46 void DidMouseDown();
47 void DidMouseUp(); 47 void DidMouseUp();
48 void DidMouseLeave(); 48 void DidMouseLeave();
49 void DidMouseMoveNear(float distance); 49 void DidMouseMoveNear(float distance);
50 50
51 private: 51 private:
52 SingleScrollbarAnimationControllerThinning( 52 SingleScrollbarAnimationControllerThinning(
53 int scroll_layer_id, 53 ElementId scroll_element_id,
54 ScrollbarOrientation orientation, 54 ScrollbarOrientation orientation,
55 ScrollbarAnimationControllerClient* client, 55 ScrollbarAnimationControllerClient* client,
56 base::TimeDelta thinning_duration); 56 base::TimeDelta thinning_duration);
57 57
58 float AnimationProgressAtTime(base::TimeTicks now); 58 float AnimationProgressAtTime(base::TimeTicks now);
59 void RunAnimationFrame(float progress); 59 void RunAnimationFrame(float progress);
60 const base::TimeDelta& Duration(); 60 const base::TimeDelta& Duration();
61 61
62 // Describes whether the current animation should INCREASE (thicken) 62 // Describes whether the current animation should INCREASE (thicken)
63 // a bar or DECREASE it (thin). 63 // a bar or DECREASE it (thin).
64 enum AnimationChange { NONE, INCREASE, DECREASE }; 64 enum AnimationChange { NONE, INCREASE, DECREASE };
65 float ThumbThicknessScaleAt(float progress); 65 float ThumbThicknessScaleAt(float progress);
66 66
67 float AdjustScale(float new_value, 67 float AdjustScale(float new_value,
68 float current_value, 68 float current_value,
69 AnimationChange animation_change, 69 AnimationChange animation_change,
70 float min_value, 70 float min_value,
71 float max_value); 71 float max_value);
72 void ApplyThumbThicknessScale(float thumb_thickness_scale); 72 void ApplyThumbThicknessScale(float thumb_thickness_scale);
73 73
74 ScrollbarAnimationControllerClient* client_; 74 ScrollbarAnimationControllerClient* client_;
75 75
76 base::TimeTicks last_awaken_time_; 76 base::TimeTicks last_awaken_time_;
77 bool is_animating_; 77 bool is_animating_;
78 78
79 int scroll_layer_id_; 79 ElementId scroll_element_id_;
80 80
81 ScrollbarOrientation orientation_; 81 ScrollbarOrientation orientation_;
82 bool captured_; 82 bool captured_;
83 bool mouse_is_over_scrollbar_; 83 bool mouse_is_over_scrollbar_;
84 bool mouse_is_near_scrollbar_; 84 bool mouse_is_near_scrollbar_;
85 // Are we narrowing or thickening the bars. 85 // Are we narrowing or thickening the bars.
86 AnimationChange thickness_change_; 86 AnimationChange thickness_change_;
87 87
88 base::TimeDelta thinning_duration_; 88 base::TimeDelta thinning_duration_;
89 89
90 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning); 90 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning);
91 }; 91 };
92 92
93 } // namespace cc 93 } // namespace cc
94 94
95 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 95 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
OLDNEW
« no previous file with comments | « cc/input/scrollbar_animation_controller_unittest.cc ('k') | cc/input/single_scrollbar_animation_controller_thinning.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698