| OLD | NEW |
| 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_GTK_TABS_TAB_STRIP_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h" | 17 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h" |
| 17 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" | 18 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" |
| 18 #include "chrome/browser/ui/gtk/view_id_util.h" | 19 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 19 #include "chrome/browser/ui/tabs/hover_tab_selector.h" | 20 #include "chrome/browser/ui/tabs/hover_tab_selector.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 23 #include "ui/base/gtk/gtk_signal.h" | 24 #include "ui/base/gtk/gtk_signal.h" |
| 24 #include "ui/base/gtk/owned_widget_gtk.h" | 25 #include "ui/base/gtk/owned_widget_gtk.h" |
| 25 #include "ui/gfx/rect.h" | 26 #include "ui/gfx/rect.h" |
| 26 | 27 |
| 27 class BrowserWindowGtk; | 28 class BrowserWindowGtk; |
| 28 class CustomDrawButton; | 29 class CustomDrawButton; |
| 29 class DraggedTabControllerGtk; | 30 class DraggedTabControllerGtk; |
| 30 class GtkThemeService; | 31 class GtkThemeService; |
| 32 class RecentlyClosedTabsMenuModel; |
| 31 | 33 |
| 32 namespace gfx { | 34 namespace gfx { |
| 33 class Image; | 35 class Image; |
| 34 } | 36 } |
| 35 | 37 |
| 36 class TabStripGtk : public TabStripModelObserver, | 38 class TabStripGtk : public TabStripModelObserver, |
| 37 public TabGtk::TabDelegate, | 39 public TabGtk::TabDelegate, |
| 38 public MessageLoopForUI::Observer, | 40 public MessageLoopForUI::Observer, |
| 39 public content::NotificationObserver, | 41 public content::NotificationObserver, |
| 40 public TabstripOriginProvider, | 42 public TabstripOriginProvider, |
| 41 public ViewIDUtil::Delegate { | 43 public ViewIDUtil::Delegate, |
| 44 public MenuGtk::Delegate { |
| 42 public: | 45 public: |
| 43 class TabAnimation; | 46 class TabAnimation; |
| 44 | 47 |
| 45 TabStripGtk(TabStripModel* model, BrowserWindowGtk* window); | 48 TabStripGtk(TabStripModel* model, BrowserWindowGtk* window); |
| 46 virtual ~TabStripGtk(); | 49 virtual ~TabStripGtk(); |
| 47 | 50 |
| 48 // Initialize and load the TabStrip into a container. | 51 // Initialize and load the TabStrip into a container. |
| 49 // TODO(tc): Pass in theme provider so we can properly theme the tabs. | 52 // TODO(tc): Pass in theme provider so we can properly theme the tabs. |
| 50 void Init(); | 53 void Init(); |
| 51 | 54 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // background image. Passed in from the titlebar and based on the size of the | 103 // background image. Passed in from the titlebar and based on the size of the |
| 101 // alignment that sits above the tabstrip. | 104 // alignment that sits above the tabstrip. |
| 102 void SetVerticalOffset(int offset); | 105 void SetVerticalOffset(int offset); |
| 103 | 106 |
| 104 // TabstripOriginProvider implementation ------------------------------------- | 107 // TabstripOriginProvider implementation ------------------------------------- |
| 105 virtual gfx::Point GetTabStripOriginForWidget(GtkWidget* widget) OVERRIDE; | 108 virtual gfx::Point GetTabStripOriginForWidget(GtkWidget* widget) OVERRIDE; |
| 106 | 109 |
| 107 // ViewIDUtil::Delegate implementation --------------------------------------- | 110 // ViewIDUtil::Delegate implementation --------------------------------------- |
| 108 virtual GtkWidget* GetWidgetForViewID(ViewID id) OVERRIDE; | 111 virtual GtkWidget* GetWidgetForViewID(ViewID id) OVERRIDE; |
| 109 | 112 |
| 113 virtual bool AlwaysShowIconForCmd(int command_id) const OVERRIDE; |
| 114 |
| 110 protected: | 115 protected: |
| 111 // TabStripModelObserver implementation: | 116 // TabStripModelObserver implementation: |
| 112 virtual void TabInsertedAt(TabContentsWrapper* contents, | 117 virtual void TabInsertedAt(TabContentsWrapper* contents, |
| 113 int index, | 118 int index, |
| 114 bool foreground) OVERRIDE; | 119 bool foreground) OVERRIDE; |
| 115 virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE; | 120 virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE; |
| 116 virtual void TabMoved(TabContentsWrapper* contents, | 121 virtual void TabMoved(TabContentsWrapper* contents, |
| 117 int from_index, | 122 int from_index, |
| 118 int to_index) OVERRIDE; | 123 int to_index) OVERRIDE; |
| 119 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 124 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // drag-leave handler that is signaled when the mouse leaves the tabstrip | 271 // drag-leave handler that is signaled when the mouse leaves the tabstrip |
| 267 // during a drag. | 272 // during a drag. |
| 268 CHROMEGTK_CALLBACK_2(TabStripGtk, gboolean, OnDragLeave, GdkDragContext*, | 273 CHROMEGTK_CALLBACK_2(TabStripGtk, gboolean, OnDragLeave, GdkDragContext*, |
| 269 guint); | 274 guint); |
| 270 | 275 |
| 271 // drag-data-received handler that receives the data associated with the drag. | 276 // drag-data-received handler that receives the data associated with the drag. |
| 272 CHROMEGTK_CALLBACK_6(TabStripGtk, gboolean, OnDragDataReceived, | 277 CHROMEGTK_CALLBACK_6(TabStripGtk, gboolean, OnDragDataReceived, |
| 273 GdkDragContext*, gint, gint, GtkSelectionData*, | 278 GdkDragContext*, gint, gint, GtkSelectionData*, |
| 274 guint, guint); | 279 guint, guint); |
| 275 | 280 |
| 281 // Starts a timer to show the dropdown menu. |
| 282 CHROMEGTK_CALLBACK_1(TabStripGtk, gboolean, OnButtonPress, |
| 283 GdkEventButton*); |
| 284 |
| 276 // Handles the clicked signal from the new tab button. | 285 // Handles the clicked signal from the new tab button. |
| 277 CHROMEGTK_CALLBACK_0(TabStripGtk, void, OnNewTabClicked); | 286 CHROMEGTK_CALLBACK_0(TabStripGtk, void, OnNewTabClicked); |
| 278 | 287 |
| 279 // Sets the bounds of the tab and moves the tab widget to those bounds. | 288 // Sets the bounds of the tab and moves the tab widget to those bounds. |
| 280 void SetTabBounds(TabGtk* tab, const gfx::Rect& bounds); | 289 void SetTabBounds(TabGtk* tab, const gfx::Rect& bounds); |
| 281 | 290 |
| 282 // Returns true if |rects| are all areas that match up with tab favicons. | 291 // Returns true if |rects| are all areas that match up with tab favicons. |
| 283 // |rects| must be sorted from left to right. |tabs_to_paint| are the tab | 292 // |rects| must be sorted from left to right. |tabs_to_paint| are the tab |
| 284 // positions that match the rects. | 293 // positions that match the rects. |
| 285 bool CanPaintOnlyFavicons(const GdkRectangle* rects, | 294 bool CanPaintOnlyFavicons(const GdkRectangle* rects, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 void StartMiniTabAnimation(int index); | 425 void StartMiniTabAnimation(int index); |
| 417 void StartMiniMoveTabAnimation(int from_index, | 426 void StartMiniMoveTabAnimation(int from_index, |
| 418 int to_index, | 427 int to_index, |
| 419 const gfx::Rect& start_bounds); | 428 const gfx::Rect& start_bounds); |
| 420 void StartResizeLayoutAnimation(); | 429 void StartResizeLayoutAnimation(); |
| 421 | 430 |
| 422 // Notifies the TabStrip that the specified TabAnimation has completed. | 431 // Notifies the TabStrip that the specified TabAnimation has completed. |
| 423 // Optionally a full Layout will be performed, specified by |layout|. | 432 // Optionally a full Layout will be performed, specified by |layout|. |
| 424 void FinishAnimation(TabAnimation* animation, bool layout); | 433 void FinishAnimation(TabAnimation* animation, bool layout); |
| 425 | 434 |
| 435 // Shows the dropdown menu. |
| 436 void ShowRecentlyClosedTabsMenu(GtkWidget* widget, |
| 437 int button, guint32 event_time); |
| 438 |
| 426 // The Tabs we contain, and their last generated "good" bounds. | 439 // The Tabs we contain, and their last generated "good" bounds. |
| 427 std::vector<TabData> tab_data_; | 440 std::vector<TabData> tab_data_; |
| 428 | 441 |
| 429 // The current widths of various types of tabs. We save these so that, as | 442 // The current widths of various types of tabs. We save these so that, as |
| 430 // users close tabs while we're holding them at the same size, we can lay out | 443 // users close tabs while we're holding them at the same size, we can lay out |
| 431 // tabs exactly and eliminate the "pixel jitter" we'd get from just leaving | 444 // tabs exactly and eliminate the "pixel jitter" we'd get from just leaving |
| 432 // them all at their existing, rounded widths. | 445 // them all at their existing, rounded widths. |
| 433 double current_unselected_width_; | 446 double current_unselected_width_; |
| 434 double current_selected_width_; | 447 double current_selected_width_; |
| 435 | 448 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 base::WeakPtrFactory<TabStripGtk> layout_factory_; | 502 base::WeakPtrFactory<TabStripGtk> layout_factory_; |
| 490 | 503 |
| 491 // True if the tabstrip has already been added as a MessageLoop observer. | 504 // True if the tabstrip has already been added as a MessageLoop observer. |
| 492 bool added_as_message_loop_observer_; | 505 bool added_as_message_loop_observer_; |
| 493 | 506 |
| 494 // Helper for performing tab selection as a result of dragging over a tab. | 507 // Helper for performing tab selection as a result of dragging over a tab. |
| 495 HoverTabSelector hover_tab_selector_; | 508 HoverTabSelector hover_tab_selector_; |
| 496 | 509 |
| 497 content::NotificationRegistrar registrar_; | 510 content::NotificationRegistrar registrar_; |
| 498 | 511 |
| 512 // The dropdown menu model. |
| 513 scoped_ptr<RecentlyClosedTabsMenuModel> menu_model_; |
| 514 |
| 515 // The menu gets reset every time it is shown. |
| 516 scoped_ptr<MenuGtk> menu_; |
| 517 |
| 499 DISALLOW_COPY_AND_ASSIGN(TabStripGtk); | 518 DISALLOW_COPY_AND_ASSIGN(TabStripGtk); |
| 500 }; | 519 }; |
| 501 | 520 |
| 502 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ | 521 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ |
| OLD | NEW |