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_TOP_CONTROLS_MANAGER_H_ | 5 #ifndef CC_TOP_CONTROLS_MANAGER_H_ |
6 #define CC_TOP_CONTROLS_MANAGER_H_ | 6 #define CC_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/layer_impl.h" | 10 #include "cc/layer_impl.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 // Manages the position of the top controls. | 24 // Manages the position of the top controls. |
25 class CC_EXPORT TopControlsManager { | 25 class CC_EXPORT TopControlsManager { |
26 public: | 26 public: |
27 enum AnimationDirection { | 27 enum AnimationDirection { |
28 NO_ANIMATION, | 28 NO_ANIMATION, |
29 SHOWING_CONTROLS, | 29 SHOWING_CONTROLS, |
30 HIDING_CONTROLS | 30 HIDING_CONTROLS |
31 }; | 31 }; |
32 | 32 |
33 static scoped_ptr<TopControlsManager> Create(TopControlsManagerClient* client, | 33 static scoped_ptr<TopControlsManager> Create( |
34 float top_controls_height); | 34 TopControlsManagerClient* client, |
| 35 float top_controls_height, |
| 36 float top_controls_show_threshold, |
| 37 float top_controls_hide_threshold); |
35 virtual ~TopControlsManager(); | 38 virtual ~TopControlsManager(); |
36 | 39 |
37 float controls_top_offset() { return controls_top_offset_; } | 40 float controls_top_offset() { return controls_top_offset_; } |
38 float content_top_offset() { return content_top_offset_; } | 41 float content_top_offset() { return content_top_offset_; } |
39 KeyframedFloatAnimationCurve* animation() { | 42 KeyframedFloatAnimationCurve* animation() { |
40 return top_controls_animation_.get(); | 43 return top_controls_animation_.get(); |
41 } | 44 } |
42 AnimationDirection animation_direction() { return animation_direction_; } | 45 AnimationDirection animation_direction() { return animation_direction_; } |
43 | 46 |
44 void ScrollBegin(); | 47 void ScrollBegin(); |
45 gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); | 48 gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); |
46 void ScrollEnd(); | 49 void ScrollEnd(); |
47 | 50 |
48 void Animate(base::TimeTicks monotonic_time); | 51 void Animate(base::TimeTicks monotonic_time); |
49 | 52 |
50 protected: | 53 protected: |
51 TopControlsManager(TopControlsManagerClient* client, | 54 TopControlsManager(TopControlsManagerClient* client, |
52 float top_controls_height); | 55 float top_controls_height, |
| 56 float top_controls_show_threshold, |
| 57 float top_controls_hide_threshold); |
53 | 58 |
54 private: | 59 private: |
55 gfx::Vector2dF ScrollInternal(const gfx::Vector2dF pending_delta); | 60 gfx::Vector2dF ScrollInternal(const gfx::Vector2dF pending_delta); |
56 void ResetAnimations(); | 61 void ResetAnimations(); |
57 float RootScrollLayerTotalScrollY(); | 62 float RootScrollLayerTotalScrollY(); |
58 void SetupAnimation(AnimationDirection direction); | 63 void SetupAnimation(AnimationDirection direction); |
59 void StartAnimationIfNecessary(); | 64 void StartAnimationIfNecessary(); |
60 bool IsAnimationCompleteAtTime(base::TimeTicks time); | 65 bool IsAnimationCompleteAtTime(base::TimeTicks time); |
61 | 66 |
62 TopControlsManagerClient* client_; // The client manages the lifecycle of | 67 TopControlsManagerClient* client_; // The client manages the lifecycle of |
63 // this. | 68 // this. |
64 | 69 |
65 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; | 70 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; |
66 AnimationDirection animation_direction_; | 71 AnimationDirection animation_direction_; |
67 bool in_scroll_gesture_; | 72 bool in_scroll_gesture_; |
68 float controls_top_offset_; | 73 float controls_top_offset_; |
69 float content_top_offset_; | 74 float content_top_offset_; |
70 float top_controls_height_; | 75 float top_controls_height_; |
71 float previous_root_scroll_offset_; | 76 float previous_root_scroll_offset_; |
72 float scroll_start_offset_; | 77 float scroll_start_offset_; |
| 78 float current_scroll_delta_; |
| 79 |
| 80 // The height of the visible top control such that it must be shown when |
| 81 // the user stops the scroll. |
| 82 float top_controls_show_height_; |
| 83 |
| 84 // The height of the visible top control such that it must be hidden when |
| 85 // the user stops the scroll. |
| 86 float top_controls_hide_height_; |
73 | 87 |
74 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); | 88 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); |
75 }; | 89 }; |
76 | 90 |
77 } // namespace cc | 91 } // namespace cc |
78 | 92 |
79 #endif // CC_TOP_CONTROLS_MANAGER_H_ | 93 #endif // CC_TOP_CONTROLS_MANAGER_H_ |
OLD | NEW |