| 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 <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "cc/input/top_controls_state.h" | 12 #include "cc/input/top_controls_state.h" |
| 12 #include "cc/layers/layer_impl.h" | 13 #include "cc/layers/layer_impl.h" |
| 13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/gfx/geometry/vector2d_f.h" | 15 #include "ui/gfx/geometry/vector2d_f.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class TimeTicks; | 18 class TimeTicks; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 | 22 |
| 22 class KeyframedFloatAnimationCurve; | 23 class KeyframedFloatAnimationCurve; |
| 23 class LayerTreeImpl; | 24 class LayerTreeImpl; |
| 24 class TopControlsManagerClient; | 25 class TopControlsManagerClient; |
| 25 | 26 |
| 26 // Manages the position of the top controls. | 27 // Manages the position of the top controls. |
| 27 class CC_EXPORT TopControlsManager | 28 class CC_EXPORT TopControlsManager |
| 28 : public base::SupportsWeakPtr<TopControlsManager> { | 29 : public base::SupportsWeakPtr<TopControlsManager> { |
| 29 public: | 30 public: |
| 30 enum AnimationDirection { | 31 enum AnimationDirection { |
| 31 NO_ANIMATION, | 32 NO_ANIMATION, |
| 32 SHOWING_CONTROLS, | 33 SHOWING_CONTROLS, |
| 33 HIDING_CONTROLS | 34 HIDING_CONTROLS |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 static scoped_ptr<TopControlsManager> Create( | 37 static std::unique_ptr<TopControlsManager> Create( |
| 37 TopControlsManagerClient* client, | 38 TopControlsManagerClient* client, |
| 38 float top_controls_show_threshold, | 39 float top_controls_show_threshold, |
| 39 float top_controls_hide_threshold); | 40 float top_controls_hide_threshold); |
| 40 virtual ~TopControlsManager(); | 41 virtual ~TopControlsManager(); |
| 41 | 42 |
| 42 float ControlsTopOffset() const; | 43 float ControlsTopOffset() const; |
| 43 float ContentTopOffset() const; | 44 float ContentTopOffset() const; |
| 44 float TopControlsShownRatio() const; | 45 float TopControlsShownRatio() const; |
| 45 float TopControlsHeight() const; | 46 float TopControlsHeight() const; |
| 46 | 47 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 72 private: | 73 private: |
| 73 void ResetAnimations(); | 74 void ResetAnimations(); |
| 74 void SetupAnimation(AnimationDirection direction); | 75 void SetupAnimation(AnimationDirection direction); |
| 75 void StartAnimationIfNecessary(); | 76 void StartAnimationIfNecessary(); |
| 76 bool IsAnimationComplete(float new_ratio); | 77 bool IsAnimationComplete(float new_ratio); |
| 77 void ResetBaseline(); | 78 void ResetBaseline(); |
| 78 | 79 |
| 79 TopControlsManagerClient* client_; // The client manages the lifecycle of | 80 TopControlsManagerClient* client_; // The client manages the lifecycle of |
| 80 // this. | 81 // this. |
| 81 | 82 |
| 82 scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; | 83 std::unique_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; |
| 83 AnimationDirection animation_direction_; | 84 AnimationDirection animation_direction_; |
| 84 TopControlsState permitted_state_; | 85 TopControlsState permitted_state_; |
| 85 | 86 |
| 86 // Accumulated scroll delta since last baseline reset | 87 // Accumulated scroll delta since last baseline reset |
| 87 float accumulated_scroll_delta_; | 88 float accumulated_scroll_delta_; |
| 88 | 89 |
| 89 // Content offset when last baseline reset occurred | 90 // Content offset when last baseline reset occurred |
| 90 float baseline_content_offset_; | 91 float baseline_content_offset_; |
| 91 | 92 |
| 92 // The percent height of the visible top control such that it must be shown | 93 // The percent height of the visible top control such that it must be shown |
| 93 // when the user stops the scroll. | 94 // when the user stops the scroll. |
| 94 float top_controls_show_threshold_; | 95 float top_controls_show_threshold_; |
| 95 | 96 |
| 96 // The percent height of the visible top control such that it must be hidden | 97 // The percent height of the visible top control such that it must be hidden |
| 97 // when the user stops the scroll. | 98 // when the user stops the scroll. |
| 98 float top_controls_hide_threshold_; | 99 float top_controls_hide_threshold_; |
| 99 | 100 |
| 100 bool pinch_gesture_active_; | 101 bool pinch_gesture_active_; |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); | 103 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 } // namespace cc | 106 } // namespace cc |
| 106 | 107 |
| 107 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ | 108 #endif // CC_INPUT_TOP_CONTROLS_MANAGER_H_ |
| OLD | NEW |