summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 20:40:50 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 20:40:50 +0000
commita1fb7c005bcbe61577e0cf275f4bf6a612ac3b6a (patch)
treef6a5bff4639b7a79e2d4a1980113fc9381a22791 /chrome/browser
parent2b7523db7224f3460bb61a30f1ef420bafbd2822 (diff)
downloadchromium_src-a1fb7c005bcbe61577e0cf275f4bf6a612ac3b6a.zip
chromium_src-a1fb7c005bcbe61577e0cf275f4bf6a612ac3b6a.tar.gz
chromium_src-a1fb7c005bcbe61577e0cf275f4bf6a612ac3b6a.tar.bz2
Draw the side and bottom shadows in the native frame.
As with the rest of our shadow drawing, we don't overlap 1 pixel, we just draw the area around. BUG=15505 Review URL: http://codereview.chromium.org/160306 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21989 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc130
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h3
2 files changed, 118 insertions, 15 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index f818aa0..983b519d 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -471,21 +471,7 @@ gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
}
image->RenderTopCenterStrip(cr, 0, 0, widget->allocation.width);
- // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us.
- static NineBox top_shadow(theme_provider,
- 0, IDR_CONTENT_TOP_CENTER, 0, 0, 0, 0, 0, 0, 0);
- gint shadow_x, shadow_y;
- gtk_widget_translate_coordinates(window->content_vbox_,
- GTK_WIDGET(window->window_), 0, -kContentShadowThickness, &shadow_x,
- &shadow_y);
- top_shadow.RenderTopCenterStrip(cr,
- static_cast<int>(shadow_x),
- static_cast<int>(shadow_y),
- static_cast<int>(window->content_vbox_->allocation.width));
-
- // TODO(tc): Draw the shadow around the rest of content_vbox_ (corners, sides
- // and bottom). Only do this if the custom frame is enabled.
- // http://crbug.com/15505
+ DrawContentShadow(cr, window);
// TODO(tc): Draw the theme overlay. The windows code is below.
// if (theme_provider->HasCustomImage(IDR_THEME_FRAME_OVERLAY)) {
@@ -515,6 +501,120 @@ gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
return FALSE; // Allow subwidgets to paint.
}
+// static
+void BrowserWindowGtk::DrawContentShadow(cairo_t* cr,
+ BrowserWindowGtk* window) {
+ // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us.
+ ThemeProvider* theme_provider =
+ window->browser()->profile()->GetThemeProvider();
+ static NineBox top_shadow(theme_provider,
+ 0, IDR_CONTENT_TOP_CENTER, 0, 0, 0, 0, 0, 0, 0);
+ int left_x, top_y;
+ gtk_widget_translate_coordinates(window->content_vbox_,
+ GTK_WIDGET(window->window_), 0, 0, &left_x,
+ &top_y);
+ int width = window->content_vbox_->allocation.width;
+ top_shadow.RenderTopCenterStrip(cr,
+ left_x, top_y - kContentShadowThickness, width);
+
+ // Only draw the rest of the shadow if the user has the custom frame enabled.
+ if (!window->use_custom_frame_.GetValue())
+ return;
+
+ // The top left corner has a width of 3 pixels. On Windows, the last column
+ // of pixels overlap the toolbar. We just crop it off on Linux. The top
+ // corners extend to the base of the toolbar (one pixel above the dividing
+ // line).
+ int right_x = left_x + width;
+ GdkPixbuf* top_left =
+ theme_provider->GetPixbufNamed(IDR_CONTENT_TOP_LEFT_CORNER);
+ gdk_cairo_set_source_pixbuf(cr, top_left,
+ left_x - kContentShadowThickness, top_y - kContentShadowThickness);
+ // The toolbar is shorter in location bar only mode so clip the image to the
+ // height of the toolbar + the amount of shadow above the toolbar.
+ int top_corner_height =
+ window->toolbar_->widget()->allocation.height + kContentShadowThickness;
+ cairo_rectangle(cr,
+ left_x - kContentShadowThickness,
+ top_y - kContentShadowThickness,
+ kContentShadowThickness,
+ top_corner_height);
+ cairo_fill(cr);
+
+ // Likewise, we crop off the left column of pixels for the top right corner.
+ GdkPixbuf* top_right =
+ theme_provider->GetPixbufNamed(IDR_CONTENT_TOP_RIGHT_CORNER);
+ gdk_cairo_set_source_pixbuf(cr, top_right,
+ right_x - 1, top_y - kContentShadowThickness);
+ cairo_rectangle(cr,
+ right_x,
+ top_y - kContentShadowThickness,
+ kContentShadowThickness,
+ top_corner_height);
+ cairo_fill(cr);
+
+ // Fill in the sides. As above, we only draw 2 of the 3 columns on Linux.
+ int height = window->content_vbox_->allocation.height;
+ int bottom_y = top_y + height;
+ // |side_y| is where to start drawing the side shadows. The top corners draw
+ // the sides down to the bottom of the toolbar.
+ int side_y = top_y - kContentShadowThickness + top_corner_height;
+ // |side_height| is how many pixels to draw for the side borders. We do one
+ // pixel before the bottom of the web contents because that extra pixel is
+ // drawn by the bottom corners.
+ int side_height = bottom_y - side_y - 1;
+ if (side_height > 0) {
+ GdkPixbuf* left = theme_provider->GetPixbufNamed(IDR_CONTENT_LEFT_SIDE);
+ gdk_cairo_set_source_pixbuf(cr, left,
+ left_x - kContentShadowThickness, side_y);
+ cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle(cr,
+ left_x - kContentShadowThickness,
+ side_y,
+ kContentShadowThickness,
+ side_height);
+ cairo_fill(cr);
+
+ GdkPixbuf* right = theme_provider->GetPixbufNamed(IDR_CONTENT_RIGHT_SIDE);
+ gdk_cairo_set_source_pixbuf(cr, right, right_x - 1, side_y);
+ cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle(cr,
+ right_x,
+ side_y,
+ kContentShadowThickness,
+ side_height);
+ cairo_fill(cr);
+ }
+
+ // Draw the bottom corners. The bottom corners also draw the bottom row of
+ // pixels of the side shadows.
+ GdkPixbuf* bottom_left =
+ theme_provider->GetPixbufNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
+ gdk_cairo_set_source_pixbuf(cr, bottom_left,
+ left_x - kContentShadowThickness, bottom_y - 1);
+ cairo_paint(cr);
+
+ GdkPixbuf* bottom_right =
+ theme_provider->GetPixbufNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER);
+ gdk_cairo_set_source_pixbuf(cr, bottom_right,
+ right_x - 1, bottom_y - 1);
+ cairo_paint(cr);
+
+ // Finally, draw the bottom row. Since we don't overlap the contents, we clip
+ // the top row of pixels.
+ GdkPixbuf* bottom =
+ theme_provider->GetPixbufNamed(IDR_CONTENT_BOTTOM_CENTER);
+ gdk_cairo_set_source_pixbuf(cr, bottom,
+ left_x + 1, bottom_y - 1);
+ cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle(cr,
+ left_x + 1,
+ bottom_y,
+ width - 2,
+ kContentShadowThickness);
+ cairo_fill(cr);
+}
+
void BrowserWindowGtk::Show() {
// The Browser associated with this browser window must become the active
// browser at the time Show() is called. This is the natural behaviour under
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index 3df7d40..d2e3f2d 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -223,6 +223,9 @@ class BrowserWindowGtk : public BrowserWindow,
// The content area includes the toolbar and web page but not the tab strip.
static gboolean OnCustomFrameExpose(GtkWidget* widget, GdkEventExpose* event,
BrowserWindowGtk* window);
+ // A helper method that draws the shadow above the toolbar and in the frame
+ // border during an expose.
+ static void DrawContentShadow(cairo_t* cr, BrowserWindowGtk* window);
static gboolean OnGtkAccelerator(GtkAccelGroup* accel_group,
GObject* acceleratable,