| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ | |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ | |
| 7 | |
| 8 #include <gtk/gtk.h> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chrome/browser/ui/gtk/browser_titlebar_base.h" | |
| 13 #include "chrome/browser/ui/gtk/titlebar_throb_animation.h" | |
| 14 #include "chrome/browser/ui/panels/panel_constants.h" | |
| 15 #include "content/public/browser/notification_observer.h" | |
| 16 #include "content/public/browser/notification_registrar.h" | |
| 17 #include "ui/base/gtk/gtk_signal.h" | |
| 18 #include "ui/gfx/skia_util.h" | |
| 19 | |
| 20 class CustomDrawButton; | |
| 21 class GtkThemeService; | |
| 22 class PanelBrowserWindowGtk; | |
| 23 | |
| 24 namespace content { | |
| 25 class WebContents; | |
| 26 } | |
| 27 | |
| 28 class PanelBrowserTitlebarGtk : public BrowserTitlebarBase, | |
| 29 public content::NotificationObserver { | |
| 30 public: | |
| 31 PanelBrowserTitlebarGtk(PanelBrowserWindowGtk* browser_window, | |
| 32 GtkWindow* window); | |
| 33 virtual ~PanelBrowserTitlebarGtk(); | |
| 34 | |
| 35 void UpdateTextColor(); | |
| 36 void UpdateMinimizeRestoreButtonVisibility(); | |
| 37 | |
| 38 // When a panel appears in the same position as the one of the panel being | |
| 39 // closed and the cursor stays in the close button, the close button appears | |
| 40 // not to be clickable. This is because neither "enter-notify-event" nor | |
| 41 // "clicked" event for the new panel gets fired if the mouse does not move. | |
| 42 // This creates a bad experience when a user has multiple panels of the same | |
| 43 // size (which is typical) and tries closing them all by repeatedly clicking | |
| 44 // in the same place on the screen. | |
| 45 // | |
| 46 // Opened a gtk bug for this - | |
| 47 // https://bugzilla.gnome.org/show_bug.cgi?id=667841 | |
| 48 void SendEnterNotifyToCloseButtonIfUnderMouse(); | |
| 49 | |
| 50 // Overriden from BrowserTitlebarBase. | |
| 51 virtual void Init() OVERRIDE; | |
| 52 virtual void UpdateTitleAndIcon() OVERRIDE; | |
| 53 virtual void UpdateCustomFrame(bool use_custom_frame) OVERRIDE; | |
| 54 virtual void UpdateThrobber(content::WebContents* web_contents) OVERRIDE; | |
| 55 virtual void ShowContextMenu(GdkEventButton* event) OVERRIDE; | |
| 56 virtual GtkWidget* widget() const OVERRIDE; | |
| 57 virtual void set_window(GtkWindow* window) OVERRIDE; | |
| 58 virtual AvatarMenuButtonGtk* avatar_button() const OVERRIDE; | |
| 59 | |
| 60 private: | |
| 61 friend class NativePanelTestingGtk; | |
| 62 | |
| 63 // Overridden from content::NotificationObserver: | |
| 64 virtual void Observe(int type, | |
| 65 const content::NotificationSource& source, | |
| 66 const content::NotificationDetails& details) OVERRIDE; | |
| 67 | |
| 68 void BuildButtons(); | |
| 69 CustomDrawButton* CreateButton(panel::TitlebarButtonType button_type); | |
| 70 void GetButtonResources(panel::TitlebarButtonType button_type, | |
| 71 int* normal_image_id, | |
| 72 int* pressed_image_id, | |
| 73 int* hover_image_id, | |
| 74 int* tooltip_id) const; | |
| 75 GtkWidget* GetButtonHBox(); | |
| 76 | |
| 77 // Callback for changes to window state. This includes minimizing/restoring | |
| 78 // the window. | |
| 79 CHROMEG_CALLBACK_1(PanelBrowserTitlebarGtk, gboolean, OnWindowStateChanged, | |
| 80 GtkWindow*, GdkEventWindowState*); | |
| 81 | |
| 82 // Callback for minimize/restore/close buttons. | |
| 83 CHROMEGTK_CALLBACK_0(PanelBrowserTitlebarGtk, void, OnButtonClicked); | |
| 84 | |
| 85 CustomDrawButton* close_button() const { return close_button_.get(); } | |
| 86 CustomDrawButton* minimize_button() const { return minimize_button_.get(); } | |
| 87 CustomDrawButton* restore_button() const { return restore_button_.get(); } | |
| 88 | |
| 89 SkColor GetTextColor() const; | |
| 90 | |
| 91 // Pointers to the browser window that owns us and its GtkWindow. | |
| 92 PanelBrowserWindowGtk* browser_window_; | |
| 93 GtkWindow* window_; | |
| 94 | |
| 95 // The container widget the holds the hbox which contains the whole titlebar. | |
| 96 GtkWidget* container_; | |
| 97 | |
| 98 // VBoxes that holds the minimize/restore/close buttons box. | |
| 99 GtkWidget* titlebar_right_buttons_vbox_; | |
| 100 | |
| 101 // HBoxes that contains the actual min/max/close buttons. | |
| 102 GtkWidget* titlebar_right_buttons_hbox_; | |
| 103 | |
| 104 // The icon and page title. | |
| 105 GtkWidget* icon_; | |
| 106 GtkWidget* title_; | |
| 107 | |
| 108 // The buttons. | |
| 109 scoped_ptr<CustomDrawButton> close_button_; | |
| 110 scoped_ptr<CustomDrawButton> minimize_button_; | |
| 111 scoped_ptr<CustomDrawButton> restore_button_; | |
| 112 | |
| 113 TitlebarThrobAnimation throbber_; | |
| 114 GtkThemeService* theme_service_; | |
| 115 content::NotificationRegistrar registrar_; | |
| 116 | |
| 117 DISALLOW_COPY_AND_ASSIGN(PanelBrowserTitlebarGtk); | |
| 118 }; | |
| 119 | |
| 120 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ | |
| OLD | NEW |