| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GTK_TABS_DRAGGED_TAB_CONTROLLER_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_TABS_DRAGGED_TAB_CONTROLLER_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_TABS_DRAGGED_TAB_CONTROLLER_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_TABS_DRAGGED_TAB_CONTROLLER_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/timer.h" | 17 #include "base/timer.h" |
| 18 #include "chrome/browser/ui/gtk/tabs/drag_data.h" | 18 #include "chrome/browser/ui/gtk/tabs/drag_data.h" |
| 19 #include "chrome/browser/ui/tabs/dock_info.h" | 19 #include "chrome/browser/ui/tabs/dock_info.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "content/public/browser/web_contents_delegate.h" | 22 #include "content/public/browser/web_contents_delegate.h" |
| 23 #include "ui/base/x/x11_util.h" | 23 #include "ui/base/x/x11_util.h" |
| 24 | 24 |
| 25 class DraggedViewGtk; | 25 class DraggedViewGtk; |
| 26 class TabGtk; | 26 class TabGtk; |
| 27 class TabStripGtk; | 27 class TabStripGtk; |
| 28 class TabStripModel; | 28 class TabStripModel; |
| 29 class TabContents; | 29 class TabContents; |
| 30 typedef TabContents TabContentsWrapper; | |
| 31 | 30 |
| 32 class DraggedTabControllerGtk : public content::NotificationObserver, | 31 class DraggedTabControllerGtk : public content::NotificationObserver, |
| 33 public content::WebContentsDelegate { | 32 public content::WebContentsDelegate { |
| 34 public: | 33 public: |
| 35 // |source_tabstrip| is the tabstrip where the tabs reside before any | 34 // |source_tabstrip| is the tabstrip where the tabs reside before any |
| 36 // dragging occurs. |source_tab| is the tab that is under the mouse pointer | 35 // dragging occurs. |source_tab| is the tab that is under the mouse pointer |
| 37 // when dragging starts, it also becomes the active tab if not active | 36 // when dragging starts, it also becomes the active tab if not active |
| 38 // already. |tabs| contains all the selected tabs when dragging starts. | 37 // already. |tabs| contains all the selected tabs when dragging starts. |
| 39 DraggedTabControllerGtk(TabStripGtk* source_tabstrip, TabGtk* source_tab, | 38 DraggedTabControllerGtk(TabStripGtk* source_tabstrip, TabGtk* source_tab, |
| 40 const std::vector<TabGtk*>& tabs); | 39 const std::vector<TabGtk*>& tabs); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 | 57 |
| 59 // Retrieve the tab that corresponds to |contents| if it is being dragged by | 58 // Retrieve the tab that corresponds to |contents| if it is being dragged by |
| 60 // this controller, or NULL if |contents| does not correspond to any tab | 59 // this controller, or NULL if |contents| does not correspond to any tab |
| 61 // being dragged. | 60 // being dragged. |
| 62 TabGtk* GetDraggedTabForContents(content::WebContents* contents); | 61 TabGtk* GetDraggedTabForContents(content::WebContents* contents); |
| 63 | 62 |
| 64 // Returns true if |tab| matches any tab being dragged. | 63 // Returns true if |tab| matches any tab being dragged. |
| 65 bool IsDraggingTab(const TabGtk* tab); | 64 bool IsDraggingTab(const TabGtk* tab); |
| 66 | 65 |
| 67 // Returns true if |tab_contents| matches any tab contents being dragged. | 66 // Returns true if |tab_contents| matches any tab contents being dragged. |
| 68 bool IsDraggingTabContents(const TabContentsWrapper* tab_contents); | 67 bool IsDraggingTabContents(const TabContents* tab_contents); |
| 69 | 68 |
| 70 // Returns true if the specified tab is detached. | 69 // Returns true if the specified tab is detached. |
| 71 bool IsTabDetached(const TabGtk* tab); | 70 bool IsTabDetached(const TabGtk* tab); |
| 72 | 71 |
| 73 private: | 72 private: |
| 74 // Enumeration of the ways a drag session can end. | 73 // Enumeration of the ways a drag session can end. |
| 75 enum EndDragType { | 74 enum EndDragType { |
| 76 // Drag session exited normally: the user released the mouse. | 75 // Drag session exited normally: the user released the mouse. |
| 77 NORMAL, | 76 NORMAL, |
| 78 | 77 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Returns the index where the dragged WebContents should be inserted into | 147 // Returns the index where the dragged WebContents should be inserted into |
| 149 // the attached TabStripModel given the DraggedTabView's bounds | 148 // the attached TabStripModel given the DraggedTabView's bounds |
| 150 // |dragged_bounds| in coordinates relative to the attached TabStrip. | 149 // |dragged_bounds| in coordinates relative to the attached TabStrip. |
| 151 int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds); | 150 int GetInsertionIndexForDraggedBounds(const gfx::Rect& dragged_bounds); |
| 152 | 151 |
| 153 // Get the position of the dragged view relative to the upper left corner of | 152 // Get the position of the dragged view relative to the upper left corner of |
| 154 // the screen. |screen_point| is the current position of mouse cursor. | 153 // the screen. |screen_point| is the current position of mouse cursor. |
| 155 gfx::Point GetDraggedViewPoint(const gfx::Point& screen_point); | 154 gfx::Point GetDraggedViewPoint(const gfx::Point& screen_point); |
| 156 | 155 |
| 157 // Finds the Tab within the specified TabStrip that corresponds to the | 156 // Finds the Tab within the specified TabStrip that corresponds to the |
| 158 // dragged TabContentsWrapper. | 157 // dragged TabContents. |
| 159 TabGtk* GetTabMatchingDraggedContents(TabStripGtk* tabstrip, | 158 TabGtk* GetTabMatchingDraggedContents(TabStripGtk* tabstrip, |
| 160 TabContentsWrapper* contents); | 159 TabContents* contents); |
| 161 | 160 |
| 162 // Finds all the tabs within the specified TabStrip that correspond to the | 161 // Finds all the tabs within the specified TabStrip that correspond to the |
| 163 // dragged TabContentsWrapper. | 162 // dragged TabContents. |
| 164 std::vector<TabGtk*> GetTabsMatchingDraggedContents(TabStripGtk* tabstrip); | 163 std::vector<TabGtk*> GetTabsMatchingDraggedContents(TabStripGtk* tabstrip); |
| 165 | 164 |
| 166 // Sets the visible and draggging property of all dragged tabs. If |repaint| | 165 // Sets the visible and draggging property of all dragged tabs. If |repaint| |
| 167 // is true it also schedules a repaint. | 166 // is true it also schedules a repaint. |
| 168 void SetDraggedTabsVisible(bool visible, bool repaint); | 167 void SetDraggedTabsVisible(bool visible, bool repaint); |
| 169 | 168 |
| 170 // Does the work for EndDrag. Returns whether the tab has been destroyed. | 169 // Does the work for EndDrag. Returns whether the tab has been destroyed. |
| 171 bool EndDragImpl(EndDragType how_end); | 170 bool EndDragImpl(EndDragType how_end); |
| 172 | 171 |
| 173 // If the drag was aborted for some reason, this function is called to un-do | 172 // If the drag was aborted for some reason, this function is called to un-do |
| 174 // the changes made during the drag operation. | 173 // the changes made during the drag operation. |
| 175 void RevertDrag(); | 174 void RevertDrag(); |
| 176 | 175 |
| 177 // Finishes the drag operation. Returns true if the drag controller should | 176 // Finishes the drag operation. Returns true if the drag controller should |
| 178 // be destroyed immediately, false otherwise. | 177 // be destroyed immediately, false otherwise. |
| 179 bool CompleteDrag(); | 178 bool CompleteDrag(); |
| 180 | 179 |
| 181 // Resets the delegates of the TabContentsWrapper. | 180 // Resets the delegates of the TabContents. |
| 182 void ResetDelegates(); | 181 void ResetDelegates(); |
| 183 | 182 |
| 184 // Create the DraggedViewGtk if it does not yet exist. | 183 // Create the DraggedViewGtk if it does not yet exist. |
| 185 void EnsureDraggedView(); | 184 void EnsureDraggedView(); |
| 186 | 185 |
| 187 // Gets the bounds to animate the dragged view when dragging is over. | 186 // Gets the bounds to animate the dragged view when dragging is over. |
| 188 gfx::Rect GetAnimateBounds(); | 187 gfx::Rect GetAnimateBounds(); |
| 189 | 188 |
| 190 // Utility to convert the specified TabStripModel index to something valid | 189 // Utility to convert the specified TabStripModel index to something valid |
| 191 // for the attached TabStrip. | 190 // for the attached TabStrip. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 260 |
| 262 // Timer used to bring the window under the cursor to front. If the user | 261 // Timer used to bring the window under the cursor to front. If the user |
| 263 // stops moving the mouse for a brief time over a browser window, it is | 262 // stops moving the mouse for a brief time over a browser window, it is |
| 264 // brought to front. | 263 // brought to front. |
| 265 base::OneShotTimer<DraggedTabControllerGtk> bring_to_front_timer_; | 264 base::OneShotTimer<DraggedTabControllerGtk> bring_to_front_timer_; |
| 266 | 265 |
| 267 DISALLOW_COPY_AND_ASSIGN(DraggedTabControllerGtk); | 266 DISALLOW_COPY_AND_ASSIGN(DraggedTabControllerGtk); |
| 268 }; | 267 }; |
| 269 | 268 |
| 270 #endif // CHROME_BROWSER_UI_GTK_TABS_DRAGGED_TAB_CONTROLLER_GTK_H_ | 269 #endif // CHROME_BROWSER_UI_GTK_TABS_DRAGGED_TAB_CONTROLLER_GTK_H_ |
| OLD | NEW |