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

Side by Side Diff: chrome/browser/gtk/browser_toolbar_gtk.h

Issue 2985006: GTK: reduce cpu usage of upgrade notification animation. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: merge to ToT Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_GTK_BROWSER_TOOLBAR_GTK_H_ 5 #ifndef CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_
6 #define CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ 6 #define CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <string> 9 #include <string>
10 10
11 #include "app/active_window_watcher_x.h"
11 #include "app/gtk_signal.h" 12 #include "app/gtk_signal.h"
12 #include "app/menus/simple_menu_model.h" 13 #include "app/menus/simple_menu_model.h"
13 #include "app/throb_animation.h" 14 #include "app/throb_animation.h"
14 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
15 #include "chrome/browser/app_menu_model.h" 16 #include "chrome/browser/app_menu_model.h"
16 #include "chrome/browser/command_updater.h" 17 #include "chrome/browser/command_updater.h"
17 #include "chrome/browser/gtk/custom_button.h" 18 #include "chrome/browser/gtk/custom_button.h"
18 #include "chrome/browser/gtk/menu_bar_helper.h" 19 #include "chrome/browser/gtk/menu_bar_helper.h"
19 #include "chrome/browser/gtk/menu_gtk.h" 20 #include "chrome/browser/gtk/menu_gtk.h"
20 #include "chrome/browser/page_menu_model.h" 21 #include "chrome/browser/page_menu_model.h"
(...skipping 16 matching lines...) Expand all
37 class TabContents; 38 class TabContents;
38 class ToolbarModel; 39 class ToolbarModel;
39 40
40 // View class that displays the GTK version of the toolbar and routes gtk 41 // View class that displays the GTK version of the toolbar and routes gtk
41 // events back to the Browser. 42 // events back to the Browser.
42 class BrowserToolbarGtk : public CommandUpdater::CommandObserver, 43 class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
43 public menus::SimpleMenuModel::Delegate, 44 public menus::SimpleMenuModel::Delegate,
44 public MenuGtk::Delegate, 45 public MenuGtk::Delegate,
45 public NotificationObserver, 46 public NotificationObserver,
46 public MenuBarHelper::Delegate, 47 public MenuBarHelper::Delegate,
47 public AnimationDelegate { 48 public AnimationDelegate,
49 public ActiveWindowWatcherX::Observer {
48 public: 50 public:
49 explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window); 51 explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window);
50 virtual ~BrowserToolbarGtk(); 52 virtual ~BrowserToolbarGtk();
51 53
52 // Create the contents of the toolbar. |top_level_window| is the GtkWindow 54 // Create the contents of the toolbar. |top_level_window| is the GtkWindow
53 // to which we attach our accelerators. 55 // to which we attach our accelerators.
54 void Init(Profile* profile, GtkWindow* top_level_window); 56 void Init(Profile* profile, GtkWindow* top_level_window);
55 57
56 // Set the various widgets' ViewIDs. 58 // Set the various widgets' ViewIDs.
57 void SetViewIDs(); 59 void SetViewIDs();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // MenuBarHelper::Delegate implementation ------------------------------------ 121 // MenuBarHelper::Delegate implementation ------------------------------------
120 virtual void PopupForButton(GtkWidget* button); 122 virtual void PopupForButton(GtkWidget* button);
121 virtual void PopupForButtonNextTo(GtkWidget* button, 123 virtual void PopupForButtonNextTo(GtkWidget* button,
122 GtkMenuDirectionType dir); 124 GtkMenuDirectionType dir);
123 125
124 // AnimationDelegate implementation ------------------------------------------ 126 // AnimationDelegate implementation ------------------------------------------
125 virtual void AnimationEnded(const Animation* animation); 127 virtual void AnimationEnded(const Animation* animation);
126 virtual void AnimationProgressed(const Animation* animation); 128 virtual void AnimationProgressed(const Animation* animation);
127 virtual void AnimationCanceled(const Animation* animation); 129 virtual void AnimationCanceled(const Animation* animation);
128 130
131 // ActiveWindowWatcher::Observer implementation ------------------------------
132 virtual void ActiveWindowChanged(GdkWindow* active_window);
133
129 private: 134 private:
130 // Builds a toolbar button with all the properties set. 135 // Builds a toolbar button with all the properties set.
131 // |spacing| is the width of padding (in pixels) on the left and right of the 136 // |spacing| is the width of padding (in pixels) on the left and right of the
132 // button. 137 // button.
133 CustomDrawButton* BuildToolbarButton(int normal_id, 138 CustomDrawButton* BuildToolbarButton(int normal_id,
134 int active_id, 139 int active_id,
135 int highlight_id, 140 int highlight_id,
136 int depressed_id, 141 int depressed_id,
137 int background_id, 142 int background_id,
138 const std::string& localized_tooltip, 143 const std::string& localized_tooltip,
(...skipping 10 matching lines...) Expand all
149 154
150 // Helper for the PageAppMenu event handlers. Pops down the currently active 155 // Helper for the PageAppMenu event handlers. Pops down the currently active
151 // meun and pops up the other menu. 156 // meun and pops up the other menu.
152 void ChangeActiveMenu(GtkWidget* active_menu, guint timestamp); 157 void ChangeActiveMenu(GtkWidget* active_menu, guint timestamp);
153 158
154 // Sets the top corners of the toolbar to rounded, or sets them to normal, 159 // Sets the top corners of the toolbar to rounded, or sets them to normal,
155 // depending on the state of the browser window. Returns false if no action 160 // depending on the state of the browser window. Returns false if no action
156 // was taken (the roundedness was already correct), true otherwise. 161 // was taken (the roundedness was already correct), true otherwise.
157 bool UpdateRoundedness(); 162 bool UpdateRoundedness();
158 163
164 // Calculates whether the upgrade notification dot should be faded at all
165 // (as opposed to solid).
166 bool UpgradeAnimationIsFaded();
167
159 // Gtk callback for the "expose-event" signal. 168 // Gtk callback for the "expose-event" signal.
160 // The alignment contains the toolbar. 169 // The alignment contains the toolbar.
161 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnAlignmentExpose, 170 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnAlignmentExpose,
162 GdkEventExpose*); 171 GdkEventExpose*);
163 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnLocationHboxExpose, 172 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnLocationHboxExpose,
164 GdkEventExpose*); 173 GdkEventExpose*);
165 174
166 // Gtk callback for the "clicked" signal. 175 // Gtk callback for the "clicked" signal.
167 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnButtonClick); 176 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnButtonClick);
168 177
169 // Gtk callback to intercept mouse clicks to the menu buttons. 178 // Gtk callback to intercept mouse clicks to the menu buttons.
170 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnMenuButtonPressEvent, 179 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnMenuButtonPressEvent,
171 GdkEventButton*); 180 GdkEventButton*);
172 181
173 // Used for drags onto home button. 182 // Used for drags onto home button.
174 CHROMEGTK_CALLBACK_6(BrowserToolbarGtk, void, OnDragDataReceived, 183 CHROMEGTK_CALLBACK_6(BrowserToolbarGtk, void, OnDragDataReceived,
175 GdkDragContext*, gint, gint, GtkSelectionData*, 184 GdkDragContext*, gint, gint, GtkSelectionData*,
176 guint, guint); 185 guint, guint);
177 186
178 // Used to stop the upgrade notification animation. 187 // Used to stop the upgrade notification animation.
179 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnAppMenuShow); 188 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnAppMenuShow);
180 189
181 // Used to draw the upgrade notification badge. 190 // Used to draw the upgrade notification badge.
182 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnAppMenuImageExpose, 191 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnAppMenuImageExpose,
183 GdkEventExpose*); 192 GdkEventExpose*);
184 193
185 // Updates preference-dependent state. 194 // Updates preference-dependent state.
186 void NotifyPrefChanged(const std::wstring* pref); 195 void NotifyPrefChanged(const std::wstring* pref);
187 196
188 // Start the upgrade notification animation. 197 // Start the upgrade notification animation if we have detected an upgrade
189 void ShowUpgradeReminder(); 198 // and the current toolbar is focused.
199 void MaybeShowUpgradeReminder();
190 200
191 static void SetSyncMenuLabel(GtkWidget* widget, gpointer userdata); 201 static void SetSyncMenuLabel(GtkWidget* widget, gpointer userdata);
192 202
193 // Sometimes we only want to show the location w/o the toolbar buttons (e.g., 203 // Sometimes we only want to show the location w/o the toolbar buttons (e.g.,
194 // in a popup window). 204 // in a popup window).
195 bool ShouldOnlyShowLocation() const; 205 bool ShouldOnlyShowLocation() const;
196 206
197 // An event box that holds |toolbar_|. We need the toolbar to have its own 207 // An event box that holds |toolbar_|. We need the toolbar to have its own
198 // GdkWindow when we use the GTK drawing because otherwise the color from our 208 // GdkWindow when we use the GTK drawing because otherwise the color from our
199 // parent GdkWindow will leak through with some theme engines (such as 209 // parent GdkWindow will leak through with some theme engines (such as
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // rendering. 271 // rendering.
262 OwnedWidgetGtk offscreen_entry_; 272 OwnedWidgetGtk offscreen_entry_;
263 273
264 MenuBarHelper menu_bar_helper_; 274 MenuBarHelper menu_bar_helper_;
265 275
266 // Manages the home button drop signal handler. 276 // Manages the home button drop signal handler.
267 scoped_ptr<GtkSignalRegistrar> drop_handler_; 277 scoped_ptr<GtkSignalRegistrar> drop_handler_;
268 278
269 ThrobAnimation upgrade_reminder_animation_; 279 ThrobAnimation upgrade_reminder_animation_;
270 280
281 // We have already shown and dismissed the upgrade reminder animation.
282 bool upgrade_reminder_canceled_;
283
271 // When collapsed, the toolbar is just a tiny strip, no controls are visible. 284 // When collapsed, the toolbar is just a tiny strip, no controls are visible.
272 bool collapsed_; 285 bool collapsed_;
273 286
274 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk); 287 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk);
275 }; 288 };
276 289
277 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ 290 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/browser_toolbar_gtk.cc » ('j') | chrome/browser/gtk/browser_window_gtk.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698