Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1657)

Side by Side Diff: chrome/browser/ui/panels/panel_titlebar_gtk.h

Issue 10831226: Panels refactor: Support browserless panels on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_GTK_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ 6 #define CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_GTK_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.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" 12 #include "chrome/browser/ui/gtk/titlebar_throb_animation.h"
14 #include "chrome/browser/ui/panels/panel_constants.h" 13 #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" 14 #include "ui/base/gtk/gtk_signal.h"
18 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
19 16
20 class CustomDrawButton; 17 class CustomDrawButton;
21 class GtkThemeService; 18 class GtkThemeService;
22 class PanelBrowserWindowGtk; 19 class PanelGtk;
23 20
24 namespace content { 21 namespace content {
25 class WebContents; 22 class WebContents;
26 } 23 }
27 24
28 class PanelBrowserTitlebarGtk : public BrowserTitlebarBase, 25 class PanelTitlebarGtk {
29 public content::NotificationObserver {
30 public: 26 public:
31 PanelBrowserTitlebarGtk(PanelBrowserWindowGtk* browser_window, 27 explicit PanelTitlebarGtk(PanelGtk* panel_gtk);
32 GtkWindow* window); 28 virtual ~PanelTitlebarGtk();
33 virtual ~PanelBrowserTitlebarGtk();
34 29
35 void UpdateTextColor(); 30 void UpdateTextColor();
36 void UpdateMinimizeRestoreButtonVisibility(); 31 void UpdateMinimizeRestoreButtonVisibility();
37 32
38 // When a panel appears in the same position as the one of the panel being 33 // 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 34 // 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 35 // 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. 36 // "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 37 // 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 38 // size (which is typical) and tries closing them all by repeatedly clicking
44 // in the same place on the screen. 39 // in the same place on the screen.
45 // 40 //
46 // Opened a gtk bug for this - 41 // Opened a gtk bug for this -
47 // https://bugzilla.gnome.org/show_bug.cgi?id=667841 42 // https://bugzilla.gnome.org/show_bug.cgi?id=667841
48 void SendEnterNotifyToCloseButtonIfUnderMouse(); 43 void SendEnterNotifyToCloseButtonIfUnderMouse();
49 44
50 // Overriden from BrowserTitlebarBase. 45 void Init();
51 virtual void Init() OVERRIDE; 46 void UpdateTitleAndIcon();
52 virtual void UpdateTitleAndIcon() OVERRIDE; 47 void UpdateThrobber(content::WebContents* web_contents);
53 virtual void UpdateCustomFrame(bool use_custom_frame) OVERRIDE; 48 GtkWidget* widget() const;
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 49
60 private: 50 private:
61 friend class NativePanelTestingGtk; 51 friend class GtkNativePanelTesting;
62
63 // Overridden from content::NotificationObserver:
64 virtual void Observe(int type,
65 const content::NotificationSource& source,
66 const content::NotificationDetails& details) OVERRIDE;
67 52
68 void BuildButtons(); 53 void BuildButtons();
69 CustomDrawButton* CreateButton(panel::TitlebarButtonType button_type); 54 CustomDrawButton* CreateButton(panel::TitlebarButtonType button_type);
70 void GetButtonResources(panel::TitlebarButtonType button_type, 55 void GetButtonResources(panel::TitlebarButtonType button_type,
71 int* normal_image_id, 56 int* normal_image_id,
72 int* pressed_image_id, 57 int* pressed_image_id,
73 int* hover_image_id, 58 int* hover_image_id,
74 int* tooltip_id) const; 59 int* tooltip_id) const;
75 GtkWidget* GetButtonHBox(); 60 GtkWidget* GetButtonHBox();
76 61
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. 62 // Callback for minimize/restore/close buttons.
83 CHROMEGTK_CALLBACK_0(PanelBrowserTitlebarGtk, void, OnButtonClicked); 63 CHROMEGTK_CALLBACK_0(PanelTitlebarGtk, void, OnButtonClicked);
84 64
85 CustomDrawButton* close_button() const { return close_button_.get(); } 65 CustomDrawButton* close_button() const { return close_button_.get(); }
86 CustomDrawButton* minimize_button() const { return minimize_button_.get(); } 66 CustomDrawButton* minimize_button() const { return minimize_button_.get(); }
87 CustomDrawButton* restore_button() const { return restore_button_.get(); } 67 CustomDrawButton* restore_button() const { return restore_button_.get(); }
88 68
89 SkColor GetTextColor() const; 69 SkColor GetTextColor() const;
90 70
91 // Pointers to the browser window that owns us and its GtkWindow. 71 // Pointers to the native panel window that owns us and its GtkWindow.
92 PanelBrowserWindowGtk* browser_window_; 72 PanelGtk* panel_gtk_;
93 GtkWindow* window_;
94 73
95 // The container widget the holds the hbox which contains the whole titlebar. 74 // The container widget the holds the hbox which contains the whole titlebar.
96 GtkWidget* container_; 75 GtkWidget* container_;
97 76
98 // VBoxes that holds the minimize/restore/close buttons box. 77 // VBoxes that holds the minimize/restore/close buttons box.
99 GtkWidget* titlebar_right_buttons_vbox_; 78 GtkWidget* titlebar_right_buttons_vbox_;
100 79
101 // HBoxes that contains the actual min/max/close buttons. 80 // HBoxes that contains the actual min/max/close buttons.
102 GtkWidget* titlebar_right_buttons_hbox_; 81 GtkWidget* titlebar_right_buttons_hbox_;
103 82
104 // The icon and page title. 83 // The icon and page title.
105 GtkWidget* icon_; 84 GtkWidget* icon_;
106 GtkWidget* title_; 85 GtkWidget* title_;
107 86
108 // The buttons. 87 // The buttons.
109 scoped_ptr<CustomDrawButton> close_button_; 88 scoped_ptr<CustomDrawButton> close_button_;
110 scoped_ptr<CustomDrawButton> minimize_button_; 89 scoped_ptr<CustomDrawButton> minimize_button_;
111 scoped_ptr<CustomDrawButton> restore_button_; 90 scoped_ptr<CustomDrawButton> restore_button_;
112 91
113 TitlebarThrobAnimation throbber_; 92 TitlebarThrobAnimation throbber_;
114 GtkThemeService* theme_service_; 93 GtkThemeService* theme_service_;
115 content::NotificationRegistrar registrar_;
116 94
117 DISALLOW_COPY_AND_ASSIGN(PanelBrowserTitlebarGtk); 95 DISALLOW_COPY_AND_ASSIGN(PanelTitlebarGtk);
118 }; 96 };
119 97
120 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ 98 #endif // CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698