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

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

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: separate responsibilities of SACT and SSACT Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
6 #define CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/time/time.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/input/scrollbar_animation_controller.h"
14 #include "cc/layers/layer_impl.h"
15 #include "cc/layers/scrollbar_layer_impl_base.h"
16 #include "ui/gfx/geometry/vector2d_f.h"
17
18 namespace cc {
19
20 // ScrollbarAnimationControllerThinning for one scrollbar
21 class CC_EXPORT SingleScrollbarAnimationControllerThinning {
22 public:
23 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create(
24 int scroll_layer_id,
25 ScrollbarOrientation orientation,
26 ScrollbarAnimationControllerClient* client,
27 base::CancelableClosure* delayed_scrollbar_fade,
28 base::TimeDelta thinning_duration);
29
30 ~SingleScrollbarAnimationControllerThinning() {}
31
32 void set_mouse_move_distance_for_test(float distance) {
33 mouse_move_distance_to_trigger_animation_ = distance;
34 }
35 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; }
36 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; }
37 bool captured() const { return captured_; }
38
39 bool Animate(base::TimeTicks now);
40 void StartAnimation();
41 void StopAnimation();
42
43 bool ShouldFadeOut() const;
44 void UpdateThumbThicknessScale();
45
46 void DidMouseDown();
47 void DidMouseUp();
48 void DidMouseLeave();
49 void DidMouseMoveNear(float distance);
50
51 bool Hidden() const { return hidden_; }
52 void SetHidden(bool hidden) { hidden_ = hidden; }
53
54 private:
55 SingleScrollbarAnimationControllerThinning(
56 int scroll_layer_id,
57 ScrollbarOrientation orientation,
58 ScrollbarAnimationControllerClient* client,
59 base::CancelableClosure* delayed_scrollbar_fade,
60 base::TimeDelta thinning_duration);
61
62 float AnimationProgressAtTime(base::TimeTicks now);
63 void RunAnimationFrame(float progress);
64 const base::TimeDelta& Duration();
65
66 // Describes whether the current animation should INCREASE (thicken)
67 // a bar or DECREASE it (thin).
68 enum AnimationChange { NONE, INCREASE, DECREASE };
69 float ThumbThicknessScaleAt(float progress);
70
71 float AdjustScale(float new_value,
72 float current_value,
73 AnimationChange animation_change,
74 float min_value,
75 float max_value);
76 void ApplyThumbThicknessScale(float thumb_thickness_scale);
77
78 ScrollbarAnimationControllerClient* client_;
79 base::CancelableClosure* delayed_scrollbar_fade_;
80
81 base::TimeTicks last_awaken_time_;
82 bool is_animating_;
83
84 int scroll_layer_id_;
85
86 ScrollbarOrientation orientation_;
87 bool hidden_;
88 bool captured_;
89 bool mouse_is_over_scrollbar_;
90 bool mouse_is_near_scrollbar_;
91 // Are we narrowing or thickening the bars.
92 AnimationChange thickness_change_;
93 // How close should the mouse be to the scrollbar before we thicken it.
94 float mouse_move_distance_to_trigger_animation_;
95
96 base::TimeDelta thinning_duration_;
97
98 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning);
99 };
100
101 } // namespace cc
102
103 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698