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

Unified Diff: chrome/browser/ui/views/tabs/default_tab_drag_controller.h

Issue 10267023: Gets tab dragging to work in touch mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/default_tab_drag_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/default_tab_drag_controller.h
diff --git a/chrome/browser/ui/views/tabs/default_tab_drag_controller.h b/chrome/browser/ui/views/tabs/default_tab_drag_controller.h
index 6be30e7bf0cfe8856a76e477a60741d9905bca49..f296fed90317d458eae5e548e508601416dc54ae 100644
--- a/chrome/browser/ui/views/tabs/default_tab_drag_controller.h
+++ b/chrome/browser/ui/views/tabs/default_tab_drag_controller.h
@@ -67,6 +67,10 @@ class DefaultTabDragController : public TabDragController,
typedef std::set<gfx::NativeView> DockWindows;
+ // Used to indicate the direction the mouse has moved when attached.
+ static const int kMovedMouseLeft = 1 << 0;
+ static const int kMovedMouseRight = 1 << 1;
+
// Enumeration of the ways a drag session can end.
enum EndDragType {
// Drag session exited normally: the user released the mouse.
@@ -171,7 +175,12 @@ class DefaultTabDragController : public TabDragController,
// Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't
// actually reorder the tabs in anyway, just changes what's visible.
- void MoveAttachedStacked(const gfx::Point& screen_point);
+ void DragActiveTabStacked(const gfx::Point& screen_point);
+
+ // Moves the active tab to the next/previous tab. Used when the next/previous
+ // tab is stacked.
+ void MoveAttachedToNextStackedIndex();
+ void MoveAttachedToPreviousStackedIndex();
// Handles dragging tabs while the tabs are attached.
void MoveAttached(const gfx::Point& screen_point);
@@ -179,6 +188,10 @@ class DefaultTabDragController : public TabDragController,
// Handles dragging while the tabs are detached.
void MoveDetached(const gfx::Point& screen_point);
+ // If necessary starts the |move_stacked_timer_|. The timer is started if
+ // close enough to an edge with stacked tabs.
+ void StartMoveStackedTimerIfNecessary(int delay_ms);
+
#if defined(OS_WIN) && !defined(USE_AURA)
// Returns the compatible TabStrip that is under the specified point (screen
// coordinates), or NULL if there is none.
@@ -198,6 +211,13 @@ class DefaultTabDragController : public TabDragController,
// Detach the dragged Tab from the current TabStrip.
void Detach();
+ // Determines the index to insert tabs at. |dragged_bounds| is the bounds of
+ // the tabs being dragged, |start| the index of the tab to start looking from
+ // and |delta| the amount to increment (1 or -1).
+ int GetInsertionIndexFrom(const gfx::Rect& dragged_bounds,
+ int start,
+ int delta) const;
+
// Returns the index where the dragged WebContents should be inserted into
// |attached_tabstrip_| given the DraggedTabView's bounds |dragged_bounds| in
// coordinates relative to |attached_tabstrip_| and has had the mirroring
@@ -205,6 +225,20 @@ class DefaultTabDragController : public TabDragController,
// NOTE: this is invoked from |Attach| before the tabs have been inserted.
int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds) const;
+ // Returns true if |dragged_bounds| is close enough to the next stacked tab
+ // so that the active tab should be dragged there.
+ bool ShouldDragToNextStackedTab(const gfx::Rect& dragged_bounds,
+ int index) const;
+
+ // Returns true if |dragged_bounds| is close enough to the previous stacked
+ // tab so that the active tab should be dragged there.
+ bool ShouldDragToPreviousStackedTab(const gfx::Rect& dragged_bounds,
+ int index) const;
+
+ // Used by GetInsertionIndexForDraggedBounds() when the tabstrip is stacked.
+ int GetInsertionIndexForDraggedBoundsStacked(
+ const gfx::Rect& dragged_bounds) const;
+
// Retrieve the bounds of the DraggedTabView relative to the attached
// TabStrip. |tab_strip_point| is in the attached TabStrip's coordinate
// system.
@@ -346,6 +380,10 @@ class DefaultTabDragController : public TabDragController,
// brought to front.
base::OneShotTimer<DefaultTabDragController> bring_to_front_timer_;
+ // Timer used to move the stacked tabs. See comment aboue
+ // StartMoveStackedTimerIfNecessary().
+ base::OneShotTimer<DefaultTabDragController> move_stacked_timer_;
+
// Did the mouse move enough that we started a drag?
bool started_drag_;
@@ -374,6 +412,14 @@ class DefaultTabDragController : public TabDragController,
// TODO(sky): clean up.
bool move_only_;
+ // Updated as the mouse is moved when attached. Indicates whether the mouse
+ // has ever moved to the left or right. If the tabs are ever detached this
+ // is set to kMovedMouseRight | kMovedMouseLeft.
+ int mouse_move_direction_;
+
+ // Coordinate last used in MoveAttached().
+ gfx::Point last_screen_point_;
+
DISALLOW_COPY_AND_ASSIGN(DefaultTabDragController);
};
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/default_tab_drag_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698