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

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

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: add ScrollbarAnimationControllerThinningTest 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_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
7 7
8 #include <algorithm>
bokan 2016/12/08 19:34:07 I think this is unneeded?
8 #include <memory> 9 #include <memory>
9 10
10 #include "base/macros.h" 11 #include "base/macros.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/input/single_scrollbar_animation_controller_thinning.h"
13 15
14 namespace cc { 16 namespace cc {
15 17
18 using std::unique_ptr;
bokan 2016/12/08 19:34:07 I would prefer just using std:: in the declaration
19
16 // Scrollbar animation that partially fades and thins after an idle delay, 20 // Scrollbar animation that partially fades and thins after an idle delay,
17 // and reacts to mouse movements. 21 // and reacts to mouse movements.
18 class CC_EXPORT ScrollbarAnimationControllerThinning 22 class CC_EXPORT ScrollbarAnimationControllerThinning
bokan 2016/12/08 19:34:07 Please file a bug and add a TODO to clean up the i
19 : public ScrollbarAnimationController { 23 : public ScrollbarAnimationController {
20 public: 24 public:
21 static std::unique_ptr<ScrollbarAnimationControllerThinning> Create( 25 static unique_ptr<ScrollbarAnimationControllerThinning> Create(
22 int scroll_layer_id, 26 int scroll_layer_id,
23 ScrollbarAnimationControllerClient* client, 27 ScrollbarAnimationControllerClient* client,
24 base::TimeDelta delay_before_starting, 28 base::TimeDelta delay_before_starting,
25 base::TimeDelta resize_delay_before_starting, 29 base::TimeDelta resize_delay_before_starting,
26 base::TimeDelta fade_duration, 30 base::TimeDelta fade_duration,
27 base::TimeDelta thinning_duration); 31 base::TimeDelta thinning_duration);
28 32
29 ~ScrollbarAnimationControllerThinning() override; 33 ~ScrollbarAnimationControllerThinning() override;
30 34
31 void set_mouse_move_distance_for_test(float distance) { 35 void set_mouse_move_distance_for_test(float distance);
32 mouse_move_distance_to_trigger_animation_ = distance;
33 }
34 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; }
35 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; }
36 36
37 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const;
38 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const;
39 bool ScrollbarsHidden() const override;
40
41 bool Animate(base::TimeTicks now) override;
37 void DidScrollUpdate(bool on_resize) override; 42 void DidScrollUpdate(bool on_resize) override;
38
39 void DidMouseDown() override; 43 void DidMouseDown() override;
40 void DidMouseUp() override; 44 void DidMouseUp() override;
41 void DidMouseLeave() override; 45 void DidMouseLeave() override;
42 void DidMouseMoveNear(float distance) override; 46 void DidMouseMoveNear(ScrollbarOrientation, float) override;
43 bool ScrollbarsHidden() const override;
44 47
45 protected: 48 protected:
46 ScrollbarAnimationControllerThinning( 49 ScrollbarAnimationControllerThinning(
47 int scroll_layer_id, 50 int scroll_layer_id,
48 ScrollbarAnimationControllerClient* client, 51 ScrollbarAnimationControllerClient* client,
49 base::TimeDelta delay_before_starting, 52 base::TimeDelta delay_before_starting,
50 base::TimeDelta resize_delay_before_starting, 53 base::TimeDelta resize_delay_before_starting,
51 base::TimeDelta fade_duration, 54 base::TimeDelta fade_duration,
52 base::TimeDelta thinning_duration); 55 base::TimeDelta thinning_duration);
53 56
54 void RunAnimationFrame(float progress) override; 57 void RunAnimationFrame(float progress) override;
55 const base::TimeDelta& Duration() override; 58 const base::TimeDelta& Duration() override;
56 59
57 private: 60 private:
58 // Describes whether the current animation should INCREASE (thicken) 61 unique_ptr<SingleScrollbarAnimationControllerThinning> v_scrollbar_controller;
59 // a bar or DECREASE it (thin). 62 unique_ptr<SingleScrollbarAnimationControllerThinning> h_scrollbar_controller;
bokan 2016/12/08 19:34:07 Call these vertical_controller_ and horizontal_con
60 enum AnimationChange { NONE, INCREASE, DECREASE };
61 enum AnimatingProperty { OPACITY, THICKNESS };
62 float ThumbThicknessScaleAt(float progress);
63 float AdjustScale(float new_value,
64 float current_value,
65 AnimationChange animation_change,
66 float min_value,
67 float max_value);
68 void ApplyOpacity(float opacity);
69 void ApplyThumbThicknessScale(float thumb_thickness_scale);
70 63
71 void SetCurrentAnimatingProperty(AnimatingProperty property); 64 SingleScrollbarAnimationControllerThinning* GetScrollbarAnimationController(
72 65 ScrollbarOrientation) const;
73 float opacity_;
74 bool captured_;
75 bool mouse_is_over_scrollbar_;
76 bool mouse_is_near_scrollbar_;
77 // Are we narrowing or thickening the bars.
78 AnimationChange thickness_change_;
79 // How close should the mouse be to the scrollbar before we thicken it.
80 float mouse_move_distance_to_trigger_animation_;
81
82 base::TimeDelta fade_duration_;
83 base::TimeDelta thinning_duration_;
84
85 AnimatingProperty current_animating_property_;
86 66
87 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning); 67 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning);
88 }; 68 };
89 69
90 } // namespace cc 70 } // namespace cc
91 71
92 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 72 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698