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_TAB_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_TABS_TAB_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "chrome/browser/tabs/tab_strip_model.h" | 11 #include "chrome/browser/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" | 12 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" |
13 #include "ui/base/gtk/gtk_signal.h" | 13 #include "ui/base/gtk/gtk_signal.h" |
14 | 14 |
15 class TabStripMenuController; | |
16 | |
15 namespace gfx { | 17 namespace gfx { |
16 class Path; | 18 class Path; |
17 } | 19 } |
18 | 20 |
19 namespace ui { | 21 namespace ui { |
20 class ThemeProvider; | 22 class ThemeProvider; |
21 } | 23 } |
22 | 24 |
23 class TabGtk : public TabRendererGtk, | 25 class TabGtk : public TabRendererGtk, |
24 public MessageLoopForUI::Observer { | 26 public MessageLoopForUI::Observer { |
25 public: | 27 public: |
26 // An interface implemented by an object that can help this Tab complete | 28 // An interface implemented by an object that can help this Tab complete |
27 // various actions. The index parameter is the index of this Tab in the | 29 // various actions. The index parameter is the index of this Tab in the |
28 // TabRenderer::Model. | 30 // TabRenderer::Model. |
29 class TabDelegate { | 31 class TabDelegate { |
30 public: | 32 public: |
33 // Returns true if the specified Tab is active. | |
34 virtual bool IsTabActive(const TabGtk* tab) const = 0; | |
35 | |
31 // Returns true if the specified Tab is selected. | 36 // Returns true if the specified Tab is selected. |
32 virtual bool IsTabSelected(const TabGtk* tab) const = 0; | 37 virtual bool IsTabSelected(const TabGtk* tab) const = 0; |
33 | 38 |
34 // Returns true if the specified Tab is pinned. | 39 // Returns true if the specified Tab is pinned. |
35 virtual bool IsTabPinned(const TabGtk* tab) const = 0; | 40 virtual bool IsTabPinned(const TabGtk* tab) const = 0; |
36 | 41 |
37 // Returns true if the specified Tab is detached. | 42 // Returns true if the specified Tab is detached. |
38 virtual bool IsTabDetached(const TabGtk* tab) const = 0; | 43 virtual bool IsTabDetached(const TabGtk* tab) const = 0; |
39 | 44 |
40 // Selects the specified Tab. | 45 // Activate the specified Tab. |
James Hawkins
2011/05/18 18:03:10
s/Activate/Activates/
dpapad
2011/06/01 18:05:41
Done.
| |
41 virtual void SelectTab(TabGtk* tab) = 0; | 46 virtual void ActivateTab(TabGtk* tab) = 0; |
47 | |
48 // Toggle selection of the specified Tab. | |
James Hawkins
2011/05/18 18:03:10
s/Toggle/Toggles/
dpapad
2011/06/01 18:05:41
Done.
| |
49 virtual void ToggleTabSelection(TabGtk* tab) = 0; | |
50 | |
51 // Extends selection from the anchor to the specified Tab. | |
52 virtual void ExtendTabSelection(TabGtk* tab) = 0; | |
42 | 53 |
43 // Closes the specified Tab. | 54 // Closes the specified Tab. |
44 virtual void CloseTab(TabGtk* tab) = 0; | 55 virtual void CloseTab(TabGtk* tab) = 0; |
45 | 56 |
46 // Returns true if the specified command is enabled for the specified Tab. | 57 // Returns true if the specified command is enabled for the specified Tab. |
47 virtual bool IsCommandEnabledForTab( | 58 virtual bool IsCommandEnabledForTab( |
48 TabStripModel::ContextMenuCommand command_id, | 59 TabStripModel::ContextMenuCommand command_id, |
49 const TabGtk* tab) const = 0; | 60 const TabGtk* tab) const = 0; |
50 | 61 |
51 // Executes the specified command for the specified Tab. | 62 // Executes the specified command for the specified Tab. |
(...skipping 21 matching lines...) Expand all Loading... | |
73 | 84 |
74 // Returns true if the associated TabStrip's delegate supports tab moving or | 85 // Returns true if the associated TabStrip's delegate supports tab moving or |
75 // detaching. Used by the Frame to determine if dragging on the Tab | 86 // detaching. Used by the Frame to determine if dragging on the Tab |
76 // itself should move the window in cases where there's only one | 87 // itself should move the window in cases where there's only one |
77 // non drag-able Tab. | 88 // non drag-able Tab. |
78 virtual bool HasAvailableDragActions() const = 0; | 89 virtual bool HasAvailableDragActions() const = 0; |
79 | 90 |
80 // Returns the theme provider for icons and colors. | 91 // Returns the theme provider for icons and colors. |
81 virtual ui::ThemeProvider* GetThemeProvider() = 0; | 92 virtual ui::ThemeProvider* GetThemeProvider() = 0; |
82 | 93 |
94 // Returns a context menu controller for |tab|. Caller takes ownership of | |
95 // the pointed object. | |
96 virtual TabStripMenuController* GetTabStripMenuControllerForTab( | |
97 TabGtk* tab) = 0; | |
98 | |
83 protected: | 99 protected: |
84 virtual ~TabDelegate() {} | 100 virtual ~TabDelegate() {} |
85 }; | 101 }; |
86 | 102 |
87 explicit TabGtk(TabDelegate* delegate); | 103 explicit TabGtk(TabDelegate* delegate); |
88 virtual ~TabGtk(); | 104 virtual ~TabGtk(); |
89 | 105 |
90 // Access the delegate. | 106 // Access the delegate. |
91 TabDelegate* delegate() const { return delegate_; } | 107 TabDelegate* delegate() const { return delegate_; } |
92 | 108 |
93 GtkWidget* widget() const { return event_box_; } | 109 GtkWidget* widget() const { return event_box_; } |
94 | 110 |
95 // Used to set/check whether this Tab is being animated closed. | 111 // Used to set/check whether this Tab is being animated closed. |
96 void set_closing(bool closing) { closing_ = closing; } | 112 void set_closing(bool closing) { closing_ = closing; } |
97 bool closing() const { return closing_; } | 113 bool closing() const { return closing_; } |
98 | 114 |
99 // Used to set/check whether this Tab is being dragged. | 115 // Used to set/check whether this Tab is being dragged. |
100 void set_dragging(bool dragging) { dragging_ = dragging; } | 116 void set_dragging(bool dragging) { dragging_ = dragging; } |
101 bool dragging() const { return dragging_; } | 117 bool dragging() const { return dragging_; } |
102 | 118 |
103 // TabRendererGtk overrides: | 119 // TabRendererGtk overrides: |
120 virtual bool IsActive() const; | |
104 virtual bool IsSelected() const; | 121 virtual bool IsSelected() const; |
105 virtual bool IsVisible() const; | 122 virtual bool IsVisible() const; |
106 virtual void SetVisible(bool visible) const; | 123 virtual void SetVisible(bool visible) const; |
107 virtual void CloseButtonClicked(); | 124 virtual void CloseButtonClicked(); |
108 virtual void UpdateData(TabContents* contents, bool app, bool loading_only); | 125 virtual void UpdateData(TabContents* contents, bool app, bool loading_only); |
109 virtual void SetBounds(const gfx::Rect& bounds); | 126 virtual void SetBounds(const gfx::Rect& bounds); |
110 | 127 |
111 private: | 128 private: |
112 class ContextMenuController; | |
113 class TabGtkObserverHelper; | 129 class TabGtkObserverHelper; |
114 friend class ContextMenuController; | |
115 | 130 |
116 // MessageLoop::Observer implementation: | 131 // MessageLoop::Observer implementation: |
117 virtual void WillProcessEvent(GdkEvent* event); | 132 virtual void WillProcessEvent(GdkEvent* event); |
118 virtual void DidProcessEvent(GdkEvent* event); | 133 virtual void DidProcessEvent(GdkEvent* event); |
119 | 134 |
120 // button-press-event handler that handles mouse clicks. | 135 // button-press-event handler that handles mouse clicks. |
121 CHROMEGTK_CALLBACK_1(TabGtk, gboolean, OnButtonPressEvent, GdkEventButton*); | 136 CHROMEGTK_CALLBACK_1(TabGtk, gboolean, OnButtonPressEvent, GdkEventButton*); |
122 | 137 |
123 // button-release-event handler that handles mouse click releases. | 138 // button-release-event handler that handles mouse click releases. |
124 CHROMEGTK_CALLBACK_1(TabGtk, gboolean, OnButtonReleaseEvent, GdkEventButton*); | 139 CHROMEGTK_CALLBACK_1(TabGtk, gboolean, OnButtonReleaseEvent, GdkEventButton*); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 // user gestures. | 179 // user gestures. |
165 TabDelegate* delegate_; | 180 TabDelegate* delegate_; |
166 | 181 |
167 // True if the tab is being animated closed. | 182 // True if the tab is being animated closed. |
168 bool closing_; | 183 bool closing_; |
169 | 184 |
170 // True if the tab is being dragged. | 185 // True if the tab is being dragged. |
171 bool dragging_; | 186 bool dragging_; |
172 | 187 |
173 // The context menu controller. | 188 // The context menu controller. |
174 scoped_ptr<ContextMenuController> menu_controller_; | 189 scoped_ptr<TabStripMenuController> menu_controller_; |
175 | 190 |
176 // The windowless widget used to collect input events for the tab. We can't | 191 // The windowless widget used to collect input events for the tab. We can't |
177 // use an OwnedWidgetGtk because of the way the dragged tab controller | 192 // use an OwnedWidgetGtk because of the way the dragged tab controller |
178 // destroys the source tab. The source tab is destroyed when the drag ends | 193 // destroys the source tab. The source tab is destroyed when the drag ends |
179 // before we let gtk handle the end of the drag. This results in the widget | 194 // before we let gtk handle the end of the drag. This results in the widget |
180 // having an extra reference, which will cause OwnedWidgetGtk.Destroy to | 195 // having an extra reference, which will cause OwnedWidgetGtk.Destroy to |
181 // DCHECK. | 196 // DCHECK. |
182 GtkWidget* event_box_; | 197 GtkWidget* event_box_; |
183 | 198 |
184 // A copy of the last button press event, used to initiate a drag. | 199 // A copy of the last button press event, used to initiate a drag. |
(...skipping 18 matching lines...) Expand all Loading... | |
203 // mouse release event on the the dragged widget, otherwise, we don't know | 218 // mouse release event on the the dragged widget, otherwise, we don't know |
204 // when the drag has ended when the user presses space or enter. We queue | 219 // when the drag has ended when the user presses space or enter. We queue |
205 // a task to end the drag and only run it if GTK+ didn't send us the | 220 // a task to end the drag and only run it if GTK+ didn't send us the |
206 // drag-failed event. | 221 // drag-failed event. |
207 ScopedRunnableMethodFactory<TabGtk> drag_end_factory_; | 222 ScopedRunnableMethodFactory<TabGtk> drag_end_factory_; |
208 | 223 |
209 DISALLOW_COPY_AND_ASSIGN(TabGtk); | 224 DISALLOW_COPY_AND_ASSIGN(TabGtk); |
210 }; | 225 }; |
211 | 226 |
212 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_GTK_H_ | 227 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_GTK_H_ |
OLD | NEW |