OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_TOP_CONTROLS_MANAGER_H_ |
| 6 #define CC_TOP_CONTROLS_MANAGER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/timer.h" |
| 11 #include "cc/layer_impl.h" |
| 12 #include "ui/gfx/size.h" |
| 13 #include "ui/gfx/vector2d_f.h" |
| 14 |
| 15 namespace base { |
| 16 class TimeTicks; |
| 17 } |
| 18 |
| 19 namespace cc { |
| 20 |
| 21 class LayerTreeImpl; |
| 22 class TopControlsAnimation; |
| 23 class TopControlsManagerClient; |
| 24 |
| 25 // Manages the position of the top controls. |
| 26 class TopControlsManager { |
| 27 public: |
| 28 static scoped_ptr<TopControlsManager> Create(TopControlsManagerClient* client, |
| 29 float top_controls_height); |
| 30 virtual ~TopControlsManager(); |
| 31 |
| 32 float controls_top_offset() { return controls_top_offset_; } |
| 33 float content_top_offset() { return content_top_offset_; } |
| 34 float is_overlay_mode() { return is_overlay_mode_; } |
| 35 TopControlsAnimation* animation() { return top_controls_animation_.get(); } |
| 36 |
| 37 void UpdateDrawPositions(); |
| 38 |
| 39 void ScrollBegin(); |
| 40 gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); |
| 41 void ScrollEnd(); |
| 42 |
| 43 void Animate(base::TimeTicks monotonic_time); |
| 44 |
| 45 protected: |
| 46 TopControlsManager(TopControlsManagerClient* client, |
| 47 float top_controls_height); |
| 48 |
| 49 private: |
| 50 gfx::Vector2dF ScrollInternal(const gfx::Vector2dF pending_delta); |
| 51 void ResetAnimations(); |
| 52 LayerImpl* RootScrollLayer(); |
| 53 float RootScrollLayerTotalScrollY(); |
| 54 void StartAnimationIfNecessary(); |
| 55 void StartAutoHideAnimation(); |
| 56 |
| 57 TopControlsManagerClient* client_; // The client manages the lifecycle of |
| 58 // this. |
| 59 |
| 60 base::OneShotTimer<TopControlsManager> auto_hide_timer_; |
| 61 scoped_ptr<TopControlsAnimation> top_controls_animation_; |
| 62 bool is_overlay_mode_; |
| 63 float controls_top_offset_; |
| 64 float content_top_offset_; |
| 65 float top_controls_height_; |
| 66 bool scroll_readjustment_enabled_; |
| 67 float previous_root_scroll_offset_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(TopControlsManager); |
| 70 }; |
| 71 |
| 72 } // namespace cc |
| 73 |
| 74 #endif // CC_TOP_CONTROLS_MANAGER_H_ |
OLD | NEW |