diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 16:47:08 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 16:47:08 +0000 |
commit | 12f9faa592c28028cb833347a641ab0b9bab4b40 (patch) | |
tree | d96db1e66eef1b1577e3426a15f5ad9cf38f2525 /chrome/browser/gtk | |
parent | 82e2f2bab320ec135fc00417984a4fa6a93014a1 (diff) | |
download | chromium_src-12f9faa592c28028cb833347a641ab0b9bab4b40.zip chromium_src-12f9faa592c28028cb833347a641ab0b9bab4b40.tar.gz chromium_src-12f9faa592c28028cb833347a641ab0b9bab4b40.tar.bz2 |
Some enhancements as requested to the compact nav bar. The search box looks
larger, back and foward moved to the right, there is a border below the tab
strip.
Importantly, the compact nav bar can be switched on and off at runtime via the
app menu (which creates a new window with it) rather than using the command
line flag.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/171112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 60 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 13 |
2 files changed, 66 insertions, 7 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index e2fce5d..d94da08 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -82,10 +82,6 @@ #include "views/controls/button/image_button.h" #include "views/widget/widget_gtk.h" -// This command-line switch enables the compact navigation bar instead of the -// regular toolbar. -static const wchar_t kUseCompactNavBar[] = L"compact-nav"; - // This command-line switch enables the main menu button in the upper left // corner. By default it isn't shown. static const wchar_t kShowMainMenuButton[] = L"main-menu-button"; @@ -325,6 +321,40 @@ class MenuPopupCloser : public views::ButtonListener { DISALLOW_COPY_AND_ASSIGN(MenuPopupCloser); }; +// This draws the spacer below the tab strip when we're using the compact +// location bar (i.e. no location bar). This basically duplicates the painting +// that the tab strip would have done for this region so that it blends +// nicely in with the bottom of the tabs. +gboolean OnCompactNavSpacerExpose(GtkWidget* widget, + GdkEventExpose* e, + BrowserWindowGtk* window) { + cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); + cairo_rectangle(cr, e->area.x, e->area.y, e->area.width, e->area.height); + cairo_clip(cr); + // The toolbar is supposed to blend in with the active tab, so we have to pass + // coordinates for the IDR_THEME_TOOLBAR bitmap relative to the top of the + // tab strip. + gfx::Point tabstrip_origin = + window->tabstrip()->GetTabStripOriginForWidget(widget); + ThemeProvider* theme_provider = + window->browser()->profile()->GetThemeProvider(); + GdkPixbuf* toolbar_background = theme_provider->GetPixbufNamed( + IDR_THEME_TOOLBAR); + gdk_cairo_set_source_pixbuf(cr, toolbar_background, tabstrip_origin.x(), + tabstrip_origin.y()); + // We tile the toolbar background in both directions. + cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); + cairo_rectangle(cr, + tabstrip_origin.x(), + tabstrip_origin.y(), + e->area.x + e->area.width - tabstrip_origin.x(), + e->area.y + e->area.height - tabstrip_origin.y()); + cairo_fill(cr); + cairo_destroy(cr); + + return FALSE; +} + } // namespace // Callback from GTK when the user clicks the main menu button. @@ -344,7 +374,8 @@ static void OnMainMenuButtonClicked(GtkWidget* widget, menu_popup->SetContentsView(button); menu_popup->Show(); } -#endif + +#endif // OS_CHROMEOS int GetCommandId(guint accel_key, GdkModifierType modifier) { // Bug 9806: If capslock is on, we will get a capital letter as accel_key. @@ -487,6 +518,11 @@ GdkColor SkColorToGdkColor(const SkColor& color) { std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; +#if defined(OS_CHROMEOS) +// Default to using the regular window style. +bool BrowserWindowGtk::next_window_should_use_compact_nav_ = false; +#endif + BrowserWindowGtk::BrowserWindowGtk(Browser* browser) : browser_(browser), #if defined(OS_CHROMEOS) @@ -1466,8 +1502,7 @@ void BrowserWindowGtk::InitWidgets() { GtkWidget* titlebar_hbox = NULL; GtkWidget* navbar_hbox = NULL; GtkWidget* status_hbox = NULL; - bool has_compact_nav_bar = - CommandLine::ForCurrentProcess()->HasSwitch(kUseCompactNavBar); + bool has_compact_nav_bar = next_window_should_use_compact_nav_; if (browser_->type() == Browser::TYPE_NORMAL) { bool show_main_menu_button = CommandLine::ForCurrentProcess()->HasSwitch(kShowMainMenuButton); @@ -1480,6 +1515,10 @@ void BrowserWindowGtk::InitWidgets() { navbar_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(navbar_hbox); gtk_box_pack_start(GTK_BOX(titlebar_hbox), navbar_hbox, FALSE, FALSE, 0); + + // Reset the compact nav bit now that we're creating the next toplevel + // window. Code below will use our local has_compact_nav_bar variable. + next_window_should_use_compact_nav_ = false; } else if (show_main_menu_button) { CustomDrawButton* main_menu_button = new CustomDrawButton(IDR_MAIN_MENU_BUTTON, IDR_MAIN_MENU_BUTTON, @@ -1517,6 +1556,13 @@ void BrowserWindowGtk::InitWidgets() { #if defined(OS_CHROMEOS) if (browser_->type() == Browser::TYPE_NORMAL && has_compact_nav_bar) { gtk_widget_hide(toolbar_->widget()); + + GtkWidget* spacer = gtk_vbox_new(FALSE, 0); + gtk_widget_set_size_request(spacer, -1, 3); + gtk_widget_show(spacer); + gtk_box_pack_start(GTK_BOX(content_vbox_), spacer, FALSE, FALSE, 0); + g_signal_connect(spacer, "expose-event", + G_CALLBACK(&OnCompactNavSpacerExpose), this); } #endif diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index c97c2f6..c4426a71 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -154,6 +154,17 @@ class BrowserWindowGtk : public BrowserWindow, // Sets whether a drag is active. If a drag is active the window will not // close. void set_drag_active(bool drag_active) { drag_active_ = drag_active; } + + // Sets the flag that the next toplevel browser window being created will + // use the compact nav bar. This is used to implement the "new compact nav + // window" menu option. This flag will be cleared after the next window is + // opened, which will revert to the old behavior. + // + // TODO(brettw) remove this when we figure out how this is actually going + // to work long-term. This is a hack so the feature can be tested. + static void set_next_window_should_use_compact_nav() { + next_window_should_use_compact_nav_ = true; + } #endif // Reset the mouse cursor to the default cursor if it was set to something @@ -360,6 +371,8 @@ class BrowserWindowGtk : public BrowserWindow, CompactNavigationBar* compact_navigation_bar_; StatusAreaView* status_area_; + + static bool next_window_should_use_compact_nav_; #endif // A map which translates an X Window ID into its respective GtkWindow. |