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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/default_tab_drag_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_DEFAULT_TAB_DRAG_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_DEFAULT_TAB_DRAG_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_DEFAULT_TAB_DRAG_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TABS_DEFAULT_TAB_DRAG_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // See description above fields for details on these. 60 // See description above fields for details on these.
61 bool active() const { return active_; } 61 bool active() const { return active_; }
62 const TabStrip* attached_tabstrip() const { return attached_tabstrip_; } 62 const TabStrip* attached_tabstrip() const { return attached_tabstrip_; }
63 63
64 private: 64 private:
65 class DockDisplayer; 65 class DockDisplayer;
66 friend class DockDisplayer; 66 friend class DockDisplayer;
67 67
68 typedef std::set<gfx::NativeView> DockWindows; 68 typedef std::set<gfx::NativeView> DockWindows;
69 69
70 // Used to indicate the direction the mouse has moved when attached.
71 static const int kMovedMouseLeft = 1 << 0;
72 static const int kMovedMouseRight = 1 << 1;
73
70 // Enumeration of the ways a drag session can end. 74 // Enumeration of the ways a drag session can end.
71 enum EndDragType { 75 enum EndDragType {
72 // Drag session exited normally: the user released the mouse. 76 // Drag session exited normally: the user released the mouse.
73 NORMAL, 77 NORMAL,
74 78
75 // The drag session was canceled (alt-tab during drag, escape ...) 79 // The drag session was canceled (alt-tab during drag, escape ...)
76 CANCELED, 80 CANCELED,
77 81
78 // The tab (NavigationController) was destroyed during the drag. 82 // The tab (NavigationController) was destroyed during the drag.
79 TAB_DESTROYED 83 TAB_DESTROYED
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Tests whether the position of the mouse is past a minimum elasticity 168 // Tests whether the position of the mouse is past a minimum elasticity
165 // threshold required to start a drag. 169 // threshold required to start a drag.
166 bool CanStartDrag() const; 170 bool CanStartDrag() const;
167 171
168 // Move the DraggedTabView according to the current mouse screen position, 172 // Move the DraggedTabView according to the current mouse screen position,
169 // potentially updating the source and other TabStrips. 173 // potentially updating the source and other TabStrips.
170 void ContinueDragging(); 174 void ContinueDragging();
171 175
172 // Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't 176 // Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't
173 // actually reorder the tabs in anyway, just changes what's visible. 177 // actually reorder the tabs in anyway, just changes what's visible.
174 void MoveAttachedStacked(const gfx::Point& screen_point); 178 void DragActiveTabStacked(const gfx::Point& screen_point);
179
180 // Moves the active tab to the next/previous tab. Used when the next/previous
181 // tab is stacked.
182 void MoveAttachedToNextStackedIndex();
183 void MoveAttachedToPreviousStackedIndex();
175 184
176 // Handles dragging tabs while the tabs are attached. 185 // Handles dragging tabs while the tabs are attached.
177 void MoveAttached(const gfx::Point& screen_point); 186 void MoveAttached(const gfx::Point& screen_point);
178 187
179 // Handles dragging while the tabs are detached. 188 // Handles dragging while the tabs are detached.
180 void MoveDetached(const gfx::Point& screen_point); 189 void MoveDetached(const gfx::Point& screen_point);
181 190
191 // If necessary starts the |move_stacked_timer_|. The timer is started if
192 // close enough to an edge with stacked tabs.
193 void StartMoveStackedTimerIfNecessary(int delay_ms);
194
182 #if defined(OS_WIN) && !defined(USE_AURA) 195 #if defined(OS_WIN) && !defined(USE_AURA)
183 // Returns the compatible TabStrip that is under the specified point (screen 196 // Returns the compatible TabStrip that is under the specified point (screen
184 // coordinates), or NULL if there is none. 197 // coordinates), or NULL if there is none.
185 TabStrip* GetTabStripForPoint(const gfx::Point& screen_point); 198 TabStrip* GetTabStripForPoint(const gfx::Point& screen_point);
186 #endif 199 #endif
187 200
188 DockInfo GetDockInfoAtPoint(const gfx::Point& screen_point); 201 DockInfo GetDockInfoAtPoint(const gfx::Point& screen_point);
189 202
190 // Returns the specified |tabstrip| if it contains the specified point 203 // Returns the specified |tabstrip| if it contains the specified point
191 // (screen coordinates), NULL if it does not. 204 // (screen coordinates), NULL if it does not.
192 TabStrip* GetTabStripIfItContains(TabStrip* tabstrip, 205 TabStrip* GetTabStripIfItContains(TabStrip* tabstrip,
193 const gfx::Point& screen_point) const; 206 const gfx::Point& screen_point) const;
194 207
195 // Attach the dragged Tab to the specified TabStrip. 208 // Attach the dragged Tab to the specified TabStrip.
196 void Attach(TabStrip* attached_tabstrip, const gfx::Point& screen_point); 209 void Attach(TabStrip* attached_tabstrip, const gfx::Point& screen_point);
197 210
198 // Detach the dragged Tab from the current TabStrip. 211 // Detach the dragged Tab from the current TabStrip.
199 void Detach(); 212 void Detach();
200 213
214 // Determines the index to insert tabs at. |dragged_bounds| is the bounds of
215 // the tabs being dragged, |start| the index of the tab to start looking from
216 // and |delta| the amount to increment (1 or -1).
217 int GetInsertionIndexFrom(const gfx::Rect& dragged_bounds,
218 int start,
219 int delta) const;
220
201 // Returns the index where the dragged WebContents should be inserted into 221 // Returns the index where the dragged WebContents should be inserted into
202 // |attached_tabstrip_| given the DraggedTabView's bounds |dragged_bounds| in 222 // |attached_tabstrip_| given the DraggedTabView's bounds |dragged_bounds| in
203 // coordinates relative to |attached_tabstrip_| and has had the mirroring 223 // coordinates relative to |attached_tabstrip_| and has had the mirroring
204 // transformation applied. 224 // transformation applied.
205 // NOTE: this is invoked from |Attach| before the tabs have been inserted. 225 // NOTE: this is invoked from |Attach| before the tabs have been inserted.
206 int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds) const; 226 int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds) const;
207 227
228 // Returns true if |dragged_bounds| is close enough to the next stacked tab
229 // so that the active tab should be dragged there.
230 bool ShouldDragToNextStackedTab(const gfx::Rect& dragged_bounds,
231 int index) const;
232
233 // Returns true if |dragged_bounds| is close enough to the previous stacked
234 // tab so that the active tab should be dragged there.
235 bool ShouldDragToPreviousStackedTab(const gfx::Rect& dragged_bounds,
236 int index) const;
237
238 // Used by GetInsertionIndexForDraggedBounds() when the tabstrip is stacked.
239 int GetInsertionIndexForDraggedBoundsStacked(
240 const gfx::Rect& dragged_bounds) const;
241
208 // Retrieve the bounds of the DraggedTabView relative to the attached 242 // Retrieve the bounds of the DraggedTabView relative to the attached
209 // TabStrip. |tab_strip_point| is in the attached TabStrip's coordinate 243 // TabStrip. |tab_strip_point| is in the attached TabStrip's coordinate
210 // system. 244 // system.
211 gfx::Rect GetDraggedViewTabStripBounds(const gfx::Point& tab_strip_point); 245 gfx::Rect GetDraggedViewTabStripBounds(const gfx::Point& tab_strip_point);
212 246
213 // Get the position of the dragged tab view relative to the attached tab 247 // Get the position of the dragged tab view relative to the attached tab
214 // strip with the mirroring transform applied. 248 // strip with the mirroring transform applied.
215 gfx::Point GetAttachedDragPoint(const gfx::Point& screen_point); 249 gfx::Point GetAttachedDragPoint(const gfx::Point& screen_point);
216 250
217 // Finds the Tabs within the specified TabStrip that corresponds to the 251 // Finds the Tabs within the specified TabStrip that corresponds to the
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 373
340 DockWindows dock_windows_; 374 DockWindows dock_windows_;
341 375
342 std::vector<DockDisplayer*> dock_controllers_; 376 std::vector<DockDisplayer*> dock_controllers_;
343 377
344 // Timer used to bring the window under the cursor to front. If the user 378 // Timer used to bring the window under the cursor to front. If the user
345 // stops moving the mouse for a brief time over a browser window, it is 379 // stops moving the mouse for a brief time over a browser window, it is
346 // brought to front. 380 // brought to front.
347 base::OneShotTimer<DefaultTabDragController> bring_to_front_timer_; 381 base::OneShotTimer<DefaultTabDragController> bring_to_front_timer_;
348 382
383 // Timer used to move the stacked tabs. See comment aboue
384 // StartMoveStackedTimerIfNecessary().
385 base::OneShotTimer<DefaultTabDragController> move_stacked_timer_;
386
349 // Did the mouse move enough that we started a drag? 387 // Did the mouse move enough that we started a drag?
350 bool started_drag_; 388 bool started_drag_;
351 389
352 // Is the drag active? 390 // Is the drag active?
353 bool active_; 391 bool active_;
354 392
355 DragData drag_data_; 393 DragData drag_data_;
356 394
357 // Index of the source tab in drag_data_. 395 // Index of the source tab in drag_data_.
358 size_t source_tab_index_; 396 size_t source_tab_index_;
359 397
360 // True until |MoveAttached| is invoked once. 398 // True until |MoveAttached| is invoked once.
361 bool initial_move_; 399 bool initial_move_;
362 400
363 // The selection model before the drag started. See comment above Init() for 401 // The selection model before the drag started. See comment above Init() for
364 // details. 402 // details.
365 TabStripSelectionModel initial_selection_model_; 403 TabStripSelectionModel initial_selection_model_;
366 404
367 // The selection model of |attached_tabstrip_| before the tabs were attached. 405 // The selection model of |attached_tabstrip_| before the tabs were attached.
368 TabStripSelectionModel selection_model_before_attach_; 406 TabStripSelectionModel selection_model_before_attach_;
369 407
370 // Initial x-coordinates of the tabs when the drag started. Only used for 408 // Initial x-coordinates of the tabs when the drag started. Only used for
371 // touch mode. 409 // touch mode.
372 std::vector<int> initial_tab_positions_; 410 std::vector<int> initial_tab_positions_;
373 411
374 // TODO(sky): clean up. 412 // TODO(sky): clean up.
375 bool move_only_; 413 bool move_only_;
376 414
415 // Updated as the mouse is moved when attached. Indicates whether the mouse
416 // has ever moved to the left or right. If the tabs are ever detached this
417 // is set to kMovedMouseRight | kMovedMouseLeft.
418 int mouse_move_direction_;
419
420 // Coordinate last used in MoveAttached().
421 gfx::Point last_screen_point_;
422
377 DISALLOW_COPY_AND_ASSIGN(DefaultTabDragController); 423 DISALLOW_COPY_AND_ASSIGN(DefaultTabDragController);
378 }; 424 };
379 425
380 #endif // CHROME_BROWSER_UI_VIEWS_TABS_DEFAULT_TAB_DRAG_CONTROLLER_H_ 426 #endif // CHROME_BROWSER_UI_VIEWS_TABS_DEFAULT_TAB_DRAG_CONTROLLER_H_
OLDNEW
« 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