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

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

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: fix for fade in/out together 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
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_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 5 #ifndef CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
6 #define CC_INPUT_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 "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
12 #include "cc/input/scrollbar_animation_controller.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"
13 17
14 namespace cc { 18 namespace cc {
15 19
16 // Scrollbar animation that partially fades and thins after an idle delay, 20 // ScrollbarAnimationControllerThinning for one scrollbar
17 // and reacts to mouse movements. 21 class CC_EXPORT SingleScrollbarAnimationControllerThinning {
18 class CC_EXPORT ScrollbarAnimationControllerThinning
19 : public ScrollbarAnimationController {
20 public: 22 public:
21 static std::unique_ptr<ScrollbarAnimationControllerThinning> Create( 23 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create(
22 int scroll_layer_id, 24 int scroll_layer_id,
25 ScrollbarOrientation orientation,
23 ScrollbarAnimationControllerClient* client, 26 ScrollbarAnimationControllerClient* client,
24 base::TimeDelta delay_before_starting, 27 base::CancelableClosure* delayed_scrollbar_fade,
25 base::TimeDelta resize_delay_before_starting,
26 base::TimeDelta fade_duration, 28 base::TimeDelta fade_duration,
27 base::TimeDelta thinning_duration); 29 base::TimeDelta thinning_duration);
28 30
29 ~ScrollbarAnimationControllerThinning() override; 31 ~SingleScrollbarAnimationControllerThinning() {}
30 32
31 void set_mouse_move_distance_for_test(float distance) { 33 void set_mouse_move_distance_for_test(float distance) {
32 mouse_move_distance_to_trigger_animation_ = distance; 34 mouse_move_distance_to_trigger_animation_ = distance;
33 } 35 }
34 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } 36 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; }
35 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_; }
36 39
37 void DidScrollUpdate(bool on_resize) override; 40 bool Animate(base::TimeTicks now);
38 void DidScrollEnd() override; 41 void StartAnimation();
42 void StopAnimation();
39 43
40 void DidMouseDown() override; 44 void FadeIn();
41 void DidMouseUp() override; 45 bool ShouldFadeOut() const;
42 void DidMouseLeave() override;
43 void DidMouseMoveNear(float distance) override;
44 bool ScrollbarsHidden() const override;
45 46
46 protected: 47 void DidMouseDown();
47 ScrollbarAnimationControllerThinning( 48 void DidMouseUp();
49 void DidMouseLeave();
50 void DidMouseMoveNear(float distance);
51 bool ScrollbarsHidden() const;
52
53 const base::TimeDelta& Duration();
54
55 private:
56 SingleScrollbarAnimationControllerThinning(
48 int scroll_layer_id, 57 int scroll_layer_id,
58 ScrollbarOrientation orientation,
49 ScrollbarAnimationControllerClient* client, 59 ScrollbarAnimationControllerClient* client,
50 base::TimeDelta delay_before_starting, 60 base::CancelableClosure* delayed_scrollbar_fade,
51 base::TimeDelta resize_delay_before_starting,
52 base::TimeDelta fade_duration, 61 base::TimeDelta fade_duration,
53 base::TimeDelta thinning_duration); 62 base::TimeDelta thinning_duration);
54 63
55 void RunAnimationFrame(float progress) override; 64 float AnimationProgressAtTime(base::TimeTicks now);
56 const base::TimeDelta& Duration() override; 65 void RunAnimationFrame(float progress);
57 66
58 private:
59 // Describes whether the current animation should INCREASE (thicken) 67 // Describes whether the current animation should INCREASE (thicken)
60 // a bar or DECREASE it (thin). 68 // a bar or DECREASE it (thin).
61 enum AnimationChange { NONE, INCREASE, DECREASE }; 69 enum AnimationChange { NONE, INCREASE, DECREASE };
62 enum AnimatingProperty { OPACITY, THICKNESS }; 70 enum AnimatingProperty { OPACITY, THICKNESS };
63 float ThumbThicknessScaleAt(float progress); 71 float ThumbThicknessScaleAt(float progress);
72
64 float AdjustScale(float new_value, 73 float AdjustScale(float new_value,
65 float current_value, 74 float current_value,
66 AnimationChange animation_change, 75 AnimationChange animation_change,
67 float min_value, 76 float min_value,
68 float max_value); 77 float max_value);
69 void ApplyOpacity(float opacity); 78 void ApplyOpacity(float opacity);
70 void ApplyThumbThicknessScale(float thumb_thickness_scale); 79 void ApplyThumbThicknessScale(float thumb_thickness_scale);
71 80
72 void SetCurrentAnimatingProperty(AnimatingProperty property); 81 void SetCurrentAnimatingProperty(AnimatingProperty property);
73 82
83 ScrollbarSet Scrollbars() const;
bokan 2016/12/16 14:57:42 This should just return one scrollbar.
84
85 ScrollbarAnimationControllerClient* client_;
86 base::CancelableClosure* delayed_scrollbar_fade_;
87
88 base::TimeTicks last_awaken_time_;
89 bool is_animating_;
90
91 int scroll_layer_id_;
92
93 ScrollbarOrientation orientation_;
74 float opacity_; 94 float opacity_;
75 bool captured_; 95 bool captured_;
76 bool mouse_is_over_scrollbar_; 96 bool mouse_is_over_scrollbar_;
77 bool mouse_is_near_scrollbar_; 97 bool mouse_is_near_scrollbar_;
78 // Are we narrowing or thickening the bars. 98 // Are we narrowing or thickening the bars.
79 AnimationChange thickness_change_; 99 AnimationChange thickness_change_;
80 // How close should the mouse be to the scrollbar before we thicken it. 100 // How close should the mouse be to the scrollbar before we thicken it.
81 float mouse_move_distance_to_trigger_animation_; 101 float mouse_move_distance_to_trigger_animation_;
82 102
83 base::TimeDelta fade_duration_; 103 base::TimeDelta fade_duration_;
84 base::TimeDelta thinning_duration_; 104 base::TimeDelta thinning_duration_;
85 105
86 AnimatingProperty current_animating_property_; 106 AnimatingProperty current_animating_property_;
87 107
88 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning); 108 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning);
89 }; 109 };
90 110
91 } // namespace cc 111 } // namespace cc
92 112
93 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 113 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698