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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 SHOWING_CONTROLS, | 31 SHOWING_CONTROLS, |
32 HIDING_CONTROLS | 32 HIDING_CONTROLS |
33 }; | 33 }; |
34 | 34 |
35 static scoped_ptr<TopControlsManager> Create( | 35 static scoped_ptr<TopControlsManager> Create( |
36 TopControlsManagerClient* client, | 36 TopControlsManagerClient* client, |
37 float top_controls_show_threshold, | 37 float top_controls_show_threshold, |
38 float top_controls_hide_threshold); | 38 float top_controls_hide_threshold); |
39 virtual ~TopControlsManager(); | 39 virtual ~TopControlsManager(); |
40 | 40 |
41 float ControlsTopOffset(); | 41 float ControlsTopOffset() const; |
42 float ContentTopOffset(); | 42 float ContentTopOffset() const; |
| 43 float TopControlsShownRatio() const; |
| 44 float TopControlsHeight() const; |
43 | 45 |
44 KeyframedFloatAnimationCurve* animation() { | 46 KeyframedFloatAnimationCurve* animation() { |
45 return top_controls_animation_.get(); | 47 return top_controls_animation_.get(); |
46 } | 48 } |
47 AnimationDirection animation_direction() { return animation_direction_; } | 49 AnimationDirection animation_direction() { return animation_direction_; } |
48 | 50 |
49 void UpdateTopControlsState(TopControlsState constraints, | 51 void UpdateTopControlsState(TopControlsState constraints, |
50 TopControlsState current, | 52 TopControlsState current, |
51 bool animate); | 53 bool animate); |
52 | 54 |
53 void ScrollBegin(); | 55 void ScrollBegin(); |
54 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& pending_delta); | 56 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& pending_delta); |
55 void ScrollEnd(); | 57 void ScrollEnd(); |
56 | 58 |
57 // The caller should ensure that |Pinch{Begin,End}| are called within | 59 // The caller should ensure that |Pinch{Begin,End}| are called within |
58 // the scope of |Scroll{Begin,End}|. | 60 // the scope of |Scroll{Begin,End}|. |
59 void PinchBegin(); | 61 void PinchBegin(); |
60 void PinchEnd(); | 62 void PinchEnd(); |
61 | 63 |
62 gfx::Vector2dF Animate(base::TimeTicks monotonic_time); | 64 gfx::Vector2dF Animate(base::TimeTicks monotonic_time); |
63 void SetControlsTopOffset(float offset); | |
64 void SetTopControlsHeight(float top_controls_height); | |
65 float top_controls_height() { return top_controls_height_; } | |
66 | 65 |
67 protected: | 66 protected: |
68 TopControlsManager(TopControlsManagerClient* client, | 67 TopControlsManager(TopControlsManagerClient* client, |
69 float top_controls_show_threshold, | 68 float top_controls_show_threshold, |
70 float top_controls_hide_threshold); | 69 float top_controls_hide_threshold); |
71 | 70 |
72 private: | 71 private: |
73 void ResetAnimations(); | 72 void ResetAnimations(); |
74 void SetupAnimation(AnimationDirection direction); | 73 void SetupAnimation(AnimationDirection direction); |
75 void StartAnimationIfNecessary(); | 74 void StartAnimationIfNecessary(); |
76 bool IsAnimationCompleteAtTime(base::TimeTicks time); | 75 bool IsAnimationCompleteAtTime(base::TimeTicks time); |
77 | 76 |
78 TopControlsManagerClient* client_; // The client manages the lifecycle of | 77 TopControlsManagerClient* client_; // The client manages the lifecycle of |
79 // this. | 78 // this. |
80 | 79 |
81 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; | 80 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; |
82 AnimationDirection animation_direction_; | 81 AnimationDirection animation_direction_; |
83 TopControlsState permitted_state_; | 82 TopControlsState permitted_state_; |
84 float top_controls_height_; | |
85 | 83 |
86 float current_scroll_delta_; | 84 float current_scroll_delta_; |
87 float controls_scroll_begin_offset_; | 85 float controls_scroll_begin_offset_; |
88 | 86 |
89 // The percent height of the visible top control such that it must be shown | 87 // The percent height of the visible top control such that it must be shown |
90 // when the user stops the scroll. | 88 // when the user stops the scroll. |
91 float top_controls_show_threshold_; | 89 float top_controls_show_threshold_; |
92 | 90 |
93 // The percent height of the visible top control such that it must be hidden | 91 // The percent height of the visible top control such that it must be hidden |
94 // when the user stops the scroll. | 92 // when the user stops the scroll. |
95 float top_controls_hide_threshold_; | 93 float top_controls_hide_threshold_; |
96 | 94 |
97 bool pinch_gesture_active_; | 95 bool pinch_gesture_active_; |
98 | 96 |
99 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); | 97 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); |
100 }; | 98 }; |
101 | 99 |
102 } // namespace cc | 100 } // namespace cc |
103 | 101 |
104 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ | 102 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ |
OLD | NEW |