[StShadow] Add support for spread radius

The (optional) spread radius allows to make the shadow bigger without
enlarging the blur value. Mozilla supports this parameter for the
-moz-box-shadow property.

https://bugzilla.gnome.org/show_bug.cgi?id=613832
This commit is contained in:
Florian Müllner 2010-03-19 11:34:32 +01:00
parent b71afe55d8
commit 50c453c54d
4 changed files with 28 additions and 7 deletions

View File

@ -19,6 +19,7 @@
* @xoffset: horizontal offset * @xoffset: horizontal offset
* @yoffset: vertical offset * @yoffset: vertical offset
* @blur: blur radius * @blur: blur radius
* @spread: spread radius
* *
* Creates a new #StShadow * Creates a new #StShadow
* *
@ -28,7 +29,8 @@ StShadow *
st_shadow_new (ClutterColor *color, st_shadow_new (ClutterColor *color,
gdouble xoffset, gdouble xoffset,
gdouble yoffset, gdouble yoffset,
gdouble blur) gdouble blur,
gdouble spread)
{ {
StShadow *shadow; StShadow *shadow;
@ -38,6 +40,7 @@ st_shadow_new (ClutterColor *color,
shadow->xoffset = xoffset; shadow->xoffset = xoffset;
shadow->yoffset = yoffset; shadow->yoffset = yoffset;
shadow->blur = blur; shadow->blur = blur;
shadow->spread = spread;
return shadow; return shadow;
} }

View File

@ -18,6 +18,8 @@ typedef struct _StShadow StShadow;
* @yoffset: vertical offset - positive values mean placement below, negative * @yoffset: vertical offset - positive values mean placement below, negative
* values placement above the element. * values placement above the element.
* @blur: shadow's blur radius - a value of 0.0 will result in a hard shadow. * @blur: shadow's blur radius - a value of 0.0 will result in a hard shadow.
* @spread: shadow's spread radius - grow the shadow without enlarging the
* blur.
* *
* Attributes of the -st-shadow property. * Attributes of the -st-shadow property.
*/ */
@ -26,6 +28,7 @@ struct _StShadow {
gdouble xoffset; gdouble xoffset;
gdouble yoffset; gdouble yoffset;
gdouble blur; gdouble blur;
gdouble spread;
}; };
GType st_shadow_get_type (void) G_GNUC_CONST; GType st_shadow_get_type (void) G_GNUC_CONST;
@ -33,7 +36,8 @@ GType st_shadow_get_type (void) G_GNUC_CONST;
StShadow *st_shadow_new (ClutterColor *color, StShadow *st_shadow_new (ClutterColor *color,
gdouble xoffset, gdouble xoffset,
gdouble yoffset, gdouble yoffset,
gdouble blur); gdouble blur,
gdouble spread);
StShadow *st_shadow_copy (const StShadow *shadow); StShadow *st_shadow_copy (const StShadow *shadow);
void st_shadow_free (StShadow *shadow); void st_shadow_free (StShadow *shadow);

View File

@ -1079,10 +1079,14 @@ st_theme_node_paint (StThemeNode *node,
shadow_spec = node->shadow; shadow_spec = node->shadow;
shadow_box.x1 = background_box.x1 + shadow_spec->xoffset - shadow_spec->blur; shadow_box.x1 = background_box.x1 + shadow_spec->xoffset
shadow_box.y1 = background_box.y1 + shadow_spec->yoffset - shadow_spec->blur; - shadow_spec->blur - shadow_spec->spread;
shadow_box.x2 = background_box.x2 + shadow_spec->xoffset + shadow_spec->blur; shadow_box.y1 = background_box.y1 + shadow_spec->yoffset
shadow_box.y2 = background_box.y2 + shadow_spec->yoffset + shadow_spec->blur; - shadow_spec->blur - shadow_spec->spread;
shadow_box.x2 = background_box.x2 + shadow_spec->xoffset
+ shadow_spec->blur + shadow_spec->spread;
shadow_box.y2 = background_box.y2 + shadow_spec->yoffset
+ shadow_spec->blur + shadow_spec->spread;
cogl_material_set_color4ub (node->shadow_material, cogl_material_set_color4ub (node->shadow_material,
paint_opacity, paint_opacity, paint_opacity, paint_opacity); paint_opacity, paint_opacity, paint_opacity, paint_opacity);

View File

@ -2220,6 +2220,7 @@ st_theme_node_get_shadow (StThemeNode *node)
gdouble xoffset = 0.; gdouble xoffset = 0.;
gdouble yoffset = 0.; gdouble yoffset = 0.;
gdouble blur = 0.; gdouble blur = 0.;
gdouble spread = 0.;
int n_offsets = 0; int n_offsets = 0;
for (term = decl->value; term; term = term->next) for (term = decl->value; term; term = term->next)
@ -2248,6 +2249,13 @@ st_theme_node_get_shadow (StThemeNode *node)
g_warning ("Negative blur values are " g_warning ("Negative blur values are "
"not allowed"); "not allowed");
blur = value; blur = value;
break;
case 3:
if (multiplier < 0)
g_warning ("Negative spread values are "
"not allowed");
spread = value;
break;
} }
continue; continue;
} }
@ -2259,7 +2267,9 @@ st_theme_node_get_shadow (StThemeNode *node)
continue; continue;
} }
} }
node->shadow = st_shadow_new (&color, xoffset, yoffset, blur); node->shadow = st_shadow_new (&color,
xoffset, yoffset,
blur, spread);
return node->shadow; return node->shadow;
} }