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

Side by Side Diff: cc/input/scrollbar_animation_controller.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 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/scrollbar.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 class ScrollbarAnimationController;
19 20
20 class CC_EXPORT ScrollbarAnimationControllerClient { 21 class CC_EXPORT ScrollbarAnimationControllerClient {
21 public: 22 public:
22 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task, 23 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task,
23 base::TimeDelta delay) = 0; 24 base::TimeDelta delay) = 0;
24 virtual void SetNeedsRedrawForScrollbarAnimation() = 0; 25 virtual void SetNeedsRedrawForScrollbarAnimation() = 0;
25 virtual void SetNeedsAnimateForScrollbarAnimation() = 0; 26 virtual void SetNeedsAnimateForScrollbarAnimation() = 0;
26 virtual void DidChangeScrollbarVisibility() = 0; 27 virtual void DidChangeScrollbarVisibility() = 0;
27 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0; 28 virtual ScrollbarSet ScrollbarsFor(int scroll_layer_id) const = 0;
28 29
29 protected: 30 protected:
30 virtual ~ScrollbarAnimationControllerClient() {} 31 virtual ~ScrollbarAnimationControllerClient() {}
31 }; 32 };
32 33
33 // This abstract class represents the compositor-side analogy of 34 // This abstract class represents the compositor-side analogy of
34 // ScrollbarAnimator. Individual platforms should subclass it to provide 35 // ScrollbarAnimator. Individual platforms should subclass it to provide
35 // specialized implementation. 36 // specialized implementation.
36 class CC_EXPORT ScrollbarAnimationController { 37 class CC_EXPORT ScrollbarAnimationController {
37 public: 38 public:
38 virtual ~ScrollbarAnimationController(); 39 virtual ~ScrollbarAnimationController();
39 40
40 bool Animate(base::TimeTicks now); 41 virtual bool Animate(base::TimeTicks now);
41 42
42 virtual void DidScrollBegin(); 43 virtual void DidScrollBegin();
43 virtual void DidScrollUpdate(bool on_resize); 44 virtual void DidScrollUpdate(bool on_resize);
44 virtual void DidScrollEnd(); 45 virtual void DidScrollEnd();
45 virtual void DidMouseDown() {} 46 virtual void DidMouseDown() {}
46 virtual void DidMouseUp() {} 47 virtual void DidMouseUp() {}
47 virtual void DidMouseLeave() {} 48 virtual void DidMouseLeave() {}
48 virtual void DidMouseMoveNear(float distance) {} 49 virtual void DidMouseMoveNear(ScrollbarOrientation, float) {}
50 virtual void EnsureScrollbarFadeIn() {}
49 virtual bool ScrollbarsHidden() const; 51 virtual bool ScrollbarsHidden() const;
50 52
51 protected: 53 protected:
52 ScrollbarAnimationController(int scroll_layer_id, 54 ScrollbarAnimationController(int scroll_layer_id,
53 ScrollbarAnimationControllerClient* client, 55 ScrollbarAnimationControllerClient* client,
54 base::TimeDelta delay_before_starting, 56 base::TimeDelta delay_before_starting,
55 base::TimeDelta resize_delay_before_starting); 57 base::TimeDelta resize_delay_before_starting);
56 58
57 virtual void RunAnimationFrame(float progress) = 0; 59 virtual void RunAnimationFrame(float progress) = 0;
58 virtual const base::TimeDelta& Duration() = 0; 60 virtual const base::TimeDelta& Duration() = 0;
59 61
60 void StartAnimation(); 62 virtual void StartAnimation();
61 void StopAnimation(); 63 void StopAnimation();
64
62 ScrollbarSet Scrollbars() const; 65 ScrollbarSet Scrollbars() const;
63 66
64 ScrollbarAnimationControllerClient* client_; 67 ScrollbarAnimationControllerClient* client_;
65 68
66 void PostDelayedAnimationTask(bool on_resize); 69 void PostDelayedAnimationTask(bool on_resize);
67 70
71 base::CancelableClosure* delayed_scrollbar_fade() {
72 return &delayed_scrollbar_fade_;
73 }
74
68 int scroll_layer_id() const { return scroll_layer_id_; } 75 int scroll_layer_id() const { return scroll_layer_id_; }
69 76
70 private: 77 private:
71 // Returns how far through the animation we are as a progress value from 78 // Returns how far through the animation we are as a progress value from
72 // 0 to 1. 79 // 0 to 1.
73 float AnimationProgressAtTime(base::TimeTicks now); 80 float AnimationProgressAtTime(base::TimeTicks now);
74 81
75 base::TimeTicks last_awaken_time_; 82 base::TimeTicks last_awaken_time_;
76 base::TimeDelta delay_before_starting_; 83 base::TimeDelta delay_before_starting_;
77 base::TimeDelta resize_delay_before_starting_; 84 base::TimeDelta resize_delay_before_starting_;
78 85
79 bool is_animating_; 86 bool is_animating_;
80 87
81 int scroll_layer_id_; 88 int scroll_layer_id_;
82 bool currently_scrolling_; 89 bool currently_scrolling_;
83 bool scroll_gesture_has_scrolled_; 90 bool scroll_gesture_has_scrolled_;
84 base::CancelableClosure delayed_scrollbar_fade_; 91 base::CancelableClosure delayed_scrollbar_fade_;
85 92
86 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_; 93 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
87 }; 94 };
88 95
89 } // namespace cc 96 } // namespace cc
90 97
91 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_ 98 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698