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