diff options
author | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-28 21:24:38 +0000 |
---|---|---|
committer | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-28 21:24:38 +0000 |
commit | 452b4a958d55f8824b0ca9a1397249bfe95ebff3 (patch) | |
tree | ad06ad800b78ce2bc615ec3ec33a857bc8c4b7b5 /cc | |
parent | 5b69cca2604690eea480d22aeb08687c7b990a65 (diff) | |
download | chromium_src-452b4a958d55f8824b0ca9a1397249bfe95ebff3.zip chromium_src-452b4a958d55f8824b0ca9a1397249bfe95ebff3.tar.gz chromium_src-452b4a958d55f8824b0ca9a1397249bfe95ebff3.tar.bz2 |
Enable hiding/showing top controls persistently
Pass down to the renderer whether or not we should allow showing the fullscreen controls
as well as hiding.
BUG=161303
Review URL: https://chromiumcodereview.appspot.com/12954003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/input/top_controls_manager.cc | 33 | ||||
-rw-r--r-- | cc/input/top_controls_manager.h | 12 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 11 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 4 |
4 files changed, 46 insertions, 14 deletions
diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc index e1698f1..343dd3c 100644 --- a/cc/input/top_controls_manager.cc +++ b/cc/input/top_controls_manager.cc @@ -40,7 +40,7 @@ TopControlsManager::TopControlsManager(TopControlsManagerClient* client, float top_controls_hide_threshold) : client_(client), animation_direction_(NO_ANIMATION), - enable_hiding_(true), + visibility_restriction_(NONE), controls_top_offset_(0.f), top_controls_height_(top_controls_height), current_scroll_delta_(0.f), @@ -55,15 +55,30 @@ TopControlsManager::TopControlsManager(TopControlsManagerClient* client, TopControlsManager::~TopControlsManager() { } -void TopControlsManager::EnableHidingTopControls(bool enable) { - enable_hiding_ = enable; +void TopControlsManager::UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate) { + float final_controls_position = 0.f; + + if (enable_hiding && enable_showing) { + visibility_restriction_ = NONE; + } else if (enable_showing || !enable_hiding) { + visibility_restriction_ = ALWAYS_SHOWN; + } else { + visibility_restriction_ = ALWAYS_HIDDEN; + final_controls_position = -top_controls_height_; + } - if (!enable) { + if (visibility_restriction_ != NONE && + final_controls_position != controls_top_offset_) { ResetAnimations(); - if (controls_top_offset_ != 0) { - SetupAnimation(SHOWING_CONTROLS); - client_->setNeedsRedraw(); + if (animate) { + SetupAnimation(visibility_restriction_ == ALWAYS_SHOWN ? + SHOWING_CONTROLS : HIDING_CONTROLS); + } else { + controls_top_offset_ = final_controls_position; } + client_->setNeedsRedraw(); } } @@ -75,7 +90,9 @@ void TopControlsManager::ScrollBegin() { gfx::Vector2dF TopControlsManager::ScrollBy( const gfx::Vector2dF pending_delta) { - if (!enable_hiding_ && pending_delta.y() > 0) + if (visibility_restriction_ == ALWAYS_SHOWN && pending_delta.y() > 0) + return pending_delta; + else if (visibility_restriction_ == ALWAYS_HIDDEN && pending_delta.y() < 0) return pending_delta; current_scroll_delta_ += pending_delta.y(); diff --git a/cc/input/top_controls_manager.h b/cc/input/top_controls_manager.h index 59289f6..78ccf80 100644 --- a/cc/input/top_controls_manager.h +++ b/cc/input/top_controls_manager.h @@ -31,6 +31,12 @@ class CC_EXPORT TopControlsManager HIDING_CONTROLS }; + enum VisibilityRestriction { + ALWAYS_SHOWN, + ALWAYS_HIDDEN, + NONE + }; + static scoped_ptr<TopControlsManager> Create( TopControlsManagerClient* client, float top_controls_height, @@ -47,7 +53,9 @@ class CC_EXPORT TopControlsManager } AnimationDirection animation_direction() { return animation_direction_; } - void EnableHidingTopControls(bool enable); + void UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate); void ScrollBegin(); gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); @@ -73,7 +81,7 @@ class CC_EXPORT TopControlsManager scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; AnimationDirection animation_direction_; - bool enable_hiding_; + VisibilityRestriction visibility_restriction_; float controls_top_offset_; float top_controls_height_; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 75b6118..c98c81b 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -983,13 +983,18 @@ void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { SetNeedsCommit(); } -void LayerTreeHost::EnableHidingTopControls(bool enable) { +void LayerTreeHost::UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate) { if (!settings_.calculate_top_controls_position) return; proxy_->ImplThread()->PostTask( - base::Bind(&TopControlsManager::EnableHidingTopControls, - top_controls_manager_weak_ptr_, enable)); + base::Bind(&TopControlsManager::UpdateTopControlsState, + top_controls_manager_weak_ptr_, + enable_hiding, + enable_showing, + animate)); } bool LayerTreeHost::BlocksPendingCommit() const { diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 220cbb5..b412dab 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -224,7 +224,9 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { void SetDeviceScaleFactor(float device_scale_factor); float device_scale_factor() const { return device_scale_factor_; } - void EnableHidingTopControls(bool enable); + void UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate); HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } |