cds: enable outset shadows

Adds conditional code paths to GdkCssShadowValue for painting outset
shadows, and allows shadows to be applied in two passes (first outset
then inset). This can be used to draw csd shadows in outer window
borders.

https://bugzilla.gnome.org/show_bug.cgi?id=695998
Signed-off-by: Rob Bradford <rob@linux.intel.com>
This commit is contained in:
Chris Cummins 2013-04-05 10:54:03 +01:00 committed by Rob Bradford
parent b37d83e988
commit f478f16dba
5 changed files with 34 additions and 10 deletions

View File

@ -287,7 +287,8 @@ _gtk_css_shadows_value_paint_spinner (const GtkCssValue *shadows,
void
_gtk_css_shadows_value_paint_box (const GtkCssValue *shadows,
cairo_t *cr,
const GtkRoundedBox *padding_box)
const GtkRoundedBox *padding_box,
gboolean inset)
{
guint i;
@ -295,6 +296,7 @@ _gtk_css_shadows_value_paint_box (const GtkCssValue *shadows,
for (i = 0; i < shadows->len; i++)
{
_gtk_css_shadow_value_paint_box (shadows->values[i], cr, padding_box);
if (inset == _gtk_css_shadow_value_get_inset (shadows->values[i]))
_gtk_css_shadow_value_paint_box (shadows->values[i], cr, padding_box);
}
}

View File

@ -46,7 +46,8 @@ void _gtk_css_shadows_value_paint_spinner (const GtkCssValue
gdouble progress);
void _gtk_css_shadows_value_paint_box (const GtkCssValue *shadows,
cairo_t *cr,
const GtkRoundedBox *padding_box);
const GtkRoundedBox *padding_box,
gboolean inset);
G_END_DECLS

View File

@ -445,6 +445,14 @@ _gtk_css_shadow_value_paint_spinner (const GtkCssValue *shadow,
cairo_restore (cr);
}
gboolean
_gtk_css_shadow_value_get_inset (const GtkCssValue *shadow)
{
g_return_val_if_fail (shadow->class == &GTK_CSS_VALUE_SHADOW, FALSE);
return shadow->inset;
}
void
_gtk_css_shadow_value_paint_box (const GtkCssValue *shadow,
cairo_t *cr,
@ -457,15 +465,21 @@ _gtk_css_shadow_value_paint_box (const GtkCssValue *shadow,
cairo_save (cr);
_gtk_rounded_box_path (padding_box, cr);
cairo_clip (cr);
if (shadow->inset)
{
_gtk_rounded_box_path (padding_box, cr);
cairo_clip (cr);
}
box = *padding_box;
_gtk_rounded_box_move (&box,
_gtk_css_number_value_get (shadow->hoffset, 0),
_gtk_css_number_value_get (shadow->voffset, 0));
spread = _gtk_css_number_value_get (shadow->spread, 0);
_gtk_rounded_box_shrink (&box, spread, spread, spread, spread);
if (shadow->inset)
_gtk_rounded_box_shrink (&box, spread, spread, spread, spread);
else /* Outset */
_gtk_rounded_box_grow (&box, spread, spread, spread, spread);
clip_box = *padding_box;
radius = _gtk_css_number_value_get (shadow->radius, 0);
@ -475,7 +489,8 @@ _gtk_css_shadow_value_paint_box (const GtkCssValue *shadow,
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
_gtk_rounded_box_path (&box, cr);
_gtk_rounded_box_clip_path (&clip_box, cr);
if (shadow->inset)
_gtk_rounded_box_clip_path (&clip_box, cr);
gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color));
cairo_fill (cr);

View File

@ -34,6 +34,8 @@ GtkCssValue * _gtk_css_shadow_value_new_for_transition (GtkCssValue
GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser);
gboolean _gtk_css_shadow_value_get_inset (const GtkCssValue *shadow);
void _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow,
cairo_t *cr,
PangoLayout *layout);

View File

@ -265,11 +265,13 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
static void
_gtk_theming_background_apply_shadow (GtkThemingBackground *bg,
cairo_t *cr)
cairo_t *cr,
gboolean inset)
{
_gtk_css_shadows_value_paint_box (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BOX_SHADOW),
cr,
&bg->padding_box);
&bg->padding_box,
inset);
}
static void
@ -358,6 +360,8 @@ _gtk_theming_background_render (GtkThemingBackground *bg,
cairo_save (cr);
cairo_translate (cr, bg->paint_area.x, bg->paint_area.y);
_gtk_theming_background_apply_shadow (bg, cr, FALSE); /* Outset shadow */
_gtk_theming_background_paint_color (bg, cr, background_image);
for (idx = _gtk_css_array_value_get_n_values (background_image) - 1; idx >= 0; idx--)
@ -365,7 +369,7 @@ _gtk_theming_background_render (GtkThemingBackground *bg,
_gtk_theming_background_paint_layer (bg, idx, cr);
}
_gtk_theming_background_apply_shadow (bg, cr);
_gtk_theming_background_apply_shadow (bg, cr, TRUE); /* Inset shadow */
cairo_restore (cr);
}