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_GTK_TABS_TAB_STRIP_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_TABS_TAB_STRIP_GTK_H_ |
6 #define CHROME_BROWSER_GTK_TABS_TAB_STRIP_GTK_H_ | 6 #define CHROME_BROWSER_GTK_TABS_TAB_STRIP_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
| 13 #include "chrome/browser/gtk/menu_gtk.h" |
13 #include "chrome/browser/gtk/tabs/tab_gtk.h" | 14 #include "chrome/browser/gtk/tabs/tab_gtk.h" |
14 #include "chrome/browser/tabs/tab_strip_model.h" | 15 #include "chrome/browser/tabs/tab_strip_model.h" |
15 #include "chrome/common/owned_widget_gtk.h" | 16 #include "chrome/common/owned_widget_gtk.h" |
16 | 17 |
17 class CustomDrawButton; | 18 class CustomDrawButton; |
18 class DraggedTabControllerGtk; | 19 class DraggedTabControllerGtk; |
19 | 20 |
20 class TabStripGtk : public TabStripModelObserver, | 21 class TabStripGtk : public TabStripModelObserver, |
21 public TabGtk::TabDelegate { | 22 public TabGtk::TabDelegate, |
| 23 public MenuGtk::Delegate { |
22 public: | 24 public: |
23 class TabAnimation; | 25 class TabAnimation; |
24 | 26 |
25 explicit TabStripGtk(TabStripModel* model); | 27 explicit TabStripGtk(TabStripModel* model); |
26 virtual ~TabStripGtk(); | 28 virtual ~TabStripGtk(); |
27 | 29 |
28 // Initialize and load the TabStrip into a container. | 30 // Initialize and load the TabStrip into a container. |
29 // TODO(jhawkins): We have to pass in |profile| in order to get a pointer to | 31 // TODO(jhawkins): We have to pass in |profile| in order to get a pointer to |
30 // the theme provider. In views, all instances of views::View have access to | 32 // the theme provider. In views, all instances of views::View have access to |
31 // the theme provider. | 33 // the theme provider. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 }; | 118 }; |
117 | 119 |
118 // expose-event handler that redraws the tabstrip | 120 // expose-event handler that redraws the tabstrip |
119 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, | 121 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, |
120 TabStripGtk* tabstrip); | 122 TabStripGtk* tabstrip); |
121 | 123 |
122 // size-allocate handler that gets the new bounds of the tabstrip. | 124 // size-allocate handler that gets the new bounds of the tabstrip. |
123 static void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation, | 125 static void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation, |
124 TabStripGtk* tabstrip); | 126 TabStripGtk* tabstrip); |
125 | 127 |
| 128 // Event handler for context menu popups. |
| 129 static gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event, |
| 130 TabStripGtk* tabstrip); |
| 131 |
126 // Handles the clicked signal from the new tab button. | 132 // Handles the clicked signal from the new tab button. |
127 static void OnNewTabClicked(GtkWidget* widget, TabStripGtk* tabstrip); | 133 static void OnNewTabClicked(GtkWidget* widget, TabStripGtk* tabstrip); |
128 | 134 |
129 // Renders the tabstrip background. | 135 // Renders the tabstrip background. |
130 void PaintBackground(GdkEventExpose* event); | 136 void PaintBackground(GdkEventExpose* event); |
131 | 137 |
132 // Sets the bounds of the tab and moves the tab widget to those bounds. | 138 // Sets the bounds of the tab and moves the tab widget to those bounds. |
133 void SetTabBounds(TabGtk* tab, const gfx::Rect& bounds); | 139 void SetTabBounds(TabGtk* tab, const gfx::Rect& bounds); |
134 | 140 |
135 // Initializes the new tab button. | 141 // Initializes the new tab button. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Layout method and other callers like the DraggedTabController that need | 178 // Layout method and other callers like the DraggedTabController that need |
173 // stable representations of Tab positions. | 179 // stable representations of Tab positions. |
174 void GenerateIdealBounds(); | 180 void GenerateIdealBounds(); |
175 | 181 |
176 // Lays out the New Tab button, assuming the right edge of the last Tab on | 182 // Lays out the New Tab button, assuming the right edge of the last Tab on |
177 // the TabStrip at |last_tab_right|. |unselected_width| is the width of | 183 // the TabStrip at |last_tab_right|. |unselected_width| is the width of |
178 // unselected tabs at the moment this function is called. The value changes | 184 // unselected tabs at the moment this function is called. The value changes |
179 // during animations, so we can't use current_unselected_width_. | 185 // during animations, so we can't use current_unselected_width_. |
180 void LayoutNewTabButton(double last_tab_right, double unselected_width); | 186 void LayoutNewTabButton(double last_tab_right, double unselected_width); |
181 | 187 |
| 188 // -- Context Menu ----------------------------------------------------------- |
| 189 |
| 190 // On Windows, right clicking in the tab strip background brings up the |
| 191 // system menu. There's no such thing on linux, so we just show the menu |
| 192 // items we add to the menu. |
| 193 void ShowContextMenu(); |
| 194 // MenuGtk::Delegate implementation: |
| 195 virtual bool IsCommandEnabled(int command_id) const; |
| 196 virtual void ExecuteCommand(int command_id); |
| 197 |
182 // -- Animations ------------------------------------------------------------- | 198 // -- Animations ------------------------------------------------------------- |
183 | 199 |
184 // A generic Layout method for various classes of TabStrip animations, | 200 // A generic Layout method for various classes of TabStrip animations, |
185 // including Insert, Remove and Resize Layout cases. | 201 // including Insert, Remove and Resize Layout cases. |
186 void AnimationLayout(double unselected_width); | 202 void AnimationLayout(double unselected_width); |
187 | 203 |
188 // Starts various types of TabStrip animations. | 204 // Starts various types of TabStrip animations. |
189 void StartInsertTabAnimation(int index); | 205 void StartInsertTabAnimation(int index); |
190 void StartRemoveTabAnimation(int index, TabContents* contents); | 206 void StartRemoveTabAnimation(int index, TabContents* contents); |
191 void StartResizeLayoutAnimation(); | 207 void StartResizeLayoutAnimation(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // The currently running animation. | 256 // The currently running animation. |
241 scoped_ptr<TabAnimation> active_animation_; | 257 scoped_ptr<TabAnimation> active_animation_; |
242 | 258 |
243 // The New Tab button. | 259 // The New Tab button. |
244 scoped_ptr<CustomDrawButton> newtab_button_; | 260 scoped_ptr<CustomDrawButton> newtab_button_; |
245 | 261 |
246 // The controller for a drag initiated from a Tab. Valid for the lifetime of | 262 // The controller for a drag initiated from a Tab. Valid for the lifetime of |
247 // the drag session. | 263 // the drag session. |
248 scoped_ptr<DraggedTabControllerGtk> drag_controller_; | 264 scoped_ptr<DraggedTabControllerGtk> drag_controller_; |
249 | 265 |
| 266 // The context menu. |
| 267 scoped_ptr<MenuGtk> context_menu_; |
| 268 |
250 DISALLOW_COPY_AND_ASSIGN(TabStripGtk); | 269 DISALLOW_COPY_AND_ASSIGN(TabStripGtk); |
251 }; | 270 }; |
252 | 271 |
253 #endif // CHROME_BROWSER_GTK_TABS_TAB_STRIP_GTK_H_ | 272 #endif // CHROME_BROWSER_GTK_TABS_TAB_STRIP_GTK_H_ |
OLD | NEW |