cssshadowvalue: Add a parsing function

Add a variant of the parse function that parses
just a single (non-box) shadow, as required for
the drop-shadow filter.
This commit is contained in:
Matthias Clasen 2021-02-05 21:36:22 -05:00
parent 60ff231fac
commit de24b4f91b
2 changed files with 33 additions and 0 deletions

View File

@ -326,6 +326,21 @@ gtk_css_shadow_value_new (ShadowValue *shadows,
return retval; return retval;
} }
GtkCssValue *
gtk_css_shadow_value_new_filter (void)
{
ShadowValue value;
value.inset = FALSE;
value.hoffset = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
value.voffset = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
value.radius = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
value.spread = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
value.color = _gtk_css_color_value_new_current_color ();
return gtk_css_shadow_value_new (&value, 1);
}
enum { enum {
HOFFSET, HOFFSET,
VOFFSET, VOFFSET,
@ -497,6 +512,22 @@ fail:
return NULL; return NULL;
} }
GtkCssValue *
_gtk_css_shadow_value_parse_filter (GtkCssParser *parser)
{
GtkCssValue *result;
result = _gtk_css_shadow_value_parse (parser, FALSE);
if (result && result->n_shadows != 1)
{
gtk_css_parser_error_syntax (parser, "A single shadow is required");
g_clear_pointer (&result, gtk_css_value_unref);
}
return result;
}
void void
gtk_css_shadow_value_get_extents (const GtkCssValue *value, gtk_css_shadow_value_get_extents (const GtkCssValue *value,
GtkBorder *border) GtkBorder *border)

View File

@ -35,9 +35,11 @@
G_BEGIN_DECLS G_BEGIN_DECLS
GtkCssValue * gtk_css_shadow_value_new_none (void); GtkCssValue * gtk_css_shadow_value_new_none (void);
GtkCssValue * gtk_css_shadow_value_new_filter (void);
GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser, GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser,
gboolean box_shadow_mode); gboolean box_shadow_mode);
GtkCssValue * _gtk_css_shadow_value_parse_filter (GtkCssParser *parser);
void gtk_css_shadow_value_get_extents (const GtkCssValue *shadow, void gtk_css_shadow_value_get_extents (const GtkCssValue *shadow,
GtkBorder *border); GtkBorder *border);