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

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

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: move ScrollbarAnimationControllerClient back Created 3 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_H_ 5 #ifndef CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
7 7
8 #include "base/cancelable_callback.h" 8 #include "base/cancelable_callback.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/input/single_scrollbar_animation_controller_thinning.h"
12 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
13 #include "cc/layers/scrollbar_layer_impl_base.h" 14 #include "cc/layers/scrollbar_layer_impl_base.h"
14 #include "ui/gfx/geometry/vector2d_f.h" 15 #include "ui/gfx/geometry/vector2d_f.h"
15 16
16 namespace cc { 17 namespace cc {
17 18
18 class ScrollbarAnimationController;
19
20 class CC_EXPORT ScrollbarAnimationControllerClient { 19 class CC_EXPORT ScrollbarAnimationControllerClient {
21 public: 20 public:
22 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task, 21 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task,
23 base::TimeDelta delay) = 0; 22 base::TimeDelta delay) = 0;
24 virtual void SetNeedsRedrawForScrollbarAnimation() = 0; 23 virtual void SetNeedsRedrawForScrollbarAnimation() = 0;
25 virtual void SetNeedsAnimateForScrollbarAnimation() = 0; 24 virtual void SetNeedsAnimateForScrollbarAnimation() = 0;
26 virtual void DidChangeScrollbarVisibility() = 0; 25 virtual void DidChangeScrollbarVisibility() = 0;
27 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0; 26 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0;
28 27
29 protected: 28 protected:
30 virtual ~ScrollbarAnimationControllerClient() {} 29 virtual ~ScrollbarAnimationControllerClient() {}
31 }; 30 };
32 31
33 // This abstract class represents the compositor-side analogy of 32 // This abstract class represents the compositor-side analogy of
34 // ScrollbarAnimator. Individual platforms should subclass it to provide 33 // ScrollbarAnimator. Individual platforms should subclass it to provide
35 // specialized implementation. 34 // specialized implementation.
35 // This class also passes the mouse state to each
36 // SingleScrollbarAnimationControllerThinning. The thinning animations are
37 // independent between vertical/horizontal and are managed by the
38 // SingleScrollbarAnimationControllerThinnings.
36 class CC_EXPORT ScrollbarAnimationController { 39 class CC_EXPORT ScrollbarAnimationController {
37 public: 40 public:
38 virtual ~ScrollbarAnimationController(); 41 virtual ~ScrollbarAnimationController();
39 42
40 bool Animate(base::TimeTicks now); 43 bool Animate(base::TimeTicks now);
41 44
42 virtual void DidScrollBegin(); 45 virtual void DidScrollBegin();
43 virtual void DidScrollUpdate(bool on_resize); 46 virtual void DidScrollUpdate(bool on_resize);
44 virtual void DidScrollEnd(); 47 virtual void DidScrollEnd();
45 virtual void DidMouseDown() {}
46 virtual void DidMouseUp() {}
47 virtual void DidMouseLeave() {}
48 virtual void DidMouseMoveNear(float distance) {}
49 virtual bool ScrollbarsHidden() const; 48 virtual bool ScrollbarsHidden() const;
49 virtual bool NeedThinningAnimation() const;
weiliangc 2017/01/26 23:13:54 Not need to change this, just providing some alter
50
51 void DidMouseDown();
52 void DidMouseUp();
53 void DidMouseLeave();
54 void DidMouseMoveNear(ScrollbarOrientation, float);
55
56 bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const;
57 bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const;
58 bool mouse_is_near_any_scrollbar() const;
59
60 void set_mouse_move_distance_for_test(float distance);
50 61
51 protected: 62 protected:
52 ScrollbarAnimationController(int scroll_layer_id, 63 ScrollbarAnimationController(int scroll_layer_id,
53 ScrollbarAnimationControllerClient* client, 64 ScrollbarAnimationControllerClient* client,
54 base::TimeDelta delay_before_starting, 65 base::TimeDelta delay_before_starting,
55 base::TimeDelta resize_delay_before_starting); 66 base::TimeDelta resize_delay_before_starting);
56 67
57 virtual void RunAnimationFrame(float progress) = 0; 68 virtual void RunAnimationFrame(float progress) = 0;
58 virtual const base::TimeDelta& Duration() = 0; 69 virtual const base::TimeDelta& Duration() = 0;
70 virtual void ApplyOpacityToScrollbars(float opacity) = 0;
59 71
60 void StartAnimation(); 72 void StartAnimation();
61 void StopAnimation(); 73 void StopAnimation();
62 ScrollbarSet Scrollbars() const; 74 ScrollbarSet Scrollbars() const;
63 75
64 ScrollbarAnimationControllerClient* client_; 76 ScrollbarAnimationControllerClient* client_;
65 77
66 void PostDelayedAnimationTask(bool on_resize); 78 void PostDelayedAnimationTask(bool on_resize);
67 79
68 int scroll_layer_id() const { return scroll_layer_id_; } 80 int scroll_layer_id() const { return scroll_layer_id_; }
69 81
82 bool animating_fade() const { return is_animating_; }
83
84 bool Captured() const;
85
86 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
87 vertical_controller_;
88 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
89 horizontal_controller_;
90
70 private: 91 private:
71 // Returns how far through the animation we are as a progress value from 92 // Returns how far through the animation we are as a progress value from
72 // 0 to 1. 93 // 0 to 1.
73 float AnimationProgressAtTime(base::TimeTicks now); 94 float AnimationProgressAtTime(base::TimeTicks now);
74 95
96 SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
97 ScrollbarOrientation) const;
98
75 base::TimeTicks last_awaken_time_; 99 base::TimeTicks last_awaken_time_;
76 base::TimeDelta delay_before_starting_; 100 base::TimeDelta delay_before_starting_;
77 base::TimeDelta resize_delay_before_starting_; 101 base::TimeDelta resize_delay_before_starting_;
78 102
79 bool is_animating_; 103 bool is_animating_;
80 104
81 int scroll_layer_id_; 105 int scroll_layer_id_;
82 bool currently_scrolling_; 106 bool currently_scrolling_;
83 bool scroll_gesture_has_scrolled_; 107 bool scroll_gesture_has_scrolled_;
84 base::CancelableClosure delayed_scrollbar_fade_; 108 base::CancelableClosure delayed_scrollbar_fade_;
85 109
86 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 110 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
87 }; 111 };
88 112
89 } // namespace cc 113 } // namespace cc
90 114
91 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 115 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698