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

Side by Side Diff: chrome/browser/ui/gtk/browser_titlebar.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 // 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_
11 #define CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ 11 #define CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_
12 #pragma once 12 #pragma once
13 13
14 #include <gtk/gtk.h> 14 #include <gtk/gtk.h>
15 15
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "chrome/browser/prefs/pref_member.h" 18 #include "chrome/browser/prefs/pref_member.h"
19 #include "chrome/browser/ui/gtk/browser_titlebar_base.h"
20 #include "chrome/browser/ui/gtk/browser_titlebar_throbber.h"
19 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
21 #include "ui/base/gtk/gtk_signal.h" 23 #include "ui/base/gtk/gtk_signal.h"
22 #include "ui/base/models/simple_menu_model.h" 24 #include "ui/base/models/simple_menu_model.h"
23 #include "ui/base/x/active_window_watcher_x_observer.h" 25 #include "ui/base/x/active_window_watcher_x_observer.h"
24 26
25 class AvatarMenuButtonGtk; 27 class AvatarMenuButtonGtk;
26 class BrowserWindowGtk; 28 class BrowserWindowGtk;
27 class CustomDrawButton; 29 class CustomDrawButton;
28 class GtkThemeService; 30 class GtkThemeService;
29 class MenuGtk; 31 class MenuGtk;
30 class PopupPageMenuModel; 32 class PopupPageMenuModel;
31 33
32 namespace content { 34 namespace content {
33 class WebContents; 35 class WebContents;
34 } 36 }
35 37
36 class BrowserTitlebar : public content::NotificationObserver, 38 class BrowserTitlebar : public BrowserTitlebarBase,
39 public content::NotificationObserver,
37 public ui::ActiveWindowWatcherXObserver, 40 public ui::ActiveWindowWatcherXObserver,
38 public ui::SimpleMenuModel::Delegate { 41 public ui::SimpleMenuModel::Delegate {
39 public: 42 public:
40 // A default button order string for when we aren't asking gconf for the 43 // A default button order string for when we aren't asking gconf for the
41 // metacity configuration. 44 // metacity configuration.
42 static const char kDefaultButtonString[]; 45 static const char kDefaultButtonString[];
43 46
44 BrowserTitlebar(BrowserWindowGtk* browser_window, GtkWindow* window); 47 BrowserTitlebar(BrowserWindowGtk* browser_window, GtkWindow* window);
45 virtual ~BrowserTitlebar(); 48 virtual ~BrowserTitlebar();
46 49
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
53 GtkWidget* widget() {
54 return container_;
55 }
56
57 void set_window(GtkWindow* window) { window_ = window; }
58
59 // Build the titlebar, the space above the tab strip, and (maybe) the min,
60 // max, close buttons. |container_| is the gtk container that we put the
61 // widget into.
62 void Init();
63
64 // Builds the buttons based on the metacity |button_string|. 50 // Builds the buttons based on the metacity |button_string|.
65 void BuildButtons(const std::string& button_string); 51 void BuildButtons(const std::string& button_string);
66 52
67 // Update the appearance of the title bar based on whether we're showing a 53 // Overriden from BrowserTitlebarBase.
68 // custom frame or not. If |use_custom_frame| is true, we show an extra 54 virtual void Init() OVERRIDE;
69 // tall titlebar and the min/max/close buttons. 55 virtual void UpdateTitleAndIcon() OVERRIDE;
70 void UpdateCustomFrame(bool use_custom_frame); 56 virtual void UpdateCustomFrame(bool use_custom_frame) OVERRIDE;
57 virtual void UpdateThrobber(content::WebContents* web_contents) OVERRIDE;
58 virtual void ShowContextMenu(GdkEventButton* event) OVERRIDE;
59 virtual GtkWidget* widget() const OVERRIDE;
60 virtual void set_window(GtkWindow* window) OVERRIDE;
61 virtual AvatarMenuButtonGtk* avatar_button() const OVERRIDE;
71 62
72 // Called by the browser asking us to update the loading throbber. 63 private:
73 // |web_contents| is the tab that is associated with the window throbber. 64 class ContextMenuModel : public ui::SimpleMenuModel {
74 // |web_contents| can be null. 65 public:
75 void UpdateThrobber(content::WebContents* web_contents); 66 explicit ContextMenuModel(ui::SimpleMenuModel::Delegate* delegate);
67 };
76 68
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
79 // add to the menu.
80 void ShowContextMenu(GdkEventButton* event);
81
82 AvatarMenuButtonGtk* avatar_button() { return avatar_button_.get(); }
83
84 protected:
85 // Builds the button as denoted by |button_token|. Returns true if the button 69 // Builds the button as denoted by |button_token|. Returns true if the button
86 // is created successfully. 70 // is created successfully.
87 virtual bool BuildButton(const std::string& button_token, bool left_side); 71 bool BuildButton(const std::string& button_token, bool left_side);
88 72
89 // Retrieves the 3 image ids (IDR_) and a tooltip id (IDS) for the purpose of 73 // Retrieves the 3 image ids (IDR_) and a tooltip id (IDS) for the purpose of
90 // painting a CustomDraw button. 74 // painting a CustomDraw button.
91 virtual void GetButtonResources(const std::string& button_name, 75 void GetButtonResources(const std::string& button_name,
92 int* normal_image_id, 76 int* normal_image_id,
93 int* pressed_image_id, 77 int* pressed_image_id,
94 int* hover_image_id, 78 int* hover_image_id,
95 int* tooltip_id) const; 79 int* tooltip_id) const;
96
97 // Returns the spacing around outside of titlebar buttons.
98 virtual int GetButtonOuterPadding() const;
99
100 // Returns the spacing between buttons of the titlebar.
101 virtual int GetButtonSpacing() const;
102
103 // Called when a button is clicked.
104 virtual void HandleButtonClick(GtkWidget* button);
105
106 // Show the menu that the user gets from left-clicking the favicon.
107 virtual void ShowFaviconMenu(GdkEventButton* event);
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 80
113 // Constructs a CustomDraw button given button name and left or right side of 81 // Constructs a CustomDraw button given button name and left or right side of
114 // the titlebar where the button is placed. 82 // the titlebar where the button is placed.
115 CustomDrawButton* CreateTitlebarButton(const std::string& button_name, 83 CustomDrawButton* CreateTitlebarButton(const std::string& button_name,
116 bool left_side); 84 bool left_side);
117 85
118 // Lazily builds and returns |titlebar_{left,right}_buttons_vbox_| and their 86 // Lazily builds and returns |titlebar_{left,right}_buttons_vbox_| and their
119 // subtrees. We do this lazily because in most situations, only one of them 87 // subtrees. We do this lazily because in most situations, only one of them
120 // is allocated (though the user can (and do) manually mess with their gconf 88 // is allocated (though the user can (and do) manually mess with their gconf
121 // settings to get absolutely horrid combinations of buttons on both sides. 89 // settings to get absolutely horrid combinations of buttons on both sides.
122 GtkWidget* GetButtonHBox(bool left_side); 90 GtkWidget* GetButtonHBox(bool left_side);
123 91
124 CustomDrawButton* minimize_button() const { return minimize_button_.get(); } 92 // Updates the theme supplied background color and image.
125 CustomDrawButton* maximize_button() const { return maximize_button_.get(); } 93 void UpdateButtonBackground(CustomDrawButton* button);
126 CustomDrawButton* restore_button() const { return restore_button_.get(); }
127 CustomDrawButton* close_button() const { return close_button_.get(); }
128 GtkWidget* app_mode_title() const { return app_mode_title_; }
129 94
130 GtkThemeService* theme_service() const { return theme_service_; } 95 // Show the menu that the user gets from left-clicking the favicon.
96 void ShowFaviconMenu(GdkEventButton* event);
jennb 2012/06/04 22:17:52 Can move this code back inline inside OnFavIconMen
jianli 2012/06/05 18:48:30 Done.
131 97
132 private: 98 // Updates the color of the title bar. Called whenever we have a state
133 // A helper class to keep track of which frame of the throbber animation 99 // change in the window.
134 // we're showing. 100 void UpdateTextColor();
135 class Throbber {
136 public:
137 Throbber() : current_frame_(0), current_waiting_frame_(0) {}
138
139 // Get the next frame in the animation. The image is owned by the throbber
140 // so the caller doesn't need to unref. |is_waiting| is true if we're
141 // still waiting for a response.
142 GdkPixbuf* GetNextFrame(bool is_waiting);
143
144 // Reset back to the first frame.
145 void Reset();
146 private:
147 // Make sure the frames are loaded.
148 static void InitFrames();
149
150 int current_frame_;
151 int current_waiting_frame_;
152 };
153
154 class ContextMenuModel : public ui::SimpleMenuModel {
155 public:
156 explicit ContextMenuModel(ui::SimpleMenuModel::Delegate* delegate);
157 };
158 101
159 // Update the titlebar spacing based on the custom frame and maximized state. 102 // Update the titlebar spacing based on the custom frame and maximized state.
160 void UpdateTitlebarAlignment(); 103 void UpdateTitlebarAlignment();
161 104
162 // Updates the avatar image displayed, either a multi-profile avatar or the 105 // Updates the avatar image displayed, either a multi-profile avatar or the
163 // incognito spy guy. 106 // incognito spy guy.
164 void UpdateAvatar(); 107 void UpdateAvatar();
165 108
166 // The maximize button was clicked, take an action depending on which mouse 109 // The maximize button was clicked, take an action depending on which mouse
167 // button the user pressed. 110 // button the user pressed.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 223
281 // The context menu view and model. 224 // The context menu view and model.
282 scoped_ptr<MenuGtk> context_menu_; 225 scoped_ptr<MenuGtk> context_menu_;
283 scoped_ptr<ContextMenuModel> context_menu_model_; 226 scoped_ptr<ContextMenuModel> context_menu_model_;
284 227
285 // The favicon menu view and model. 228 // The favicon menu view and model.
286 scoped_ptr<MenuGtk> favicon_menu_; 229 scoped_ptr<MenuGtk> favicon_menu_;
287 scoped_ptr<PopupPageMenuModel> favicon_menu_model_; 230 scoped_ptr<PopupPageMenuModel> favicon_menu_model_;
288 231
289 // The throbber used when the window is in app mode or popup window mode. 232 // The throbber used when the window is in app mode or popup window mode.
290 Throbber throbber_; 233 BrowserTitlebarThrobber throbber_;
291 234
292 // The avatar button. 235 // The avatar button.
293 scoped_ptr<AvatarMenuButtonGtk> avatar_button_; 236 scoped_ptr<AvatarMenuButtonGtk> avatar_button_;
294 237
295 // Theme provider for building buttons. 238 // Theme provider for building buttons.
296 GtkThemeService* theme_service_; 239 GtkThemeService* theme_service_;
297 240
298 content::NotificationRegistrar registrar_; 241 content::NotificationRegistrar registrar_;
299 }; 242 };
300 243
301 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ 244 #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') | chrome/browser/ui/gtk/browser_titlebar_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698