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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.h

Issue 10446090: Changes the tabstrip dragging code to use coordinates from the events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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_TAB_DRAG_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Returns true if there is a drag underway. 98 // Returns true if there is a drag underway.
99 static bool IsActive(); 99 static bool IsActive();
100 100
101 // See description above fields for details on these. 101 // See description above fields for details on these.
102 bool active() const { return active_; } 102 bool active() const { return active_; }
103 const TabStrip* attached_tabstrip() const { return attached_tabstrip_; } 103 const TabStrip* attached_tabstrip() const { return attached_tabstrip_; }
104 104
105 // Returns true if a drag started. 105 // Returns true if a drag started.
106 bool started_drag() const { return started_drag_; } 106 bool started_drag() const { return started_drag_; }
107 107
108 // Invoked as the mouse is dragged. If the mouse moves a sufficient distance 108 // Invoked to drag to the new location, in screen coordinates.
109 // before the mouse is released, a drag session is initiated. 109 void Drag(const gfx::Point& screen_point);
110 void Drag();
111 110
112 // Complete the current drag session. If the drag session was canceled 111 // Complete the current drag session. If the drag session was canceled
113 // because the user pressed escape or something interrupted it, |canceled| 112 // because the user pressed escape or something interrupted it, |canceled|
114 // is true and the drag is reverted. 113 // is true and the drag is reverted.
115 void EndDrag(bool canceled); 114 void EndDrag(bool canceled);
116 115
117 private: 116 private:
118 class DockDisplayer; 117 class DockDisplayer;
119 friend class DockDisplayer; 118 friend class DockDisplayer;
120 119
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 virtual void OnWidgetMoved(views::Widget* widget) OVERRIDE; 223 virtual void OnWidgetMoved(views::Widget* widget) OVERRIDE;
225 224
226 // Overriden from TabStripModelObserver: 225 // Overriden from TabStripModelObserver:
227 virtual void TabStripEmpty() OVERRIDE; 226 virtual void TabStripEmpty() OVERRIDE;
228 227
229 // Initialize the offset used to calculate the position to create windows 228 // Initialize the offset used to calculate the position to create windows
230 // in |GetWindowCreatePoint|. This should only be invoked from |Init|. 229 // in |GetWindowCreatePoint|. This should only be invoked from |Init|.
231 void InitWindowCreatePoint(); 230 void InitWindowCreatePoint();
232 231
233 // Returns the point where a detached window should be created given the 232 // Returns the point where a detached window should be created given the
234 // current mouse position. 233 // current mouse position |origin|.
235 gfx::Point GetWindowCreatePoint() const; 234 gfx::Point GetWindowCreatePoint(const gfx::Point& origin) const;
236 235
237 void UpdateDockInfo(const gfx::Point& screen_point); 236 void UpdateDockInfo(const gfx::Point& screen_point);
238 237
239 // Saves focus in the window that the drag initiated from. Focus will be 238 // Saves focus in the window that the drag initiated from. Focus will be
240 // restored appropriately if the drag ends within this same window. 239 // restored appropriately if the drag ends within this same window.
241 void SaveFocus(); 240 void SaveFocus();
242 241
243 // Restore focus to the View that had focus before the drag was started, if 242 // Restore focus to the View that had focus before the drag was started, if
244 // the drag ends within the same Window as it began. 243 // the drag ends within the same Window as it began.
245 void RestoreFocus(); 244 void RestoreFocus();
246 245
247 // Tests whether the position of the mouse is past a minimum elasticity 246 // Tests whether |screen_point| is past a minimum elasticity threshold
248 // threshold required to start a drag. 247 // required to start a drag.
249 bool CanStartDrag() const; 248 bool CanStartDrag(const gfx::Point& screen_point) const;
250 249
251 // Move the DraggedTabView according to the current mouse screen position, 250 // Move the DraggedTabView according to the current mouse screen position,
252 // potentially updating the source and other TabStrips. 251 // potentially updating the source and other TabStrips.
253 void ContinueDragging(); 252 void ContinueDragging(const gfx::Point& screen_point);
254 253
255 // Transitions dragging from |attached_tabstrip_| to |target_tabstrip|. 254 // Transitions dragging from |attached_tabstrip_| to |target_tabstrip|.
256 // |target_tabstrip| is NULL if the mouse is not over a valid tab strip. See 255 // |target_tabstrip| is NULL if the mouse is not over a valid tab strip. See
257 // DragBrowserResultType for details of the return type. 256 // DragBrowserResultType for details of the return type.
258 DragBrowserResultType DragBrowserToNewTabStrip( 257 DragBrowserResultType DragBrowserToNewTabStrip(
259 TabStrip* target_tabstrip, 258 TabStrip* target_tabstrip,
260 const gfx::Point& screen_point); 259 const gfx::Point& screen_point);
261 260
262 // Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't 261 // Handles dragging for a touch tabstrip when the tabs are stacked. Doesn't
263 // actually reorder the tabs in anyway, just changes what's visible. 262 // actually reorder the tabs in anyway, just changes what's visible.
264 void DragActiveTabStacked(const gfx::Point& screen_point); 263 void DragActiveTabStacked(const gfx::Point& screen_point);
265 264
266 // Moves the active tab to the next/previous tab. Used when the next/previous 265 // Moves the active tab to the next/previous tab. Used when the next/previous
267 // tab is stacked. 266 // tab is stacked.
268 void MoveAttachedToNextStackedIndex(); 267 void MoveAttachedToNextStackedIndex(const gfx::Point& screen_point);
269 void MoveAttachedToPreviousStackedIndex(); 268 void MoveAttachedToPreviousStackedIndex(const gfx::Point& screen_point);
270 269
271 // Handles dragging tabs while the tabs are attached. 270 // Handles dragging tabs while the tabs are attached.
272 void MoveAttached(const gfx::Point& screen_point); 271 void MoveAttached(const gfx::Point& screen_point);
273 272
274 // Handles dragging while the tabs are detached. 273 // Handles dragging while the tabs are detached.
275 void MoveDetached(const gfx::Point& screen_point); 274 void MoveDetached(const gfx::Point& screen_point);
276 275
277 // If necessary starts the |move_stacked_timer_|. The timer is started if 276 // If necessary starts the |move_stacked_timer_|. The timer is started if
278 // close enough to an edge with stacked tabs. 277 // close enough to an edge with stacked tabs.
279 void StartMoveStackedTimerIfNecessary(int delay_ms); 278 void StartMoveStackedTimerIfNecessary(
279 const gfx::Point& screen_point,
280 int delay_ms);
280 281
281 // Returns the TabStrip for the specified window, or NULL if one doesn't exist 282 // Returns the TabStrip for the specified window, or NULL if one doesn't exist
282 // or isn't compatible. 283 // or isn't compatible.
283 TabStrip* GetTabStripForWindow(gfx::NativeWindow window); 284 TabStrip* GetTabStripForWindow(gfx::NativeWindow window);
284 285
285 // Returns the compatible TabStrip that is under the specified point (screen 286 // Returns the compatible TabStrip that is under the specified point (screen
286 // coordinates), or NULL if there is none. 287 // coordinates), or NULL if there is none.
287 TabStrip* GetTabStripForPoint(const gfx::Point& screen_point); 288 TabStrip* GetTabStripForPoint(const gfx::Point& screen_point);
288 289
289 // Returns true if |tabstrip| contains the specified point in screen 290 // Returns true if |tabstrip| contains the specified point in screen
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // Finishes a succesful drag operation. 374 // Finishes a succesful drag operation.
374 void CompleteDrag(); 375 void CompleteDrag();
375 376
376 // Resets the delegates of the WebContents. 377 // Resets the delegates of the WebContents.
377 void ResetDelegates(); 378 void ResetDelegates();
378 379
379 // Create the DraggedTabView. 380 // Create the DraggedTabView.
380 void CreateDraggedView(const std::vector<TabRendererData>& data, 381 void CreateDraggedView(const std::vector<TabRendererData>& data,
381 const std::vector<gfx::Rect>& renderer_bounds); 382 const std::vector<gfx::Rect>& renderer_bounds);
382 383
383 // Utility for getting the mouse position in screen coordinates.
384 gfx::Point GetCursorScreenPoint() const;
385
386 // Returns the bounds (in screen coordinates) of the specified View. 384 // Returns the bounds (in screen coordinates) of the specified View.
387 gfx::Rect GetViewScreenBounds(views::View* tabstrip) const; 385 gfx::Rect GetViewScreenBounds(views::View* tabstrip) const;
388 386
389 // Hides the frame for the window that contains the TabStrip the current 387 // Hides the frame for the window that contains the TabStrip the current
390 // drag session was initiated from. 388 // drag session was initiated from.
391 void HideFrame(); 389 void HideFrame();
392 390
393 // Closes a hidden frame at the end of a drag session. 391 // Closes a hidden frame at the end of a drag session.
394 void CleanUpHiddenFrame(); 392 void CleanUpHiddenFrame();
395 393
396 void DockDisplayerDestroyed(DockDisplayer* controller); 394 void DockDisplayerDestroyed(DockDisplayer* controller);
397 395
398 void BringWindowUnderMouseToFront(); 396 void BringWindowUnderPointToFront(const gfx::Point& screen_point);
399 397
400 // Convenience for getting the TabDragData corresponding to the tab the user 398 // Convenience for getting the TabDragData corresponding to the tab the user
401 // started dragging. 399 // started dragging.
402 TabDragData* source_tab_drag_data() { 400 TabDragData* source_tab_drag_data() {
403 return &(drag_data_[source_tab_index_]); 401 return &(drag_data_[source_tab_index_]);
404 } 402 }
405 403
406 // Convenience for |source_tab_drag_data()->contents|. 404 // Convenience for |source_tab_drag_data()->contents|.
407 TabContentsWrapper* source_dragged_contents() { 405 TabContentsWrapper* source_dragged_contents() {
408 return source_tab_drag_data()->contents; 406 return source_tab_drag_data()->contents;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 std::vector<int> initial_tab_positions_; 527 std::vector<int> initial_tab_positions_;
530 528
531 DetachBehavior detach_behavior_; 529 DetachBehavior detach_behavior_;
532 MoveBehavior move_behavior_; 530 MoveBehavior move_behavior_;
533 531
534 // Updated as the mouse is moved when attached. Indicates whether the mouse 532 // Updated as the mouse is moved when attached. Indicates whether the mouse
535 // has ever moved to the left or right. If the tabs are ever detached this 533 // has ever moved to the left or right. If the tabs are ever detached this
536 // is set to kMovedMouseRight | kMovedMouseLeft. 534 // is set to kMovedMouseRight | kMovedMouseLeft.
537 int mouse_move_direction_; 535 int mouse_move_direction_;
538 536
539 // Coordinate last used in MoveAttached(). 537 // Last location used.
540 gfx::Point last_screen_point_; 538 gfx::Point last_screen_point_;
541 539
542 // The following are needed when detaching into a browser 540 // The following are needed when detaching into a browser
543 // (|detach_into_browser_| is true). 541 // (|detach_into_browser_| is true).
544 542
545 // Set to true if we've detached from a tabstrip and are running a nested 543 // Set to true if we've detached from a tabstrip and are running a nested
546 // move message loop. 544 // move message loop.
547 bool is_dragging_window_; 545 bool is_dragging_window_;
548 546
549 EndRunLoopBehavior end_run_loop_behavior_; 547 EndRunLoopBehavior end_run_loop_behavior_;
550 548
551 // If true, we're waiting for a move loop to complete. 549 // If true, we're waiting for a move loop to complete.
552 bool waiting_for_run_loop_to_exit_; 550 bool waiting_for_run_loop_to_exit_;
553 551
554 // The TabStrip to attach to after the move loop completes. 552 // The TabStrip to attach to after the move loop completes.
555 TabStrip* tab_strip_to_attach_to_after_exit_; 553 TabStrip* tab_strip_to_attach_to_after_exit_;
556 554
557 // Non-null for the duration of RunMoveLoop. 555 // Non-null for the duration of RunMoveLoop.
558 views::Widget* move_loop_widget_; 556 views::Widget* move_loop_widget_;
559 557
560 // If non-null set to true from destructor. 558 // If non-null set to true from destructor.
561 bool* destroyed_; 559 bool* destroyed_;
562 560
563 DISALLOW_COPY_AND_ASSIGN(TabDragController); 561 DISALLOW_COPY_AND_ASSIGN(TabDragController);
564 }; 562 };
565 563
566 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ 564 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_controller.h ('k') | chrome/browser/ui/views/tabs/tab_drag_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698