| 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/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
| 11 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
| 12 #include "ui/gfx/vector2d_f.h" | 13 #include "ui/gfx/vector2d_f.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class TimeTicks; | 16 class TimeTicks; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 | 20 |
| 20 class KeyframedFloatAnimationCurve; | 21 class KeyframedFloatAnimationCurve; |
| 21 class LayerTreeImpl; | 22 class LayerTreeImpl; |
| 22 class TopControlsManagerClient; | 23 class TopControlsManagerClient; |
| 23 | 24 |
| 24 // Manages the position of the top controls. | 25 // Manages the position of the top controls. |
| 25 class CC_EXPORT TopControlsManager | 26 class CC_EXPORT TopControlsManager |
| 26 : public base::SupportsWeakPtr<TopControlsManager> { | 27 : public base::SupportsWeakPtr<TopControlsManager> { |
| 27 public: | 28 public: |
| 28 enum AnimationDirection { | 29 enum AnimationDirection { |
| 29 NO_ANIMATION, | 30 NO_ANIMATION, |
| 30 SHOWING_CONTROLS, | 31 SHOWING_CONTROLS, |
| 31 HIDING_CONTROLS | 32 HIDING_CONTROLS |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 enum VisibilityRestriction { | |
| 35 ALWAYS_SHOWN, | |
| 36 ALWAYS_HIDDEN, | |
| 37 NONE | |
| 38 }; | |
| 39 | |
| 40 static scoped_ptr<TopControlsManager> Create( | 35 static scoped_ptr<TopControlsManager> Create( |
| 41 TopControlsManagerClient* client, | 36 TopControlsManagerClient* client, |
| 42 float top_controls_height, | 37 float top_controls_height, |
| 43 float top_controls_show_threshold, | 38 float top_controls_show_threshold, |
| 44 float top_controls_hide_threshold); | 39 float top_controls_hide_threshold); |
| 45 virtual ~TopControlsManager(); | 40 virtual ~TopControlsManager(); |
| 46 | 41 |
| 47 float controls_top_offset() { return controls_top_offset_; } | 42 float controls_top_offset() { return controls_top_offset_; } |
| 48 float content_top_offset() { | 43 float content_top_offset() { |
| 49 return controls_top_offset_ + top_controls_height_; | 44 return controls_top_offset_ + top_controls_height_; |
| 50 } | 45 } |
| 51 KeyframedFloatAnimationCurve* animation() { | 46 KeyframedFloatAnimationCurve* animation() { |
| 52 return top_controls_animation_.get(); | 47 return top_controls_animation_.get(); |
| 53 } | 48 } |
| 54 AnimationDirection animation_direction() { return animation_direction_; } | 49 AnimationDirection animation_direction() { return animation_direction_; } |
| 55 | 50 |
| 56 void UpdateTopControlsState(bool enable_hiding, | 51 void UpdateTopControlsState(TopControlsState constraints, |
| 57 bool enable_showing, | 52 TopControlsState current, |
| 58 bool animate); | 53 bool animate); |
| 59 | 54 |
| 60 void ScrollBegin(); | 55 void ScrollBegin(); |
| 61 gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); | 56 gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); |
| 62 void ScrollEnd(); | 57 void ScrollEnd(); |
| 63 | 58 |
| 64 gfx::Vector2dF Animate(base::TimeTicks monotonic_time); | 59 gfx::Vector2dF Animate(base::TimeTicks monotonic_time); |
| 65 | 60 |
| 66 protected: | 61 protected: |
| 67 TopControlsManager(TopControlsManagerClient* client, | 62 TopControlsManager(TopControlsManagerClient* client, |
| 68 float top_controls_height, | 63 float top_controls_height, |
| 69 float top_controls_show_threshold, | 64 float top_controls_show_threshold, |
| 70 float top_controls_hide_threshold); | 65 float top_controls_hide_threshold); |
| 71 | 66 |
| 72 private: | 67 private: |
| 73 void SetControlsTopOffset(float offset); | 68 void SetControlsTopOffset(float offset); |
| 74 void ResetAnimations(); | 69 void ResetAnimations(); |
| 75 void SetupAnimation(AnimationDirection direction); | 70 void SetupAnimation(AnimationDirection direction); |
| 76 void StartAnimationIfNecessary(); | 71 void StartAnimationIfNecessary(); |
| 77 bool IsAnimationCompleteAtTime(base::TimeTicks time); | 72 bool IsAnimationCompleteAtTime(base::TimeTicks time); |
| 78 | 73 |
| 79 TopControlsManagerClient* client_; // The client manages the lifecycle of | 74 TopControlsManagerClient* client_; // The client manages the lifecycle of |
| 80 // this. | 75 // this. |
| 81 | 76 |
| 82 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; | 77 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; |
| 83 AnimationDirection animation_direction_; | 78 AnimationDirection animation_direction_; |
| 84 VisibilityRestriction visibility_restriction_; | 79 TopControlsState permitted_state_; |
| 85 float controls_top_offset_; | 80 float controls_top_offset_; |
| 86 float top_controls_height_; | 81 float top_controls_height_; |
| 87 | 82 |
| 88 float current_scroll_delta_; | 83 float current_scroll_delta_; |
| 89 float controls_scroll_begin_offset_; | 84 float controls_scroll_begin_offset_; |
| 90 | 85 |
| 91 // The height of the visible top control such that it must be shown when | 86 // The height of the visible top control such that it must be shown when |
| 92 // the user stops the scroll. | 87 // the user stops the scroll. |
| 93 float top_controls_show_height_; | 88 float top_controls_show_height_; |
| 94 | 89 |
| 95 // The height of the visible top control such that it must be hidden when | 90 // The height of the visible top control such that it must be hidden when |
| 96 // the user stops the scroll. | 91 // the user stops the scroll. |
| 97 float top_controls_hide_height_; | 92 float top_controls_hide_height_; |
| 98 | 93 |
| 99 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); | 94 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); |
| 100 }; | 95 }; |
| 101 | 96 |
| 102 } // namespace cc | 97 } // namespace cc |
| 103 | 98 |
| 104 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ | 99 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ |
| OLD | NEW |