summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/browser_toolbar_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 21:44:36 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 21:44:36 +0000
commit90aeba51821eeb1181778c87152e4736fc011cbd (patch)
treeddfee05acfae06dadc974693a28d5f248dfdd61d /chrome/browser/gtk/browser_toolbar_gtk.cc
parente92dffef76706260903d20da5039ca15bc2d8652 (diff)
downloadchromium_src-90aeba51821eeb1181778c87152e4736fc011cbd.zip
chromium_src-90aeba51821eeb1181778c87152e4736fc011cbd.tar.gz
chromium_src-90aeba51821eeb1181778c87152e4736fc011cbd.tar.bz2
GTK: custom frame/drop shadow updates.
- round top corners of toolbar (in chrome theme mode only) - round bottom corners of window (custom frame) FWIW, our shadow was actually broken by r44177; you can notice this by using xmag on the top right corner of the toolbar on current dev builds. BUG=43632 TEST=manual Review URL: http://codereview.chromium.org/1985016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_toolbar_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc76
1 files changed, 74 insertions, 2 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 18ace5e..6cd4d8e 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -524,8 +524,80 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget,
gfx::Point tabstrip_origin =
window_->tabstrip()->GetTabStripOriginForWidget(widget);
- gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin,
- theme_provider_);
+ // Fill the entire region with the toolbar color.
+ GdkColor color = theme_provider_->GetGdkColor(
+ BrowserThemeProvider::COLOR_TOOLBAR);
+ gdk_cairo_set_source_color(cr, &color);
+ cairo_fill(cr);
+
+ // The horizontal size of the top left and right corner images.
+ const int kCornerWidth = 4;
+ // The thickness of the shadow outside the toolbar's bounds; the offset
+ // between the edge of the toolbar and where we anchor the corner images.
+ const int kShadowThickness = 2;
+
+ gfx::Rect area(e->area);
+ gfx::Rect right(widget->allocation.x + widget->allocation.width -
+ kCornerWidth,
+ widget->allocation.y - kShadowThickness,
+ kCornerWidth,
+ widget->allocation.height + kShadowThickness);
+ gfx::Rect left(widget->allocation.x - kShadowThickness,
+ widget->allocation.y - kShadowThickness,
+ kCornerWidth,
+ widget->allocation.height + kShadowThickness);
+ area = area.Subtract(right).Subtract(left);
+
+ CairoCachedSurface* background = theme_provider_->GetSurfaceNamed(
+ IDR_THEME_TOOLBAR, widget);
+ background->SetSource(cr, tabstrip_origin.x(), tabstrip_origin.y());
+ cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle(cr, area.x(), area.y(), area.width(), area.height());
+ cairo_fill(cr);
+
+ bool draw_left_corner = left.Intersects(gfx::Rect(e->area));
+ bool draw_right_corner = right.Intersects(gfx::Rect(e->area));
+
+ if (draw_left_corner || draw_right_corner) {
+ // Create a mask which is composed of the left and/or right corners.
+ cairo_surface_t* target = cairo_surface_create_similar(
+ cairo_get_target(cr),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ widget->allocation.x + widget->allocation.width,
+ widget->allocation.y + widget->allocation.height);
+ cairo_t* copy_cr = cairo_create(target);
+
+ cairo_set_operator(copy_cr, CAIRO_OPERATOR_SOURCE);
+ if (draw_left_corner) {
+ CairoCachedSurface* left_corner = theme_provider_->GetSurfaceNamed(
+ IDR_CONTENT_TOP_LEFT_CORNER_MASK, widget);
+ left_corner->SetSource(copy_cr, left.x(), left.y());
+ cairo_paint(copy_cr);
+ }
+ if (draw_right_corner) {
+ CairoCachedSurface* right_corner = theme_provider_->GetSurfaceNamed(
+ IDR_CONTENT_TOP_RIGHT_CORNER_MASK, widget);
+ right_corner->SetSource(copy_cr, right.x(), right.y());
+ // We fill a path rather than just painting because we don't want to
+ // overwrite the left corner.
+ cairo_rectangle(copy_cr, right.x(), right.y(),
+ right.width(), right.height());
+ cairo_fill(copy_cr);
+ }
+
+ // Draw the background. CAIRO_OPERATOR_IN uses the existing pixel data as
+ // an alpha mask.
+ background->SetSource(copy_cr, tabstrip_origin.x(), tabstrip_origin.y());
+ cairo_set_operator(copy_cr, CAIRO_OPERATOR_IN);
+ cairo_pattern_set_extend(cairo_get_source(copy_cr), CAIRO_EXTEND_REPEAT);
+ cairo_paint(copy_cr);
+ cairo_destroy(copy_cr);
+
+ // Copy the temporary surface to the screen.
+ cairo_set_source_surface(cr, target, 0, 0);
+ cairo_paint(cr);
+ cairo_surface_destroy(target);
+ }
cairo_destroy(cr);