summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 21:15:44 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 21:15:44 +0000
commit976c0994ebdf37d650fb1c9788d24ef07470937a (patch)
tree0a9080b504f42cdc194c42aa741057257b5302fd /chrome
parent6719905012bf5bd3cbac84f4b833a2a301250cb0 (diff)
downloadchromium_src-976c0994ebdf37d650fb1c9788d24ef07470937a.zip
chromium_src-976c0994ebdf37d650fb1c9788d24ef07470937a.tar.gz
chromium_src-976c0994ebdf37d650fb1c9788d24ef07470937a.tar.bz2
Fix themed toolbar drawing following tabstrip changes.
The code should also be more robust to future changes. BUG=none TEST=active tab blends into toolbar Review URL: http://codereview.chromium.org/126013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc9
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.h5
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc16
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.h4
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc5
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.cc15
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.h5
7 files changed, 46 insertions, 13 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index e5c3043..0e03a9c 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -16,10 +16,12 @@
#include "chrome/browser/gtk/bookmark_menu_controller_gtk.h"
#include "chrome/browser/gtk/bookmark_tree_model.h"
#include "chrome/browser/gtk/bookmark_utils_gtk.h"
+#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/custom_button.h"
#include "chrome/browser/gtk/dnd_registry.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/nine_box.h"
+#include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
#include "chrome/common/gtk_util.h"
@@ -86,10 +88,12 @@ void SetButtonTextColors(GtkWidget* button) {
} // namespace
-BookmarkBarGtk::BookmarkBarGtk(Profile* profile, Browser* browser)
+BookmarkBarGtk::BookmarkBarGtk(Profile* profile, Browser* browser,
+ BrowserWindowGtk* window)
: profile_(NULL),
page_navigator_(NULL),
browser_(browser),
+ window_(window),
model_(NULL),
instructions_(NULL),
dragged_node_(NULL),
@@ -795,8 +799,9 @@ gboolean BookmarkBarGtk::OnHBoxExpose(GtkWidget* widget,
event->area.width, event->area.height);
cairo_clip(cr);
bar->InitBackground();
+ int y = bar->window_->tabstrip()->GetTabStripOriginForWidget(widget).y();
bar->background_ninebox_->RenderTopCenterStrip(cr, event->area.x,
- 0, event->area.width);
+ y, event->area.width);
cairo_destroy(cr);
return FALSE; // Propagate expose to children.
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.h b/chrome/browser/gtk/bookmark_bar_gtk.h
index 66bf3e0..f0b2d06 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.h
+++ b/chrome/browser/gtk/bookmark_bar_gtk.h
@@ -17,6 +17,7 @@
class BookmarkContextMenu;
class BookmarkMenuController;
class Browser;
+class BrowserWindowGtk;
class CustomContainerButton;
class NineBox;
class PageNavigator;
@@ -25,7 +26,8 @@ class Profile;
class BookmarkBarGtk : public AnimationDelegate,
public BookmarkModelObserver {
public:
- explicit BookmarkBarGtk(Profile* profile, Browser* browser);
+ explicit BookmarkBarGtk(Profile* profile, Browser* browser,
+ BrowserWindowGtk* window);
virtual ~BookmarkBarGtk();
// Resets the profile. This removes any buttons for the current profile and
@@ -195,6 +197,7 @@ class BookmarkBarGtk : public AnimationDelegate,
PageNavigator* page_navigator_;
Browser* browser_;
+ BrowserWindowGtk* window_;
// Model providing details as to the starred entries/groups that should be
// shown. This is owned by the Profile.
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index ef34459..caaa8f2 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -15,12 +15,14 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/gtk/back_forward_button_gtk.h"
+#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/custom_button.h"
#include "chrome/browser/gtk/go_button_gtk.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/location_bar_view_gtk.h"
#include "chrome/browser/gtk/nine_box.h"
#include "chrome/browser/gtk/standard_menus.h"
+#include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
#include "chrome/browser/gtk/toolbar_star_toggle_gtk.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profile.h"
@@ -53,13 +55,14 @@ const int kPopupLeftRightMargin = 1;
// BrowserToolbarGtk, public ---------------------------------------------------
-BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser)
+BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window)
: toolbar_(NULL),
location_bar_(new LocationBarViewGtk(browser->command_updater(),
browser->toolbar_model(),
this)),
model_(browser->toolbar_model()),
browser_(browser),
+ window_(window),
profile_(NULL) {
browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
@@ -349,13 +352,12 @@ gboolean BrowserToolbarGtk::OnToolbarExpose(GtkWidget* widget,
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);
- // It would be more intuitive to pass |e->area.y| rather than 0, but the
- // toolbar is supposed to blend in with the active tab, so we have to pass
+ // 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. Since the toolbar's GdkWindow has the same origin as the tab
- // strip's GdkWindow, we can just pass 0.
- toolbar->background_ninebox_->RenderTopCenterStrip(cr,
- e->area.x, 0, e->area.width);
+ // tab strip.
+ int y = toolbar->window_->tabstrip()->GetTabStripOriginForWidget(widget).y();
+ toolbar->background_ninebox_->RenderTopCenterStrip(cr, e->area.x,
+ y, e->area.width);
cairo_destroy(cr);
return FALSE; // Allow subwidgets to paint.
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.h b/chrome/browser/gtk/browser_toolbar_gtk.h
index 2afb4ab..cbe288c 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.h
+++ b/chrome/browser/gtk/browser_toolbar_gtk.h
@@ -16,6 +16,7 @@
class BackForwardButtonGtk;
class Browser;
+class BrowserWindowGtk;
class CustomDrawButton;
class GoButtonGtk;
class LocationBar;
@@ -33,7 +34,7 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
public NotificationObserver,
public AutocompletePopupPositioner {
public:
- explicit BrowserToolbarGtk(Browser* browser);
+ explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window);
virtual ~BrowserToolbarGtk();
// Create the contents of the toolbar. |top_level_window| is the GtkWindow
@@ -144,6 +145,7 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
scoped_ptr<MenuGtk> app_menu_;
Browser* browser_;
+ BrowserWindowGtk* window_;
Profile* profile_;
// Controls whether or not a home button should be shown on the toolbar.
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 91eaf3e..e43327f 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -353,11 +353,12 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser)
G_CALLBACK(&OnContentAreaExpose), this);
gtk_widget_show(content_vbox_);
- toolbar_.reset(new BrowserToolbarGtk(browser_.get()));
+ toolbar_.reset(new BrowserToolbarGtk(browser_.get(), this));
toolbar_->Init(browser_->profile(), window_);
toolbar_->AddToolbarToBox(content_vbox_);
- bookmark_bar_.reset(new BookmarkBarGtk(browser_->profile(), browser_.get()));
+ bookmark_bar_.reset(new BookmarkBarGtk(browser_->profile(), browser_.get(),
+ this));
bookmark_bar_->AddBookmarkbarToBox(content_vbox_);
// This vbox surrounds the render area: find bar, info bars and render view.
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index 18139fe..d460c59 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -613,6 +613,21 @@ gfx::Rect TabStripGtk::GetIdealBounds(int index) {
return tab_data_.at(index).ideal_bounds;
}
+gfx::Point TabStripGtk::GetTabStripOriginForWidget(GtkWidget* target) {
+ int x, y;
+ if (!gtk_widget_translate_coordinates(widget(), target, 0, 0, &x, &y)) {
+ // If the tab strip isn't showing, give the coordinates relative to the
+ // toplevel instead.
+ gtk_widget_translate_coordinates(
+ gtk_widget_get_toplevel(widget()), target, 0, 0, &x, &y);
+ }
+ if (GTK_WIDGET_NO_WINDOW(target)) {
+ x += target->allocation.x;
+ y += target->allocation.y;
+ }
+ return gfx::Point(x, y);
+}
+
////////////////////////////////////////////////////////////////////////////////
// TabStripGtk, TabStripModelObserver implementation:
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h
index cc05ea2..93b953f 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h
@@ -78,6 +78,11 @@ class TabStripGtk : public TabStripModelObserver,
// Retrieve the ideal bounds for the Tab at the specified index.
gfx::Rect GetIdealBounds(int index);
+ // Return the origin of the tab strip in coordinates relative to the GdkWindow
+ // of |widget|. Used to help other widgets draw their background relative to
+ // the tabstrip.
+ gfx::Point GetTabStripOriginForWidget(GtkWidget* widget);
+
protected:
// TabStripModelObserver implementation:
virtual void TabInsertedAt(TabContents* contents,