OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ |
6 #define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ | 6 #define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ |
7 | 7 |
8 #include "base/gfx/point.h" | 8 #include "base/gfx/point.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 10 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
11 #include "chrome/common/notification_registrar.h" | 11 #include "chrome/common/notification_registrar.h" |
12 | 12 |
| 13 class Browser; |
13 class TabOverviewController; | 14 class TabOverviewController; |
14 class TabOverviewGrid; | 15 class TabOverviewGrid; |
15 class TabStripModel; | 16 class TabStripModel; |
16 | 17 |
17 namespace views { | 18 namespace views { |
18 class Widget; | 19 class Widget; |
19 } | 20 } |
20 | 21 |
21 // TabOverviewDragController handles dragging cells in a TabOverviewGrid. | 22 // TabOverviewDragController handles dragging cells in a TabOverviewGrid. |
22 // There are a couple of interesting states TabOverviewDragController may | 23 // There are a couple of interesting states TabOverviewDragController may |
(...skipping 10 matching lines...) Expand all Loading... |
33 // Finally CommitDrag is invoked if the user releases the mouse, or RevertDrag | 34 // Finally CommitDrag is invoked if the user releases the mouse, or RevertDrag |
34 // if the drag is canceled some how. | 35 // if the drag is canceled some how. |
35 // | 36 // |
36 // NOTE: all coordinates passed in are relative to the TabOverviewGrid. | 37 // NOTE: all coordinates passed in are relative to the TabOverviewGrid. |
37 class TabOverviewDragController : public TabContentsDelegate, | 38 class TabOverviewDragController : public TabContentsDelegate, |
38 public NotificationObserver { | 39 public NotificationObserver { |
39 public: | 40 public: |
40 explicit TabOverviewDragController(TabOverviewController* controller); | 41 explicit TabOverviewDragController(TabOverviewController* controller); |
41 ~TabOverviewDragController(); | 42 ~TabOverviewDragController(); |
42 | 43 |
43 // Invoked to prepare the TabOverviewDragController for a drag. Returns true | 44 // Sets whether the mouse is over a mini-window. |
44 // if over a cell, false if the mouse isn't over a valid location. | 45 void set_mouse_over_mini_window(bool over_mini_window) { |
| 46 mouse_over_mini_window_ = over_mini_window; |
| 47 } |
| 48 |
| 49 // Prepares the TabOverviewDragController for a drag. Returns true if over a |
| 50 // cell, false if the mouse isn't over a valid location. |
45 bool Configure(const gfx::Point& location); | 51 bool Configure(const gfx::Point& location); |
46 | 52 |
47 // Invoked as the user drags the mouse. | 53 // Invoked as the user drags the mouse. |
48 void Drag(const gfx::Point& location); | 54 void Drag(const gfx::Point& location); |
49 | 55 |
50 // Invoked to commit the drag, typically when the user pressed enter. | 56 // Commits the drag, typically when the user releases the mouse. |
51 void CommitDrag(const gfx::Point& location); | 57 void CommitDrag(const gfx::Point& location); |
52 | 58 |
53 // Invoked to rever the drag. | 59 // Reverts the drag. Use true if the revert is the result of the tab being |
54 void RevertDrag(); | 60 // destroyed. |
| 61 void RevertDrag(bool tab_destroyed); |
55 | 62 |
56 bool modifying_model() const { return modifying_model_; } | 63 bool modifying_model() const { return modifying_model_; } |
57 TabOverviewGrid* grid() const; | 64 TabOverviewGrid* grid() const; |
58 TabStripModel* model() const; | 65 TabStripModel* model() const; |
59 | 66 |
60 // Overridden from NotificationObserver: | 67 // Overridden from NotificationObserver: |
61 virtual void Observe(NotificationType type, | 68 virtual void Observe(NotificationType type, |
62 const NotificationSource& source, | 69 const NotificationSource& source, |
63 const NotificationDetails& details); | 70 const NotificationDetails& details); |
64 | 71 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // drag when the model changes. | 151 // drag when the model changes. |
145 bool modifying_model_; | 152 bool modifying_model_; |
146 | 153 |
147 // Handles registering for notifications. | 154 // Handles registering for notifications. |
148 NotificationRegistrar registrar_; | 155 NotificationRegistrar registrar_; |
149 | 156 |
150 // Once a tab is detached a window is created containing a cell and moved | 157 // Once a tab is detached a window is created containing a cell and moved |
151 // around; this is that window. | 158 // around; this is that window. |
152 views::Widget* detached_window_; | 159 views::Widget* detached_window_; |
153 | 160 |
| 161 // When a tab is detached from a browser with a single tab we hide the |
| 162 // browser. If this is non-null it means a single tab has been detached |
| 163 // and this is the browser it was detached from. |
| 164 Browser* hidden_browser_; |
| 165 |
| 166 // Whether the mouse is over a mini window. |
| 167 bool mouse_over_mini_window_; |
| 168 |
| 169 // Size of the browser window. Cached in case browser() becomes NULL (as |
| 170 // happens when the user drags over a region that shouldn't show the tab |
| 171 // overview). |
| 172 gfx::Size browser_window_size_; |
| 173 |
154 DISALLOW_COPY_AND_ASSIGN(TabOverviewDragController); | 174 DISALLOW_COPY_AND_ASSIGN(TabOverviewDragController); |
155 }; | 175 }; |
156 | 176 |
157 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ | 177 #endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ |
OLD | NEW |