Commit a44d6816 authored by Cosimo Cecchi's avatar Cosimo Cecchi

cssshadow: add a method to get the size of a shadows value

The method returns the size of each side of a GtkCssShadowsValue.
parent 7846bede
......@@ -300,3 +300,37 @@ _gtk_css_shadows_value_paint_box (const GtkCssValue *shadows,
_gtk_css_shadow_value_paint_box (shadows->values[i], cr, padding_box);
}
}
void
_gtk_css_shadows_value_get_extents (const GtkCssValue *shadows,
GtkBorder *border)
{
guint i;
GtkBorder b = { 0 };
const GtkCssValue *shadow;
gdouble hoffset, voffset, spread, radius;
g_return_if_fail (shadows->class == &GTK_CSS_VALUE_SHADOWS);
for (i = 0; i < shadows->len; i++)
{
shadow = shadows->values[i];
if (_gtk_css_shadow_value_get_inset (shadow))
continue;
_gtk_css_shadow_value_get_geometry (shadow,
&hoffset, &voffset,
&radius, &spread);
b.top = MAX (0, radius + spread - voffset);
b.right = MAX (0, radius + spread + hoffset);
b.bottom = MAX (0, radius + spread + voffset);
b.left = MAX (0, radius + spread - hoffset);
border->top = MAX (border->top, b.top);
border->right = MAX (border->right, b.right);
border->bottom = MAX (border->bottom, b.bottom);
border->left = MAX (border->left, b.left);
}
}
......@@ -49,6 +49,9 @@ void _gtk_css_shadows_value_paint_box (const GtkCssValue
const GtkRoundedBox *padding_box,
gboolean inset);
void _gtk_css_shadows_value_get_extents (const GtkCssValue *shadows,
GtkBorder *border);
G_END_DECLS
#endif /* __GTK_CSS_SHADOWS_VALUE_H__ */
......@@ -453,6 +453,26 @@ _gtk_css_shadow_value_get_inset (const GtkCssValue *shadow)
return shadow->inset;
}
void
_gtk_css_shadow_value_get_geometry (const GtkCssValue *shadow,
gdouble *hoffset,
gdouble *voffset,
gdouble *radius,
gdouble *spread)
{
g_return_if_fail (shadow->class == &GTK_CSS_VALUE_SHADOW);
if (hoffset != NULL)
*hoffset = _gtk_css_number_value_get (shadow->hoffset, 0);
if (voffset != NULL)
*voffset = _gtk_css_number_value_get (shadow->voffset, 0);
if (radius != NULL)
*radius = _gtk_css_number_value_get (shadow->radius, 0);
if (spread != NULL)
*spread = _gtk_css_number_value_get (shadow->spread, 0);
}
void
_gtk_css_shadow_value_paint_box (const GtkCssValue *shadow,
cairo_t *cr,
......
......@@ -36,6 +36,12 @@ GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser
gboolean _gtk_css_shadow_value_get_inset (const GtkCssValue *shadow);
void _gtk_css_shadow_value_get_geometry (const GtkCssValue *shadow,
gdouble *hoffset,
gdouble *voffset,
gdouble *radius,
gdouble *spread);
void _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow,
cairo_t *cr,
PangoLayout *layout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment