summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc37
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.h7
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc16
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h5
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h3
5 files changed, 38 insertions, 30 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index 5e2c736..d9467d5 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -24,7 +24,6 @@
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/gtk_dnd_util.h"
#include "chrome/browser/gtk/gtk_theme_provider.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"
@@ -133,6 +132,9 @@ void BookmarkBarGtk::SetPageNavigator(PageNavigator* navigator) {
void BookmarkBarGtk::Init(Profile* profile) {
event_box_.Own(gtk_event_box_new());
+ // Make the event box transparent so themes can use transparent backgrounds.
+ if (!theme_provider_->UseGtkTheme())
+ gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
bookmark_hbox_ = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(event_box_.get()), bookmark_hbox_);
@@ -399,6 +401,12 @@ void BookmarkBarGtk::Observe(NotificationType type,
DLOG(ERROR) << "Received a theme change notification while we "
<< "don't have a BookmarkModel. Taking no action.";
}
+
+ // When using the GTK+ theme, we need to have the event box be visible so
+ // buttons don't get a halo color from the background. When using Chromium
+ // themes, we want to let the background show through the toolbar.
+ gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()),
+ theme_provider_->UseGtkTheme());
}
}
@@ -494,15 +502,6 @@ const BookmarkNode* BookmarkBarGtk::GetNodeForToolButton(GtkWidget* widget) {
return NULL;
}
-void BookmarkBarGtk::InitBackground() {
- if (background_ninebox_.get())
- return;
-
- background_ninebox_.reset(new NineBox(
- browser_->profile()->GetThemeProvider(),
- 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0));
-}
-
void BookmarkBarGtk::PopupMenuForNode(GtkWidget* sender,
const BookmarkNode* node,
GdkEventButton* event) {
@@ -815,12 +814,22 @@ gboolean BookmarkBarGtk::OnHBoxExpose(GtkWidget* widget,
cairo_rectangle(cr, event->area.x, event->area.y,
event->area.width, event->area.height);
cairo_clip(cr);
- bar->InitBackground();
gfx::Point tabstrip_origin =
bar->window_->tabstrip()->GetTabStripOriginForWidget(widget);
- bar->background_ninebox_->RenderTopCenterStrip(
- cr, tabstrip_origin.x(), tabstrip_origin.y(),
- event->area.x + event->area.width - tabstrip_origin.x());
+
+ GtkThemeProvider* theme_provider = bar->theme_provider_;
+ 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(),
+ event->area.x + event->area.width - tabstrip_origin.x(),
+ event->area.y + event->area.height - tabstrip_origin.y());
+ cairo_fill(cr);
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 5220b95..6600046 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.h
+++ b/chrome/browser/gtk/bookmark_bar_gtk.h
@@ -21,7 +21,6 @@ class BookmarkMenuController;
class Browser;
class BrowserWindowGtk;
class CustomContainerButton;
-class NineBox;
class PageNavigator;
class Profile;
struct GtkThemeProvider;
@@ -135,9 +134,6 @@ class BookmarkBarGtk : public AnimationDelegate,
// Finds the BookmarkNode from the model associated with |button|.
const BookmarkNode* GetNodeForToolButton(GtkWidget* button);
- // Loads the background image into memory, or does nothing if already loaded.
- void InitBackground();
-
// Creates and displays a popup menu for BookmarkNode |node|.
void PopupMenuForNode(GtkWidget* sender, const BookmarkNode* node,
GdkEventButton* event);
@@ -245,9 +241,6 @@ class BookmarkBarGtk : public AnimationDelegate,
// displayed yet.
scoped_ptr<BookmarkMenuController> current_menu_;
- // Paints the background for our bookmark bar.
- scoped_ptr<NineBox> background_ninebox_;
-
scoped_ptr<SlideAnimation> slide_animation_;
NotificationRegistrar registrar_;
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index 9980cf4..d9e96a5 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -28,6 +28,7 @@ const int kLeftPadding = 16;
const int kTopPadding = 6;
const int kRightPadding = 15;
const int kBottomPadding = 5;
+const int kDropShadowHeight = 2;
const int kFavIconTitleSpacing = 4;
const int kTitleCloseButtonSpacing = 5;
const int kStandardTitleWidth = 175;
@@ -596,6 +597,10 @@ void TabRendererGtk::PaintTab(GdkEventExpose* event) {
// coordinate event->area. Translate by these offsets so we can render at
// (0,0) to match Windows' rendering metrics.
canvas.TranslateInt(event->area.x, event->area.y);
+
+ // Save the original x offset so we can position background images properly.
+ background_offset_x_ = event->area.x;
+
Paint(&canvas);
}
@@ -680,7 +685,7 @@ void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
// The tab image needs to be lined up with the background image
// so that it feels partially transparent.
- int offset = 1;
+ int offset = background_offset_x_;
int tab_id = is_otr ?
IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND;
@@ -723,7 +728,7 @@ void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
}
void TabRendererGtk::PaintActiveTabBackground(gfx::Canvas* canvas) {
- int offset = 1;
+ int offset = background_offset_x_;
SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(IDR_THEME_TOOLBAR);
@@ -745,9 +750,10 @@ void TabRendererGtk::PaintActiveTabBackground(gfx::Canvas* canvas) {
// Draw center.
canvas->TileImageInt(*tab_bg,
- offset + tab_active_.l_width, 2,
- tab_active_.l_width, 2,
- width() - tab_active_.l_width - tab_active_.r_width, height() - 2);
+ offset + tab_active_.l_width, kDropShadowHeight,
+ tab_active_.l_width, kDropShadowHeight,
+ width() - tab_active_.l_width - tab_active_.r_width,
+ height() - kDropShadowHeight);
canvas->DrawBitmapInt(*tab_active_.image_l, 0, 0);
canvas->TileImageInt(*tab_active_.image_c, tab_active_.l_width, 0,
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index edda57a..ba141f1 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -339,8 +339,9 @@ class TabRendererGtk : public AnimationDelegate {
// Contains the loading animation state.
LoadingAnimation loading_animation_;
- // TODO(jhawkins): If the theme is changed after the tab is created, we'll
- // still render the old theme for this tab.
+ // The offset used to paint the tab theme images.
+ int background_offset_x_;
+
ThemeProvider* theme_provider_;
// The close button.
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index d157ceb..8b2cbb8 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -62,7 +62,7 @@ class TabRenderer : public views::View,
// Set the background offset used to match the image in the inactive tab
// to the frame image.
- void SetBackgroundOffset(gfx::Point offset) {
+ void SetBackgroundOffset(const gfx::Point& offset) {
background_offset_ = offset;
}
@@ -171,7 +171,6 @@ class TabRenderer : public views::View,
bool crashed;
bool off_the_record;
bool show_icon;
- int background_vertical_offset;
};
TabData data_;