diff options
author | sidchat@chromium.org <sidchat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 23:40:55 +0000 |
---|---|---|
committer | sidchat@chromium.org <sidchat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 23:40:55 +0000 |
commit | f8eb092c6e7820bc484ed08a7b8e8f78745180ef (patch) | |
tree | 3068a30d307e2177896d83069a8cf360096981b8 /chrome/browser/views | |
parent | 9808ca4e09f14c674584ab82e6c9cb85abab610f (diff) | |
download | chromium_src-f8eb092c6e7820bc484ed08a7b8e8f78745180ef.zip chromium_src-f8eb092c6e7820bc484ed08a7b8e8f78745180ef.tar.gz chromium_src-f8eb092c6e7820bc484ed08a7b8e8f78745180ef.tar.bz2 |
Part 3 of 'Polish dragging of ToolStrips': Restrict the horizontal and vertical motions of the toolstrips so that they cannot be dragged out of the extension shelf.
BUG=www.crbug.com/18443
TEST=none
Review URL: http://codereview.chromium.org/251004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/extensions/extension_shelf.cc | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/chrome/browser/views/extensions/extension_shelf.cc b/chrome/browser/views/extensions/extension_shelf.cc index 10ce48d..83ea7d1 100644 --- a/chrome/browser/views/extensions/extension_shelf.cc +++ b/chrome/browser/views/extensions/extension_shelf.cc @@ -30,6 +30,11 @@ namespace { +// This is the slight padding that is there around the edge of the browser. This +// has been determined empirically. +// TODO(sidchat): Compute this value from the root view of the extension shelf. +static const int kExtensionShelfPaddingOnLeft = 4; + // Margins around the content. static const int kTopMarginWhenExtensionsOnTop = 1; static const int kTopMarginWhenExtensionsOnBottom = 2; @@ -177,10 +182,6 @@ class ExtensionShelf::Toolstrip : public views::View, virtual void AnimationEnded(const Animation* animation); private: - // The threshold for not tearing the ToolStrip from the Extension Shelf during - // click-and-drag the handle. - int GetVerticalTearFromShelfThreshold(); - // The actual renderer that this toolstrip contains. ExtensionHost* host_; @@ -369,15 +370,22 @@ bool ExtensionShelf::Toolstrip::OnMouseDragged(const views::MouseEvent& event) { // so we need to convert it back to local coordinates. gfx::Point origin(0, 0); views::View::ConvertPointToScreen(shelf_->GetRootView(), &origin); - screen.set_x(screen.x() - origin.x() - initial_drag_location_.x()); - - // Restrict the movement to horizontal unless vertical mouse drag exceeds a - // threshold. - int screen_y = initial_drag_screen_point_.y(); - if (abs(screen_y - screen.y()) > GetVerticalTearFromShelfThreshold()) { - screen_y = screen.y(); + int screen_x = screen.x() - initial_drag_location_.x() - origin.x(); + + // Restrict the horizontal and vertical motions of the toolstrip so that it + // cannot be dragged out of the extension shelf. If the extension shelf is + // on the top along with the bookmark bar, the toolstrip cannot be dragged + // into the space allocated for bookmarks. The toolstrip cannot be dragged + // out of the browser window. + if (screen_x < kExtensionShelfPaddingOnLeft) { + screen_x = kExtensionShelfPaddingOnLeft; + } else if (screen_x > shelf_->width() - width() + + kExtensionShelfPaddingOnLeft) { + screen_x = shelf_->width() - width() + kExtensionShelfPaddingOnLeft; } - screen.set_y(screen_y - origin.y() - initial_drag_location_.y()); + screen.set_x(screen_x); + screen.set_y(initial_drag_screen_point_.y() - origin.y() - + initial_drag_location_.y()); // TODO(erikkay) as this gets dragged around, update the placeholder view // on the shelf to show where it will get dropped to. @@ -497,11 +505,6 @@ void ExtensionShelf::Toolstrip::AnimationEnded(const Animation* animation) { } } -int ExtensionShelf::Toolstrip::GetVerticalTearFromShelfThreshold() { - // TODO(sidchat): Compute this value from the toolstrip height. - return 29; -} - void ExtensionShelf::Toolstrip::DetachFromShelf(bool browserDetach) { DCHECK(window_.get()); DCHECK(!placeholder_view_); |