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

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

Issue 10483010: Change the visual appearance of panel on GTK per new UI design. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 8 years, 6 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_BROWSER_TITLEBAR_GTK_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_
7 7
8 #include "chrome/browser/ui/gtk/browser_titlebar.h" 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/browser_titlebar_throbber.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/base/x/active_window_watcher_x_observer.h"
9 #include "ui/gfx/skia_util.h" 19 #include "ui/gfx/skia_util.h"
10 20
21 class CustomDrawButton;
22 class GtkThemeService;
11 class PanelBrowserWindowGtk; 23 class PanelBrowserWindowGtk;
12 24
13 class PanelBrowserTitlebarGtk : public BrowserTitlebar { 25 namespace content {
26 class WebContents;
27 }
28
29 class PanelBrowserTitlebarGtk : public BrowserTitlebarBase,
30 public content::NotificationObserver,
31 public ui::ActiveWindowWatcherXObserver {
14 public: 32 public:
15 PanelBrowserTitlebarGtk(PanelBrowserWindowGtk* browser_window, 33 PanelBrowserTitlebarGtk(PanelBrowserWindowGtk* browser_window,
16 GtkWindow* window); 34 GtkWindow* window);
17 virtual ~PanelBrowserTitlebarGtk(); 35 virtual ~PanelBrowserTitlebarGtk();
18 36
37 void UpdateTextColor();
19 void UpdateMinimizeRestoreButtonVisibility(); 38 void UpdateMinimizeRestoreButtonVisibility();
20 39
21 // When a panel appears in the same position as the one of the panel being 40 // When a panel appears in the same position as the one of the panel being
22 // closed and the cursor stays in the close button, the close button appears 41 // closed and the cursor stays in the close button, the close button appears
23 // not to be clickable. This is because neither "enter-notify-event" nor 42 // not to be clickable. This is because neither "enter-notify-event" nor
24 // "clicked" event for the new panel gets fired if the mouse does not move. 43 // "clicked" event for the new panel gets fired if the mouse does not move.
25 // This creates a bad experience when a user has multiple panels of the same 44 // This creates a bad experience when a user has multiple panels of the same
26 // size (which is typical) and tries closing them all by repeatedly clicking 45 // size (which is typical) and tries closing them all by repeatedly clicking
27 // in the same place on the screen. 46 // in the same place on the screen.
28 // 47 //
29 // Opened a gtk bug for this - 48 // Opened a gtk bug for this -
30 // https://bugzilla.gnome.org/show_bug.cgi?id=667841 49 // https://bugzilla.gnome.org/show_bug.cgi?id=667841
31 void SendEnterNotifyToCloseButtonIfUnderMouse(); 50 void SendEnterNotifyToCloseButtonIfUnderMouse();
32 51
33 // Overridden from BrowserTitlebar: 52 // Overriden from BrowserTitlebarBase.
34 virtual void UpdateButtonBackground(CustomDrawButton* button) OVERRIDE; 53 virtual void Init() OVERRIDE;
35 virtual void UpdateTitleAndIcon() OVERRIDE; 54 virtual void UpdateTitleAndIcon() OVERRIDE;
36 virtual void UpdateTextColor() OVERRIDE; 55 virtual void UpdateCustomFrame(bool use_custom_frame) OVERRIDE;
37 56 virtual void UpdateThrobber(content::WebContents* web_contents) OVERRIDE;
38 protected: 57 virtual void ShowContextMenu(GdkEventButton* event) OVERRIDE;
39 // Overridden from BrowserTitlebar: 58 virtual GtkWidget* widget() const OVERRIDE;
40 virtual bool BuildButton(const std::string& button_token, 59 virtual void set_window(GtkWindow* window) OVERRIDE;
41 bool left_side) OVERRIDE; 60 virtual AvatarMenuButtonGtk* avatar_button() const OVERRIDE;
42 virtual void GetButtonResources(const std::string& button_name,
43 int* normal_image_id,
44 int* pressed_image_id,
45 int* hover_image_id,
46 int* tooltip_id) const OVERRIDE;
47 virtual int GetButtonOuterPadding() const OVERRIDE;
48 virtual int GetButtonSpacing() const OVERRIDE;
49 virtual void HandleButtonClick(GtkWidget* button) OVERRIDE;
50 virtual void ShowFaviconMenu(GdkEventButton* event) OVERRIDE;
51 61
52 private: 62 private:
53 friend class NativePanelTestingGtk; 63 friend class NativePanelTestingGtk;
54 64
55 CustomDrawButton* unminimize_button() const { 65 // Overridden from content::NotificationObserver:
56 return unminimize_button_.get(); 66 virtual void Observe(int type,
57 } 67 const content::NotificationSource& source,
68 const content::NotificationDetails& details) OVERRIDE;
69
70 // Overriden from ActiveWindowWatcherXObserver.
71 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
72
73 void BuildButtons();
74 bool BuildButton(const std::string& button_token);
75 CustomDrawButton* CreateButton(panel::TitlebarButtonType button_type);
76 void GetButtonResources(panel::TitlebarButtonType button_type,
77 int* normal_image_id,
78 int* pressed_image_id,
79 int* hover_image_id,
80 int* tooltip_id) const;
81 GtkWidget* GetButtonHBox();
82 void ShowFaviconMenu(GdkEventButton* event);
83
84 // Callback for changes to window state. This includes minimizing/restoring
85 // the window.
86 CHROMEG_CALLBACK_1(PanelBrowserTitlebarGtk, gboolean, OnWindowStateChanged,
87 GtkWindow*, GdkEventWindowState*);
88
89 // Callback for minimize/restore/close buttons.
90 CHROMEGTK_CALLBACK_0(PanelBrowserTitlebarGtk, void, OnButtonClicked);
91
92 CustomDrawButton* close_button() const { return close_button_.get(); }
93 CustomDrawButton* minimize_button() const { return minimize_button_.get(); }
94 CustomDrawButton* restore_button() const { return restore_button_.get(); }
58 95
59 SkColor GetTextColor() const; 96 SkColor GetTextColor() const;
60 97
98 // Pointers to the browser window that owns us and its GtkWindow.
61 PanelBrowserWindowGtk* browser_window_; 99 PanelBrowserWindowGtk* browser_window_;
100 GtkWindow* window_;
62 101
63 // All other buttons, including close and minimize buttons, are defined in 102 // The container widget the holds the hbox which contains the whole titlebar.
64 // the base class BrowserTitlebar. This is indeed our restore button. But 103 GtkWidget* container_;
65 // we name it differently to avoid the confusion with restore_button defined 104
66 // in the base class and used for unmaximize purpose. 105 // VBoxes that holds the minimize/restore/close buttons box.
67 scoped_ptr<CustomDrawButton> unminimize_button_; 106 GtkWidget* titlebar_right_buttons_vbox_;
107
108 // HBoxes that contains the actual min/max/close buttons.
109 GtkWidget* titlebar_right_buttons_hbox_;
110
111 // The icon and page title.
112 GtkWidget* icon_;
113 GtkWidget* title_;
114
115 // Whether we have focus (gtk_window_is_active() sometimes returns the wrong
116 // value, so manually track the focus-in and focus-out events.)
117 bool window_has_focus_;
118
119 // The buttons.
120 scoped_ptr<CustomDrawButton> close_button_;
121 scoped_ptr<CustomDrawButton> minimize_button_;
122 scoped_ptr<CustomDrawButton> restore_button_;
123
124 BrowserTitlebarThrobber throbber_;
125 GtkThemeService* theme_service_;
126 content::NotificationRegistrar registrar_;
68 127
69 DISALLOW_COPY_AND_ASSIGN(PanelBrowserTitlebarGtk); 128 DISALLOW_COPY_AND_ASSIGN(PanelBrowserTitlebarGtk);
70 }; 129 };
71 130
72 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_ 131 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_TITLEBAR_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698