OLD | NEW |
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_TOP_CONTROLS_MANAGER_H_ | 5 #ifndef CC_INPUT_TOP_CONTROLS_MANAGER_H_ |
6 #define CC_INPUT_TOP_CONTROLS_MANAGER_H_ | 6 #define CC_INPUT_TOP_CONTROLS_MANAGER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "cc/input/top_controls_state.h" | 10 #include "cc/input/top_controls_state.h" |
11 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
| 12 #include "ui/gfx/frame_time.h" |
12 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
13 #include "ui/gfx/vector2d_f.h" | 14 #include "ui/gfx/vector2d_f.h" |
14 | 15 |
15 namespace base { | |
16 class TimeTicks; | |
17 } | |
18 | |
19 namespace cc { | 16 namespace cc { |
20 | 17 |
21 class KeyframedFloatAnimationCurve; | 18 class KeyframedFloatAnimationCurve; |
22 class LayerTreeImpl; | 19 class LayerTreeImpl; |
23 class TopControlsManagerClient; | 20 class TopControlsManagerClient; |
24 | 21 |
25 // Manages the position of the top controls. | 22 // Manages the position of the top controls. |
26 class CC_EXPORT TopControlsManager | 23 class CC_EXPORT TopControlsManager |
27 : public base::SupportsWeakPtr<TopControlsManager> { | 24 : public base::SupportsWeakPtr<TopControlsManager> { |
28 public: | 25 public: |
(...skipping 20 matching lines...) Expand all Loading... |
49 AnimationDirection animation_direction() { return animation_direction_; } | 46 AnimationDirection animation_direction() { return animation_direction_; } |
50 | 47 |
51 void UpdateTopControlsState(TopControlsState constraints, | 48 void UpdateTopControlsState(TopControlsState constraints, |
52 TopControlsState current, | 49 TopControlsState current, |
53 bool animate); | 50 bool animate); |
54 | 51 |
55 void ScrollBegin(); | 52 void ScrollBegin(); |
56 gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); | 53 gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); |
57 void ScrollEnd(); | 54 void ScrollEnd(); |
58 | 55 |
59 gfx::Vector2dF Animate(base::TimeTicks monotonic_time); | 56 gfx::Vector2dF Animate(gfx::FrameTime monotonic_time); |
60 | 57 |
61 protected: | 58 protected: |
62 TopControlsManager(TopControlsManagerClient* client, | 59 TopControlsManager(TopControlsManagerClient* client, |
63 float top_controls_height, | 60 float top_controls_height, |
64 float top_controls_show_threshold, | 61 float top_controls_show_threshold, |
65 float top_controls_hide_threshold); | 62 float top_controls_hide_threshold); |
66 | 63 |
67 private: | 64 private: |
68 void SetControlsTopOffset(float offset); | 65 void SetControlsTopOffset(float offset); |
69 void ResetAnimations(); | 66 void ResetAnimations(); |
70 void SetupAnimation(AnimationDirection direction); | 67 void SetupAnimation(AnimationDirection direction); |
71 void StartAnimationIfNecessary(); | 68 void StartAnimationIfNecessary(); |
72 bool IsAnimationCompleteAtTime(base::TimeTicks time); | 69 bool IsAnimationCompleteAtTime(gfx::FrameTime time); |
73 | 70 |
74 TopControlsManagerClient* client_; // The client manages the lifecycle of | 71 TopControlsManagerClient* client_; // The client manages the lifecycle of |
75 // this. | 72 // this. |
76 | 73 |
77 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; | 74 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; |
78 AnimationDirection animation_direction_; | 75 AnimationDirection animation_direction_; |
79 TopControlsState permitted_state_; | 76 TopControlsState permitted_state_; |
80 float controls_top_offset_; | 77 float controls_top_offset_; |
81 float top_controls_height_; | 78 float top_controls_height_; |
82 | 79 |
83 float current_scroll_delta_; | 80 float current_scroll_delta_; |
84 float controls_scroll_begin_offset_; | 81 float controls_scroll_begin_offset_; |
85 | 82 |
86 // The height of the visible top control such that it must be shown when | 83 // The height of the visible top control such that it must be shown when |
87 // the user stops the scroll. | 84 // the user stops the scroll. |
88 float top_controls_show_height_; | 85 float top_controls_show_height_; |
89 | 86 |
90 // The height of the visible top control such that it must be hidden when | 87 // The height of the visible top control such that it must be hidden when |
91 // the user stops the scroll. | 88 // the user stops the scroll. |
92 float top_controls_hide_height_; | 89 float top_controls_hide_height_; |
93 | 90 |
94 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); | 91 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); |
95 }; | 92 }; |
96 | 93 |
97 } // namespace cc | 94 } // namespace cc |
98 | 95 |
99 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ | 96 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ |
OLD | NEW |