Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3094)

Unified Diff: cc/top_controls_manager.cc

Issue 12210050: Expose FS show/hide thresholds to Command Line (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/top_controls_manager.cc
diff --git a/cc/top_controls_manager.cc b/cc/top_controls_manager.cc
index c75797dae2791232b71b9dbe2dbfe0ce9b1b481f..4dd80a8f13c1f41a2efbcebf5ac216d6f7aee789 100644
--- a/cc/top_controls_manager.cc
+++ b/cc/top_controls_manager.cc
@@ -19,27 +19,37 @@ namespace cc {
namespace {
// These constants were chosen empirically for their visually pleasant behavior.
// Contact tedchoc@chromium.org for questions about changing these values.
-const float kShowHideThreshold = 0.5f;
const int64 kShowHideMaxDurationMs = 175;
}
// static
scoped_ptr<TopControlsManager> TopControlsManager::Create(
- TopControlsManagerClient* client, float top_controls_height) {
- return make_scoped_ptr(new TopControlsManager(client, top_controls_height));
+ TopControlsManagerClient* client,
+ float top_controls_height,
+ float top_controls_show_threshold,
+ float top_controls_hide_threshold) {
+ return make_scoped_ptr(new TopControlsManager(client,
+ top_controls_height,
+ top_controls_show_threshold,
+ top_controls_hide_threshold));
}
TopControlsManager::TopControlsManager(TopControlsManagerClient* client,
- float top_controls_height)
+ float top_controls_height,
+ float top_controls_show_threshold,
+ float top_controls_hide_threshold)
: client_(client),
animation_direction_(NO_ANIMATION),
+ top_controls_show_threshold_(top_controls_show_threshold),
+ top_controls_hide_threshold_(top_controls_hide_threshold),
is_overlay_mode_(false),
in_scroll_gesture_(false),
top_controls_height_(top_controls_height),
controls_top_offset_(0),
content_top_offset_(top_controls_height),
previous_root_scroll_offset_(0.f),
- scroll_start_offset_(0.f) {
+ scroll_start_offset_(0.f),
+ current_scroll_delta_(0.f) {
CHECK(client_);
}
@@ -65,6 +75,7 @@ void TopControlsManager::ScrollBegin() {
ResetAnimations();
in_scroll_gesture_ = true;
scroll_start_offset_ = RootScrollLayerTotalScrollY() + controls_top_offset_;
+ current_scroll_delta_ = 0.f;
}
gfx::Vector2dF TopControlsManager::ScrollBy(
@@ -72,6 +83,8 @@ gfx::Vector2dF TopControlsManager::ScrollBy(
if (pending_delta.y() == 0)
return pending_delta;
+ current_scroll_delta_ += pending_delta.y();
+
float scroll_total_y = RootScrollLayerTotalScrollY();
if (in_scroll_gesture_ &&
((pending_delta.y() > 0 && scroll_total_y < scroll_start_offset_) ||
@@ -136,6 +149,7 @@ void TopControlsManager::ScrollEnd() {
StartAnimationIfNecessary();
previous_root_scroll_offset_ = RootScrollLayerTotalScrollY();
in_scroll_gesture_ = false;
+ current_scroll_delta_ = 0.f;
}
void TopControlsManager::Animate(base::TimeTicks monotonic_time) {
@@ -180,14 +194,28 @@ void TopControlsManager::SetupAnimation(AnimationDirection direction) {
}
void TopControlsManager::StartAnimationIfNecessary() {
Ted C 2013/02/07 00:40:26 Can you add a unittest that verifies the new anima
David Trainor- moved to gerrit 2013/02/11 19:38:28 Done.
- float scroll_total_y = RootScrollLayerTotalScrollY();
-
if (controls_top_offset_ != 0
&& controls_top_offset_ != -top_controls_height_) {
- AnimationDirection show_controls =
- controls_top_offset_ >= -(top_controls_height_ * kShowHideThreshold) ?
- SHOWING_CONTROLS : HIDING_CONTROLS;
- if (!top_controls_animation_ || animation_direction_ != show_controls) {
+ AnimationDirection show_controls = NO_ANIMATION;
+
+ if (controls_top_offset_ >=
+ -(top_controls_height_ * top_controls_hide_threshold_)) {
Ted C 2013/02/07 00:40:26 Looking at this, should we initialize top_controls
David Trainor- moved to gerrit 2013/02/11 19:38:28 Done.
+ // If we're showing so much that the hide threshold won't trigger, show.
+ show_controls = SHOWING_CONTROLS;
+ } else if (controls_top_offset_ <=
+ -(top_controls_height_ * (1.f - top_controls_show_threshold_))) {
Ted C 2013/02/07 00:40:26 same for this?
David Trainor- moved to gerrit 2013/02/11 19:38:28 Done.
+ // If we're showing so little that the show threshold won't trigger, hide.
+ show_controls = HIDING_CONTROLS;
+ } else {
+ // If we could be either showing or hiding, we determine which one to
+ // do based on whether or not the total scroll delta was moving up or
+ // down.
+ show_controls = current_scroll_delta_ <= 0.f ?
+ SHOWING_CONTROLS : HIDING_CONTROLS;
+ }
+
+ if (show_controls != NO_ANIMATION &&
+ (!top_controls_animation_ || animation_direction_ != show_controls)) {
SetupAnimation(show_controls);
client_->setNeedsRedraw();
}

Powered by Google App Engine
This is Rietveld 408576698