summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 01:58:01 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 01:58:01 +0000
commitb846afe7b1e97e4d245f7df153813c55ae46f74b (patch)
tree7e6ae6dda666d01ad1898a7d593bf9c0e606f5ca /chrome/browser/gtk
parentd2192e3d5b90b631abf219079d93c3453f852865 (diff)
downloadchromium_src-b846afe7b1e97e4d245f7df153813c55ae46f74b.zip
chromium_src-b846afe7b1e97e4d245f7df153813c55ae46f74b.tar.gz
chromium_src-b846afe7b1e97e4d245f7df153813c55ae46f74b.tar.bz2
GTK: Draw bottom-aligned ntp themes on floating bookmark bar.
This is a simplified version of the windows code. There will be a follow-up patch to switch windows over to using this as well. I ran into some trouble calculating the correct size of the tab contents. Punting on that for now, filed http://crbug.com/23907 BUG=22836 TEST=Tested on klassen, candies, karim rashid, tiesto, ratchet and clank, and jeff coons themes. Review URL: http://codereview.chromium.org/255086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28215 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc63
1 files changed, 28 insertions, 35 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index 4197b21..33fa70e 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -6,6 +6,7 @@
#include <vector>
+#include "app/gfx/canvas_paint.h"
#include "app/gfx/text_elider.h"
#include "app/gtk_dnd_util.h"
#include "app/l10n_util.h"
@@ -30,8 +31,10 @@
#include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
#include "chrome/browser/gtk/view_id_util.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/ntp_background_util.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/gtk_util.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
@@ -1017,12 +1020,12 @@ gboolean BookmarkBarGtk::OnEventBoxExpose(GtkWidget* widget,
if (theme_provider->UseGtkTheme() && !bar->floating_)
return FALSE;
- cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
- cairo_rectangle(cr, event->area.x, event->area.y,
- event->area.width, event->area.height);
- cairo_clip(cr);
-
if (!bar->floating_) {
+ cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
+ cairo_rectangle(cr, event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cairo_clip(cr);
+
// Paint the background theme image.
gfx::Point tabstrip_origin =
bar->tabstrip_origin_provider_->GetTabStripOriginForWidget(widget);
@@ -1038,40 +1041,30 @@ gboolean BookmarkBarGtk::OnEventBoxExpose(GtkWidget* widget,
event->area.x + event->area.width - tabstrip_origin.x(),
event->area.y + event->area.height - tabstrip_origin.y());
cairo_fill(cr);
- } else {
- // Paint the NTP background. First set the background color.
- GdkColor bg_color = theme_provider->UseGtkTheme() ? gfx::kGdkWhite :
- theme_provider->GetGdkColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND);
- double bg_color_rgb[] = {
- static_cast<double>(bg_color.red / 257) / 255.0,
- static_cast<double>(bg_color.green / 257) / 255.0,
- static_cast<double>(bg_color.blue / 257) / 255.0, };
- cairo_set_source_rgb(cr, bg_color_rgb[0], bg_color_rgb[1], bg_color_rgb[2]);
- cairo_rectangle(cr,
- event->area.x,
- event->area.y,
- event->area.width,
- event->area.height);
- cairo_fill(cr);
- // Now paint the image, if it exists.
- // TODO(estade): handle different alignments.
- if (theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
- CairoCachedSurface* background = theme_provider->GetSurfaceNamed(
- IDR_THEME_NTP_BACKGROUND, widget);
- background->SetSource(cr, widget->allocation.x, widget->allocation.y);
- cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
- cairo_rectangle(cr,
- event->area.x,
- event->area.y,
- event->area.width,
- event->area.height);
- cairo_fill(cr);
+ cairo_destroy(cr);
+ } else {
+ gfx::Size tab_contents_size;
+ Browser* browser = bar->browser_;
+ if (!browser) {
+ NOTREACHED();
+ return FALSE;
+ }
+ TabContents* tab_contents = browser->GetSelectedTabContents();
+ if (!tab_contents) {
+ NOTREACHED();
+ return FALSE;
}
+ if (!tab_contents->view()) {
+ NOTREACHED();
+ return FALSE;
+ }
+ tab_contents_size = tab_contents->view()->GetContainerSize();
+ gfx::CanvasPaint canvas(event, true);
+ NtpBackgroundUtil::PaintBackgroundDetachedMode(theme_provider, &canvas,
+ gfx::Rect(widget->allocation), tab_contents_size.height());
}
- cairo_destroy(cr);
-
return FALSE; // Propagate expose to children.
}