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

Side by Side Diff: chrome/browser/ui/gtk/browser_window_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: Fix per feedback 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_GTK_BROWSER_WINDOW_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/timer.h" 16 #include "base/timer.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/infobars/infobar_container.h" 18 #include "chrome/browser/infobars/infobar_container.h"
19 #include "chrome/browser/prefs/pref_member.h" 19 #include "chrome/browser/prefs/pref_member.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
22 #include "ui/base/gtk/gtk_signal.h" 22 #include "ui/base/gtk/gtk_signal.h"
23 #include "ui/base/ui_base_types.h" 23 #include "ui/base/ui_base_types.h"
24 #include "ui/base/x/active_window_watcher_x_observer.h" 24 #include "ui/base/x/active_window_watcher_x_observer.h"
25 #include "ui/base/x/x11_util.h" 25 #include "ui/base/x/x11_util.h"
26 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
27 27
28 class BookmarkBarGtk; 28 class BookmarkBarGtk;
29 class Browser; 29 class Browser;
30 class BrowserTitlebar; 30 class BrowserTitlebarBase;
31 class BrowserToolbarGtk; 31 class BrowserToolbarGtk;
32 class DownloadShelfGtk; 32 class DownloadShelfGtk;
33 class ExtensionKeybindingRegistryGtk; 33 class ExtensionKeybindingRegistryGtk;
34 class FindBarGtk; 34 class FindBarGtk;
35 class FullscreenExitBubbleGtk; 35 class FullscreenExitBubbleGtk;
36 class GlobalMenuBar; 36 class GlobalMenuBar;
37 class InfoBarContainerGtk; 37 class InfoBarContainerGtk;
38 class LocationBar; 38 class LocationBar;
39 class StatusBubbleGtk; 39 class StatusBubbleGtk;
40 class TabContentsContainerGtk; 40 class TabContentsContainerGtk;
(...skipping 13 matching lines...) Expand all
54 public ui::ActiveWindowWatcherXObserver, 54 public ui::ActiveWindowWatcherXObserver,
55 public InfoBarContainer::Delegate { 55 public InfoBarContainer::Delegate {
56 public: 56 public:
57 explicit BrowserWindowGtk(Browser* browser); 57 explicit BrowserWindowGtk(Browser* browser);
58 virtual ~BrowserWindowGtk(); 58 virtual ~BrowserWindowGtk();
59 59
60 // Separating initialization from constructor allows invocation of virtual 60 // Separating initialization from constructor allows invocation of virtual
61 // functions during initialization. 61 // functions during initialization.
62 virtual void Init(); 62 virtual void Init();
63 63
64 // Returns whether to draw the content drop shadow on the sides and bottom
65 // of the browser window. When false, we still draw a shadow on the top of
66 // the toolbar (under the tab strip), but do not round the top corners.
67 virtual bool ShouldDrawContentDropShadow() const;
68
69 // Overridden from BrowserWindow: 64 // Overridden from BrowserWindow:
70 virtual void Show() OVERRIDE; 65 virtual void Show() OVERRIDE;
71 virtual void ShowInactive() OVERRIDE; 66 virtual void ShowInactive() OVERRIDE;
72 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 67 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
73 virtual void Close() OVERRIDE; 68 virtual void Close() OVERRIDE;
74 virtual void Activate() OVERRIDE; 69 virtual void Activate() OVERRIDE;
75 virtual void Deactivate() OVERRIDE; 70 virtual void Deactivate() OVERRIDE;
76 virtual bool IsActive() const OVERRIDE; 71 virtual bool IsActive() const OVERRIDE;
77 virtual void FlashFrame(bool flash) OVERRIDE; 72 virtual void FlashFrame(bool flash) OVERRIDE;
78 virtual bool IsAlwaysOnTop() const OVERRIDE; 73 virtual bool IsAlwaysOnTop() const OVERRIDE;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 void OnDebouncedBoundsChanged(); 205 void OnDebouncedBoundsChanged();
211 206
212 // Request the underlying window to unmaximize. Also tries to work around 207 // Request the underlying window to unmaximize. Also tries to work around
213 // a window manager "feature" that can prevent this in some edge cases. 208 // a window manager "feature" that can prevent this in some edge cases.
214 void UnMaximize(); 209 void UnMaximize();
215 210
216 // Returns false if we're not ready to close yet. E.g., a tab may have an 211 // Returns false if we're not ready to close yet. E.g., a tab may have an
217 // onbeforeunload handler that prevents us from closing. 212 // onbeforeunload handler that prevents us from closing.
218 bool CanClose() const; 213 bool CanClose() const;
219 214
215 // Returns whether to draw the content drop shadow on the sides and bottom
216 // of the browser window. When false, we still draw a shadow on the top of
217 // the toolbar (under the tab strip), but do not round the top corners.
218 bool ShouldDrawContentDropShadow() const;
219
220 bool ShouldShowWindowIcon() const; 220 bool ShouldShowWindowIcon() const;
221 221
222 // Add the find bar widget to the window hierarchy. 222 // Add the find bar widget to the window hierarchy.
223 void AddFindBar(FindBarGtk* findbar); 223 void AddFindBar(FindBarGtk* findbar);
224 224
225 // Reset the mouse cursor to the default cursor if it was set to something 225 // Reset the mouse cursor to the default cursor if it was set to something
226 // else for the custom frame. 226 // else for the custom frame.
227 void ResetCustomFrameCursor(); 227 void ResetCustomFrameCursor();
228 228
229 // Returns the BrowserWindowGtk registered with |window|. 229 // Returns the BrowserWindowGtk registered with |window|.
230 static BrowserWindowGtk* GetBrowserWindowForNativeWindow( 230 static BrowserWindowGtk* GetBrowserWindowForNativeWindow(
231 gfx::NativeWindow window); 231 gfx::NativeWindow window);
232 232
233 // Retrieves the GtkWindow associated with |xid|, which is the X Window 233 // Retrieves the GtkWindow associated with |xid|, which is the X Window
234 // ID of the top-level X window of this object. 234 // ID of the top-level X window of this object.
235 static GtkWindow* GetBrowserWindowForXID(XID xid); 235 static GtkWindow* GetBrowserWindowForXID(XID xid);
236 236
237 Browser* browser() const { return browser_.get(); } 237 Browser* browser() const { return browser_.get(); }
238 238
239 GtkWindow* window() const { return window_; } 239 GtkWindow* window() const { return window_; }
240 240
241 BrowserTitlebar* titlebar() const { return titlebar_.get(); } 241 BrowserTitlebarBase* titlebar() const { return titlebar_.get(); }
242 242
243 GtkWidget* titlebar_widget() const; 243 GtkWidget* titlebar_widget() const;
244 244
245 BrowserToolbarGtk* GetToolbar() { return toolbar_.get(); } 245 BrowserToolbarGtk* GetToolbar() { return toolbar_.get(); }
246 246
247 gfx::Rect bounds() const { return bounds_; } 247 gfx::Rect bounds() const { return bounds_; }
248 248
249 // Returns the tab we're currently displaying in the tab contents container. 249 // Returns the tab we're currently displaying in the tab contents container.
250 TabContentsWrapper* GetDisplayedTab(); 250 TabContentsWrapper* GetDisplayedTab();
251 251
252 static void RegisterUserPrefs(PrefService* prefs); 252 static void RegisterUserPrefs(PrefService* prefs);
253 253
254 // Tells GTK that the toolbar area is invalidated and needs redrawing. We 254 // Tells GTK that the toolbar area is invalidated and needs redrawing. We
255 // have this method as a hack because GTK doesn't queue the toolbar area for 255 // have this method as a hack because GTK doesn't queue the toolbar area for
256 // redraw when it should. 256 // redraw when it should.
257 void QueueToolbarRedraw(); 257 void QueueToolbarRedraw();
258 258
259 // Get the position where the infobar arrow should be anchored in 259 // Get the position where the infobar arrow should be anchored in
260 // |relative_to| coordinates. This is the middle of the omnibox location icon. 260 // |relative_to| coordinates. This is the middle of the omnibox location icon.
261 int GetXPositionOfLocationIcon(GtkWidget* relative_to); 261 int GetXPositionOfLocationIcon(GtkWidget* relative_to);
262 262
263 protected: 263 protected:
264 virtual void DestroyBrowser() OVERRIDE; 264 virtual void DestroyBrowser() OVERRIDE;
265 265
266 // Returns an instance of |BrowserTitlebar| to be used for this window. 266 // Returns an instance of |BrowserTitlebarBase| to be used for this window.
267 virtual BrowserTitlebar* CreateBrowserTitlebar(); 267 virtual BrowserTitlebarBase* CreateBrowserTitlebar();
268 268
269 // Checks to see if the mouse pointer at |x|, |y| is over the border of the 269 // Checks to see if the mouse pointer at |x|, |y| is over the border of the
270 // custom frame (a spot that should trigger a window resize). Returns true if 270 // custom frame (a spot that should trigger a window resize). Returns true if
271 // it should and sets |edge|. 271 // it should and sets |edge|.
272 virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge); 272 virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge);
273 273
274 // Returns the window shape for the window with |width| and |height|. 274 // Returns the window shape for the window with |width| and |height|.
275 // The caller is responsible for destroying the region if non-null region is 275 // The caller is responsible for destroying the region if non-null region is
276 // returned. 276 // returned.
277 virtual GdkRegion* GetWindowShape(int width, int height) const; 277 virtual GdkRegion* GetWindowShape(int width, int height) const;
278 278
279 // Draws the border, including resizable corners, for the custom frame. 279 // Draws the frame, including background, border and drop shadow.
280 virtual void DrawCustomFrameBorder(GtkWidget* widget); 280 virtual void DrawFrame(GtkWidget* widget, GdkEventExpose* event);
281 281
282 virtual bool HandleTitleBarLeftMousePress(GdkEventButton* event, 282 virtual bool HandleTitleBarLeftMousePress(GdkEventButton* event,
283 guint32 last_click_time, 283 guint32 last_click_time,
284 gfx::Point last_click_position); 284 gfx::Point last_click_position);
285 285
286 // Returns true if handled. 286 // Returns true if handled.
287 virtual bool HandleWindowEdgeLeftMousePress(GtkWindow* window, 287 virtual bool HandleWindowEdgeLeftMousePress(GtkWindow* window,
288 GdkWindowEdge edge, 288 GdkWindowEdge edge,
289 GdkEventButton* event); 289 GdkEventButton* event);
290 290
291 // Save the window position in the prefs. 291 // Save the window position in the prefs.
292 virtual void SaveWindowPosition(); 292 virtual void SaveWindowPosition();
293 293
294 // Sets the default size for the window and the way the user is allowed to 294 // Sets the default size for the window and the way the user is allowed to
295 // resize it. 295 // resize it.
296 virtual void SetGeometryHints(); 296 virtual void SetGeometryHints();
297 297
298 // Returns |true| if we should use the custom frame. 298 // Returns |true| if we should use the custom frame.
299 virtual bool UseCustomFrame() const; 299 virtual bool UseCustomFrame() const;
300 300
301 // Whether we should draw the tab background instead of the theme_frame
302 // background because this window is a popup.
303 virtual bool UsingCustomPopupFrame() const;
304
305 // Called when the window size changed. 301 // Called when the window size changed.
306 virtual void OnSizeChanged(int width, int height); 302 virtual void OnSizeChanged(int width, int height);
307 303
308 // Draws the normal custom frame using theme_frame.
309 virtual void DrawCustomFrame(cairo_t* cr, GtkWidget* widget,
310 GdkEventExpose* event);
311
312 // Draws the tab image as the frame so we can write legible text.
313 virtual void DrawPopupFrame(cairo_t* cr, GtkWidget* widget,
314 GdkEventExpose* event);
315
316 // 'focus-in-event' handler. 304 // 'focus-in-event' handler.
317 virtual void HandleFocusIn(GtkWidget* widget, GdkEventFocus* event); 305 virtual void HandleFocusIn(GtkWidget* widget, GdkEventFocus* event);
318 306
319 // Returns the size of the window frame around the client content area. 307 // Returns the size of the window frame around the client content area.
320 gfx::Size GetNonClientFrameSize() const; 308 gfx::Size GetNonClientFrameSize() const;
321 309
322 // Invalidate window to force repaint. 310 // Invalidate window to force repaint.
323 void InvalidateWindow(); 311 void InvalidateWindow();
324 312
325 // Top level window. 313 // Top level window.
(...skipping 29 matching lines...) Expand all
355 // not). 343 // not).
356 void SetBackgroundColor(); 344 void SetBackgroundColor();
357 345
358 // Applies the window shape to if we're in custom drawing mode. 346 // Applies the window shape to if we're in custom drawing mode.
359 void UpdateWindowShape(int width, int height); 347 void UpdateWindowShape(int width, int height);
360 348
361 // Connect accelerators that aren't connected to menu items (like ctrl-o, 349 // Connect accelerators that aren't connected to menu items (like ctrl-o,
362 // ctrl-l, etc.). 350 // ctrl-l, etc.).
363 void ConnectAccelerators(); 351 void ConnectAccelerators();
364 352
353 // Whether we should draw the tab background instead of the theme_frame
354 // background because this window is a popup.
355 bool UsingCustomPopupFrame() const;
356
357 // Draws the normal custom frame using theme_frame.
358 void DrawCustomFrame(cairo_t* cr, GtkWidget* widget, GdkEventExpose* event);
359
360 // Draws the tab image as the frame so we can write legible text.
361 void DrawPopupFrame(cairo_t* cr, GtkWidget* widget, GdkEventExpose* event);
362
363 // Draws the border, including resizable corners, for the custom frame.
364 void DrawCustomFrameBorder(GtkWidget* widget);
365
365 // Change whether we're showing the custom blue frame. 366 // Change whether we're showing the custom blue frame.
366 // Must be called once at startup. 367 // Must be called once at startup.
367 // Triggers relayout of the content. 368 // Triggers relayout of the content.
368 void UpdateCustomFrame(); 369 void UpdateCustomFrame();
369 370
370 // Set the bounds of the current window. If |exterior| is true, set the size 371 // Set the bounds of the current window. If |exterior| is true, set the size
371 // of the window itself, otherwise set the bounds of the web contents. 372 // of the window itself, otherwise set the bounds of the web contents.
372 // If |move| is true, set the position of the window, otherwise leave the 373 // If |move| is true, set the position of the window, otherwise leave the
373 // position to the WM. 374 // position to the WM.
374 void SetBoundsImpl(const gfx::Rect& bounds, bool exterior, bool move); 375 void SetBoundsImpl(const gfx::Rect& bounds, bool exterior, bool move);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // The position and size of the non-maximized, non-fullscreen window. 482 // The position and size of the non-maximized, non-fullscreen window.
482 gfx::Rect restored_bounds_; 483 gfx::Rect restored_bounds_;
483 484
484 GdkWindowState state_; 485 GdkWindowState state_;
485 486
486 // Controls a hidden GtkMenuBar that we keep updated so GNOME can take a look 487 // Controls a hidden GtkMenuBar that we keep updated so GNOME can take a look
487 // inside "our menu bar" and present it in the top panel, akin to Mac OS. 488 // inside "our menu bar" and present it in the top panel, akin to Mac OS.
488 scoped_ptr<GlobalMenuBar> global_menu_bar_; 489 scoped_ptr<GlobalMenuBar> global_menu_bar_;
489 490
490 // The container for the titlebar + tab strip. 491 // The container for the titlebar + tab strip.
491 scoped_ptr<BrowserTitlebar> titlebar_; 492 scoped_ptr<BrowserTitlebarBase> titlebar_;
492 493
493 // The object that manages all of the widgets in the toolbar. 494 // The object that manages all of the widgets in the toolbar.
494 scoped_ptr<BrowserToolbarGtk> toolbar_; 495 scoped_ptr<BrowserToolbarGtk> toolbar_;
495 496
496 // The object that manages the bookmark bar. This will be NULL if the 497 // The object that manages the bookmark bar. This will be NULL if the
497 // bookmark bar is not supported. 498 // bookmark bar is not supported.
498 scoped_ptr<BookmarkBarGtk> bookmark_bar_; 499 scoped_ptr<BookmarkBarGtk> bookmark_bar_;
499 500
500 // The download shelf view (view at the bottom of the page). 501 // The download shelf view (view at the bottom of the page).
501 scoped_ptr<DownloadShelfGtk> download_shelf_; 502 scoped_ptr<DownloadShelfGtk> download_shelf_;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 scoped_ptr<FullscreenExitBubbleGtk> fullscreen_exit_bubble_; 572 scoped_ptr<FullscreenExitBubbleGtk> fullscreen_exit_bubble_;
572 573
573 FullscreenExitBubbleType fullscreen_exit_bubble_type_; 574 FullscreenExitBubbleType fullscreen_exit_bubble_type_;
574 575
575 content::NotificationRegistrar registrar_; 576 content::NotificationRegistrar registrar_;
576 577
577 DISALLOW_COPY_AND_ASSIGN(BrowserWindowGtk); 578 DISALLOW_COPY_AND_ASSIGN(BrowserWindowGtk);
578 }; 579 };
579 580
580 #endif // CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ 581 #endif // CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_titlebar_base.h ('k') | chrome/browser/ui/gtk/browser_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698