diff options
author | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-24 04:25:57 +0000 |
---|---|---|
committer | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-24 04:25:57 +0000 |
commit | 7d1d2d2d903bbab245d6db3dde70f60e1bea7b51 (patch) | |
tree | eacfd7ddd652b1b989cd0131753867865e3ffb38 /ash | |
parent | e8989219fa51bf06da3f9fa65ed2b972af15d9d7 (diff) | |
download | chromium_src-7d1d2d2d903bbab245d6db3dde70f60e1bea7b51.zip chromium_src-7d1d2d2d903bbab245d6db3dde70f60e1bea7b51.tar.gz chromium_src-7d1d2d2d903bbab245d6db3dde70f60e1bea7b51.tar.bz2 |
Shelf Gesture Tearing
Adjust shelf positioning/sizing during bezel gesture to avoid tearing (gap between shelf and the edge of display).
BUG=195983, 222391
TEST=Visual
Review URL: https://chromiumcodereview.appspot.com/12825015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190186 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/shelf/shelf_layout_manager.cc | 72 |
1 files changed, 29 insertions, 43 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 56c50a4..1a11cb6 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -713,6 +713,7 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( TargetBounds* target_bounds) const { CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_); bool horizontal = IsHorizontalAlignment(); + const gfx::Rect& available_bounds(root_window_->bounds()); int resistance_free_region = 0; if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && @@ -722,10 +723,7 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( // changed since then, e.g. because the tray-menu was shown because of the // drag), then allow the drag some resistance-free region at first to make // sure the shelf sticks with the finger until the shelf is visible. - resistance_free_region += horizontal ? - target_bounds->shelf_bounds_in_root.height() : - target_bounds->shelf_bounds_in_root.width(); - resistance_free_region -= kAutoHideSize; + resistance_free_region = kLauncherPreferredSize - kAutoHideSize; } bool resist = SelectValueForShelfAlignment( @@ -747,51 +745,39 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( } if (horizontal) { - // Move the launcher with the gesture. - target_bounds->shelf_bounds_in_root.Offset(0, translate); - - if (translate < 0) { - // When dragging up, the launcher height should increase. - float move = std::max(translate, - -static_cast<float>(resistance_free_region)); + // Move and size the launcher with the gesture. + if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { + target_bounds->shelf_bounds_in_root.Offset(0, translate); target_bounds->shelf_bounds_in_root.set_height( - target_bounds->shelf_bounds_in_root.height() + move - translate); - - // The statusbar should be in the center. - gfx::Rect status_y = target_bounds->shelf_bounds_in_root; - status_y.ClampToCenteredSize( - target_bounds->status_bounds_in_shelf.size()); - target_bounds->status_bounds_in_shelf.set_y(status_y.y()); + available_bounds.bottom() - target_bounds->shelf_bounds_in_root.y()); + } else { + target_bounds->shelf_bounds_in_root.set_height( + target_bounds->shelf_bounds_in_root.height() + translate); } + + // The statusbar should be in the center of the shelf. + gfx::Rect status_y = target_bounds->shelf_bounds_in_root; + status_y.set_y(0); + status_y.ClampToCenteredSize( + target_bounds->status_bounds_in_shelf.size()); + target_bounds->status_bounds_in_shelf.set_y(status_y.y()); } else { - // Move the launcher with the gesture. - if (alignment_ == SHELF_ALIGNMENT_RIGHT) + // Move and size the launcher with the gesture. + if (alignment_ == SHELF_ALIGNMENT_RIGHT) { target_bounds->shelf_bounds_in_root.Offset(translate, 0); - - if ((translate > 0 && alignment_ == SHELF_ALIGNMENT_RIGHT) || - (translate < 0 && alignment_ == SHELF_ALIGNMENT_LEFT)) { - // When dragging towards the edge, the statusbar should move. - target_bounds->status_bounds_in_shelf.Offset(translate, 0); + target_bounds->shelf_bounds_in_root.set_width( + available_bounds.right() - target_bounds->shelf_bounds_in_root.x()); } else { - // When dragging away from the edge, the launcher width should increase. - float move = alignment_ == SHELF_ALIGNMENT_RIGHT ? - std::max(translate, -static_cast<float>(resistance_free_region)) : - std::min(translate, static_cast<float>(resistance_free_region)); - - if (alignment_ == SHELF_ALIGNMENT_RIGHT) { - target_bounds->shelf_bounds_in_root.set_width( - target_bounds->shelf_bounds_in_root.width() + move - translate); - } else { - target_bounds->shelf_bounds_in_root.set_width( - target_bounds->shelf_bounds_in_root.width() - move + translate); - } - - // The statusbar should be in the center. - gfx::Rect status_x = target_bounds->shelf_bounds_in_root; - status_x.ClampToCenteredSize( - target_bounds->status_bounds_in_shelf.size()); - target_bounds->status_bounds_in_shelf.set_x(status_x.x()); + target_bounds->shelf_bounds_in_root.set_width( + target_bounds->shelf_bounds_in_root.width() + translate); } + + // The statusbar should be in the center of the shelf. + gfx::Rect status_x = target_bounds->shelf_bounds_in_root; + status_x.set_x(0); + status_x.ClampToCenteredSize( + target_bounds->status_bounds_in_shelf.size()); + target_bounds->status_bounds_in_shelf.set_x(status_x.x()); } } |