summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsidchat@chromium.org <sidchat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 17:37:10 +0000
committersidchat@chromium.org <sidchat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 17:37:10 +0000
commitd3f90a831c595241492e0c92fdac1e2313f7d379 (patch)
tree85727435cbef77d9b92055b6da8f80b93d2b5892 /chrome
parentabd97e42913a8713d53c4361840022a4eaa74e8c (diff)
downloadchromium_src-d3f90a831c595241492e0c92fdac1e2313f7d379.zip
chromium_src-d3f90a831c595241492e0c92fdac1e2313f7d379.tar.gz
chromium_src-d3f90a831c595241492e0c92fdac1e2313f7d379.tar.bz2
Part 1 of 'Polish dragging of ToolStrips'. This CL restricts the motion of the ToolStrip to just horizontal motions until it is dragged far enough from the extension shelf, in which case it is torn away from it (similar to Tabs).
BUG=18443 TEST=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/extensions/extension_shelf.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/chrome/browser/views/extensions/extension_shelf.cc b/chrome/browser/views/extensions/extension_shelf.cc
index 3d2b42f..1530fd9 100644
--- a/chrome/browser/views/extensions/extension_shelf.cc
+++ b/chrome/browser/views/extensions/extension_shelf.cc
@@ -174,6 +174,10 @@ 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_;
@@ -208,6 +212,11 @@ class ExtensionShelf::Toolstrip : public views::View,
// If dragging, where did the drag start from.
gfx::Point initial_drag_location_;
+ // We have to remember the initial drag point in screen coordinates, because
+ // later, when the toolstrip is being dragged around, there is no good way of
+ // computing the screen coordinates given the initial drag view coordinates.
+ gfx::Point initial_drag_screen_point_;
+
// Timers for tracking mouse hovering.
ScopedRunnableMethodFactory<ExtensionShelf::Toolstrip> timer_factory_;
@@ -315,6 +324,7 @@ void ExtensionShelf::Toolstrip::OnMouseExited(const views::MouseEvent& event) {
bool ExtensionShelf::Toolstrip::OnMousePressed(const views::MouseEvent& event) {
initial_drag_location_ = event.location();
+ initial_drag_screen_point_ = views::Screen::GetCursorScreenPoint();
return true;
}
@@ -340,7 +350,14 @@ bool ExtensionShelf::Toolstrip::OnMouseDragged(const views::MouseEvent& event) {
gfx::Point origin(0, 0);
views::View::ConvertPointToScreen(shelf_->GetRootView(), &origin);
screen.set_x(screen.x() - origin.x() - initial_drag_location_.x());
- screen.set_y(screen.y() - origin.y() - initial_drag_location_.y());
+
+ // 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();
+ }
+ screen.set_y(screen_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.
@@ -462,6 +479,11 @@ 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(handle_.get());
DCHECK(!placeholder_view_);