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

Side by Side Diff: chrome/browser/ui/gtk/browser_titlebar.h

Issue 10180011: Support painting panels with chromium themes on GTK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/browser_titlebar.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A helper class that contains the gtk widgets that make up the titlebar. The 5 // A helper class that contains the gtk widgets that make up the titlebar. The
6 // titlebar consists of the tabstrip and if the custom chrome frame is turned 6 // titlebar consists of the tabstrip and if the custom chrome frame is turned
7 // on, it includes the taller titlebar and minimize, restore, maximize, and 7 // on, it includes the taller titlebar and minimize, restore, maximize, and
8 // close buttons. 8 // close buttons.
9 9
10 #ifndef CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ 10 #ifndef CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_
(...skipping 26 matching lines...) Expand all
37 public ui::ActiveWindowWatcherXObserver, 37 public ui::ActiveWindowWatcherXObserver,
38 public ui::SimpleMenuModel::Delegate { 38 public ui::SimpleMenuModel::Delegate {
39 public: 39 public:
40 // A default button order string for when we aren't asking gconf for the 40 // A default button order string for when we aren't asking gconf for the
41 // metacity configuration. 41 // metacity configuration.
42 static const char kDefaultButtonString[]; 42 static const char kDefaultButtonString[];
43 43
44 BrowserTitlebar(BrowserWindowGtk* browser_window, GtkWindow* window); 44 BrowserTitlebar(BrowserWindowGtk* browser_window, GtkWindow* window);
45 virtual ~BrowserTitlebar(); 45 virtual ~BrowserTitlebar();
46 46
47 // Updates the theme supplied background color and image.
48 virtual void UpdateButtonBackground(CustomDrawButton* button);
49
50 // Updates the title and icon when in app or popup/panel mode (no tabstrip).
51 virtual void UpdateTitleAndIcon();
52
47 GtkWidget* widget() { 53 GtkWidget* widget() {
48 return container_; 54 return container_;
49 } 55 }
50 56
51 void set_window(GtkWindow* window) { window_ = window; } 57 void set_window(GtkWindow* window) { window_ = window; }
52 58
53 // Build the titlebar, the space above the tab strip, and (maybe) the min, 59 // Build the titlebar, the space above the tab strip, and (maybe) the min,
54 // max, close buttons. |container_| is the gtk container that we put the 60 // max, close buttons. |container_| is the gtk container that we put the
55 // widget into. 61 // widget into.
56 void Init(); 62 void Init();
57 63
58 // Builds the buttons based on the metacity |button_string|. 64 // Builds the buttons based on the metacity |button_string|.
59 void BuildButtons(const std::string& button_string); 65 void BuildButtons(const std::string& button_string);
60 66
61 // Updates the theme supplied background color and image.
62 void UpdateButtonBackground(CustomDrawButton* button);
63
64 // Update the appearance of the title bar based on whether we're showing a 67 // Update the appearance of the title bar based on whether we're showing a
65 // custom frame or not. If |use_custom_frame| is true, we show an extra 68 // custom frame or not. If |use_custom_frame| is true, we show an extra
66 // tall titlebar and the min/max/close buttons. 69 // tall titlebar and the min/max/close buttons.
67 void UpdateCustomFrame(bool use_custom_frame); 70 void UpdateCustomFrame(bool use_custom_frame);
68 71
69 // Updates the title and icon when in app or popup mode (no tabstrip).
70 void UpdateTitleAndIcon();
71
72 // Called by the browser asking us to update the loading throbber. 72 // Called by the browser asking us to update the loading throbber.
73 // |web_contents| is the tab that is associated with the window throbber. 73 // |web_contents| is the tab that is associated with the window throbber.
74 // |web_contents| can be null. 74 // |web_contents| can be null.
75 void UpdateThrobber(content::WebContents* web_contents); 75 void UpdateThrobber(content::WebContents* web_contents);
76 76
77 // On Windows, right clicking in the titlebar background brings up the system 77 // On Windows, right clicking in the titlebar background brings up the system
78 // menu. There's no such thing on linux, so we just show the menu items we 78 // menu. There's no such thing on linux, so we just show the menu items we
79 // add to the menu. 79 // add to the menu.
80 void ShowContextMenu(GdkEventButton* event); 80 void ShowContextMenu(GdkEventButton* event);
81 81
82 // When a panel appears in the same position as the one of the panel being
83 // closed and the cursor stays in the close button, the close button appears
84 // not to be clickable. This is because neither "enter-notify-event" nor
85 // "clicked" event for the new panel gets fired if the mouse does not move.
86 // This creates a bad experience when a user has multiple panels of the same
87 // size (which is typical) and tries closing them all by repeatedly clicking
88 // in the same place on the screen.
89 //
90 // Opened a gtk bug for this -
91 // https://bugzilla.gnome.org/show_bug.cgi?id=667841
92 void SendEnterNotifyToCloseButtonIfUnderMouse();
93
94 // Returns the window width to display just the icon.
95 int IconOnlyWidth();
96
97 AvatarMenuButtonGtk* avatar_button() { return avatar_button_.get(); } 82 AvatarMenuButtonGtk* avatar_button() { return avatar_button_.get(); }
98 83
99 protected: 84 protected:
100 // Builds the button as denoted by |button_token|. Returns true if the button 85 // Builds the button as denoted by |button_token|. Returns true if the button
101 // is created successfully. 86 // is created successfully.
102 virtual bool BuildButton(const std::string& button_token, bool left_side); 87 virtual bool BuildButton(const std::string& button_token, bool left_side);
103 88
104 // Retrieves the 3 image ids (IDR_) and a tooltip id (IDS) for the purpose of 89 // Retrieves the 3 image ids (IDR_) and a tooltip id (IDS) for the purpose of
105 // painting a CustomDraw button. 90 // painting a CustomDraw button.
106 virtual void GetButtonResources(const std::string& button_name, 91 virtual void GetButtonResources(const std::string& button_name,
107 int* normal_image_id, 92 int* normal_image_id,
108 int* pressed_image_id, 93 int* pressed_image_id,
109 int* hover_image_id, 94 int* hover_image_id,
110 int* tooltip_id) const; 95 int* tooltip_id) const;
111 96
112 // Returns the spacing around outside of titlebar buttons. 97 // Returns the spacing around outside of titlebar buttons.
113 virtual int GetButtonOuterPadding() const; 98 virtual int GetButtonOuterPadding() const;
114 99
115 // Returns the spacing between buttons of the titlebar. 100 // Returns the spacing between buttons of the titlebar.
116 virtual int GetButtonSpacing() const; 101 virtual int GetButtonSpacing() const;
117 102
118 // Called when a button is clicked. 103 // Called when a button is clicked.
119 virtual void HandleButtonClick(GtkWidget* button); 104 virtual void HandleButtonClick(GtkWidget* button);
120 105
121 // Show the menu that the user gets from left-clicking the favicon. 106 // Show the menu that the user gets from left-clicking the favicon.
122 virtual void ShowFaviconMenu(GdkEventButton* event); 107 virtual void ShowFaviconMenu(GdkEventButton* event);
123 108
109 // Updates the color of the title bar. Called whenever we have a state
110 // change in the window.
111 virtual void UpdateTextColor();
112
124 // Constructs a CustomDraw button given button name and left or right side of 113 // Constructs a CustomDraw button given button name and left or right side of
125 // the titlebar where the button is placed. 114 // the titlebar where the button is placed.
126 CustomDrawButton* CreateTitlebarButton(const std::string& button_name, 115 CustomDrawButton* CreateTitlebarButton(const std::string& button_name,
127 bool left_side); 116 bool left_side);
128 117
129 // Lazily builds and returns |titlebar_{left,right}_buttons_vbox_| and their 118 // Lazily builds and returns |titlebar_{left,right}_buttons_vbox_| and their
130 // subtrees. We do this lazily because in most situations, only one of them 119 // subtrees. We do this lazily because in most situations, only one of them
131 // is allocated (though the user can (and do) manually mess with their gconf 120 // is allocated (though the user can (and do) manually mess with their gconf
132 // settings to get absolutely horrid combinations of buttons on both sides. 121 // settings to get absolutely horrid combinations of buttons on both sides.
133 GtkWidget* GetButtonHBox(bool left_side); 122 GtkWidget* GetButtonHBox(bool left_side);
134 123
135 CustomDrawButton* minimize_button() const { return minimize_button_.get(); } 124 CustomDrawButton* minimize_button() const { return minimize_button_.get(); }
136 CustomDrawButton* maximize_button() const { return maximize_button_.get(); } 125 CustomDrawButton* maximize_button() const { return maximize_button_.get(); }
137 CustomDrawButton* restore_button() const { return restore_button_.get(); } 126 CustomDrawButton* restore_button() const { return restore_button_.get(); }
138 CustomDrawButton* close_button() const { return close_button_.get(); } 127 CustomDrawButton* close_button() const { return close_button_.get(); }
128 GtkWidget* app_mode_title() const { return app_mode_title_; }
129
130 ThemeServiceGtk* theme_service() const { return theme_service_; }
139 131
140 private: 132 private:
141 // A helper class to keep track of which frame of the throbber animation 133 // A helper class to keep track of which frame of the throbber animation
142 // we're showing. 134 // we're showing.
143 class Throbber { 135 class Throbber {
144 public: 136 public:
145 Throbber() : current_frame_(0), current_waiting_frame_(0) {} 137 Throbber() : current_frame_(0), current_waiting_frame_(0) {}
146 138
147 // Get the next frame in the animation. The image is owned by the throbber 139 // Get the next frame in the animation. The image is owned by the throbber
148 // so the caller doesn't need to unref. |is_waiting| is true if we're 140 // so the caller doesn't need to unref. |is_waiting| is true if we're
(...skipping 11 matching lines...) Expand all
160 }; 152 };
161 153
162 class ContextMenuModel : public ui::SimpleMenuModel { 154 class ContextMenuModel : public ui::SimpleMenuModel {
163 public: 155 public:
164 explicit ContextMenuModel(ui::SimpleMenuModel::Delegate* delegate); 156 explicit ContextMenuModel(ui::SimpleMenuModel::Delegate* delegate);
165 }; 157 };
166 158
167 // Update the titlebar spacing based on the custom frame and maximized state. 159 // Update the titlebar spacing based on the custom frame and maximized state.
168 void UpdateTitlebarAlignment(); 160 void UpdateTitlebarAlignment();
169 161
170 // Updates the color of the title bar. Called whenever we have a state
171 // change in the window.
172 void UpdateTextColor();
173
174 // Updates the avatar image displayed, either a multi-profile avatar or the 162 // Updates the avatar image displayed, either a multi-profile avatar or the
175 // incognito spy guy. 163 // incognito spy guy.
176 void UpdateAvatar(); 164 void UpdateAvatar();
177 165
178 // The maximize button was clicked, take an action depending on which mouse 166 // The maximize button was clicked, take an action depending on which mouse
179 // button the user pressed. 167 // button the user pressed.
180 void MaximizeButtonClicked(); 168 void MaximizeButtonClicked();
181 169
182 // Updates the visibility of the maximize and restore buttons; only one can 170 // Updates the visibility of the maximize and restore buttons; only one can
183 // be visible at a time. 171 // be visible at a time.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // The avatar button. 292 // The avatar button.
305 scoped_ptr<AvatarMenuButtonGtk> avatar_button_; 293 scoped_ptr<AvatarMenuButtonGtk> avatar_button_;
306 294
307 // Theme provider for building buttons. 295 // Theme provider for building buttons.
308 ThemeServiceGtk* theme_service_; 296 ThemeServiceGtk* theme_service_;
309 297
310 content::NotificationRegistrar registrar_; 298 content::NotificationRegistrar registrar_;
311 }; 299 };
312 300
313 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ 301 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/browser_titlebar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698