mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
cssshadow: add a method to get the size of a shadows value
The method returns the size of each side of a GtkCssShadowsValue.
This commit is contained in:
parent
7846bedebd
commit
a44d6816d3
@ -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 == >K_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 == >K_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);
|
||||
|
Loading…
Reference in New Issue
Block a user