nodeparser: Support color states for box shadows
Just switch from parse_color to parse_color2, and apply the corresponding changes to serialization too. Test included.
This commit is contained in:
@@ -1878,20 +1878,25 @@ parse_inset_shadow_node (GtkCssParser *parser,
|
|||||||
Context *context)
|
Context *context)
|
||||||
{
|
{
|
||||||
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
|
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
|
||||||
GdkRGBA color = GDK_RGBA("000000");
|
GdkColor color = GDK_COLOR_SRGB (0, 0, 0, 1);
|
||||||
double dx = 1, dy = 1, blur = 0, spread = 0;
|
double dx = 1, dy = 1, blur = 0, spread = 0;
|
||||||
const Declaration declarations[] = {
|
const Declaration declarations[] = {
|
||||||
{ "outline", parse_rounded_rect, NULL, &outline },
|
{ "outline", parse_rounded_rect, NULL, &outline },
|
||||||
{ "color", parse_color, NULL, &color },
|
{ "color", parse_color2, NULL, &color },
|
||||||
{ "dx", parse_double, NULL, &dx },
|
{ "dx", parse_double, NULL, &dx },
|
||||||
{ "dy", parse_double, NULL, &dy },
|
{ "dy", parse_double, NULL, &dy },
|
||||||
{ "spread", parse_double, NULL, &spread },
|
{ "spread", parse_double, NULL, &spread },
|
||||||
{ "blur", parse_positive_double, NULL, &blur }
|
{ "blur", parse_positive_double, NULL, &blur }
|
||||||
};
|
};
|
||||||
|
GskRenderNode *node;
|
||||||
|
|
||||||
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
|
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
|
||||||
|
|
||||||
return gsk_inset_shadow_node_new (&outline, &color, dx, dy, spread, blur);
|
node = gsk_inset_shadow_node_new2 (&outline, &color, dx, dy, spread, blur);
|
||||||
|
|
||||||
|
gdk_color_finish (&color);
|
||||||
|
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
@@ -2287,20 +2292,25 @@ parse_outset_shadow_node (GtkCssParser *parser,
|
|||||||
Context *context)
|
Context *context)
|
||||||
{
|
{
|
||||||
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
|
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
|
||||||
GdkRGBA color = GDK_RGBA("000000");
|
GdkColor color = GDK_COLOR_SRGB (0, 0, 0, 1);
|
||||||
double dx = 1, dy = 1, blur = 0, spread = 0;
|
double dx = 1, dy = 1, blur = 0, spread = 0;
|
||||||
const Declaration declarations[] = {
|
const Declaration declarations[] = {
|
||||||
{ "outline", parse_rounded_rect, NULL, &outline },
|
{ "outline", parse_rounded_rect, NULL, &outline },
|
||||||
{ "color", parse_color, NULL, &color },
|
{ "color", parse_color2, NULL, &color },
|
||||||
{ "dx", parse_double, NULL, &dx },
|
{ "dx", parse_double, NULL, &dx },
|
||||||
{ "dy", parse_double, NULL, &dy },
|
{ "dy", parse_double, NULL, &dy },
|
||||||
{ "spread", parse_double, NULL, &spread },
|
{ "spread", parse_double, NULL, &spread },
|
||||||
{ "blur", parse_positive_double, NULL, &blur }
|
{ "blur", parse_positive_double, NULL, &blur }
|
||||||
};
|
};
|
||||||
|
GskRenderNode *node;
|
||||||
|
|
||||||
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
|
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
|
||||||
|
|
||||||
return gsk_outset_shadow_node_new (&outline, &color, dx, dy, spread, blur);
|
node = gsk_outset_shadow_node_new2 (&outline, &color, dx, dy, spread, blur);
|
||||||
|
|
||||||
|
gdk_color_finish (&color);
|
||||||
|
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GskRenderNode *
|
static GskRenderNode *
|
||||||
@@ -3324,14 +3334,20 @@ printer_init_duplicates_for_node (Printer *printer,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GSK_INSET_SHADOW_NODE:
|
||||||
|
printer_init_check_color_state (printer, gsk_inset_shadow_node_get_color2 (node)->color_state);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GSK_OUTSET_SHADOW_NODE:
|
||||||
|
printer_init_check_color_state (printer, gsk_outset_shadow_node_get_color2 (node)->color_state);
|
||||||
|
break;
|
||||||
|
|
||||||
case GSK_CAIRO_NODE:
|
case GSK_CAIRO_NODE:
|
||||||
case GSK_LINEAR_GRADIENT_NODE:
|
case GSK_LINEAR_GRADIENT_NODE:
|
||||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||||
case GSK_RADIAL_GRADIENT_NODE:
|
case GSK_RADIAL_GRADIENT_NODE:
|
||||||
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
||||||
case GSK_CONIC_GRADIENT_NODE:
|
case GSK_CONIC_GRADIENT_NODE:
|
||||||
case GSK_INSET_SHADOW_NODE:
|
|
||||||
case GSK_OUTSET_SHADOW_NODE:
|
|
||||||
/* no children */
|
/* no children */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -4334,13 +4350,11 @@ render_node_print (Printer *p,
|
|||||||
|
|
||||||
case GSK_OUTSET_SHADOW_NODE:
|
case GSK_OUTSET_SHADOW_NODE:
|
||||||
{
|
{
|
||||||
const GdkRGBA *color = gsk_outset_shadow_node_get_color (node);
|
|
||||||
|
|
||||||
start_node (p, "outset-shadow", node_name);
|
start_node (p, "outset-shadow", node_name);
|
||||||
|
|
||||||
append_float_param (p, "blur", gsk_outset_shadow_node_get_blur_radius (node), 0.0f);
|
append_float_param (p, "blur", gsk_outset_shadow_node_get_blur_radius (node), 0.0f);
|
||||||
if (!gdk_rgba_equal (color, &GDK_RGBA("000")))
|
if (!gdk_color_equal (gsk_inset_shadow_node_get_color2 (node), &GDK_COLOR_SRGB (0, 0, 0, 1)))
|
||||||
append_rgba_param (p, "color", color);
|
append_color_param (p, "color", gsk_outset_shadow_node_get_color2 (node));
|
||||||
append_float_param (p, "dx", gsk_outset_shadow_node_get_dx (node), 1.0f);
|
append_float_param (p, "dx", gsk_outset_shadow_node_get_dx (node), 1.0f);
|
||||||
append_float_param (p, "dy", gsk_outset_shadow_node_get_dy (node), 1.0f);
|
append_float_param (p, "dy", gsk_outset_shadow_node_get_dy (node), 1.0f);
|
||||||
append_rounded_rect_param (p, "outline", gsk_outset_shadow_node_get_outline (node));
|
append_rounded_rect_param (p, "outline", gsk_outset_shadow_node_get_outline (node));
|
||||||
@@ -4539,12 +4553,11 @@ render_node_print (Printer *p,
|
|||||||
|
|
||||||
case GSK_INSET_SHADOW_NODE:
|
case GSK_INSET_SHADOW_NODE:
|
||||||
{
|
{
|
||||||
const GdkRGBA *color = gsk_inset_shadow_node_get_color (node);
|
|
||||||
start_node (p, "inset-shadow", node_name);
|
start_node (p, "inset-shadow", node_name);
|
||||||
|
|
||||||
append_float_param (p, "blur", gsk_inset_shadow_node_get_blur_radius (node), 0.0f);
|
append_float_param (p, "blur", gsk_inset_shadow_node_get_blur_radius (node), 0.0f);
|
||||||
if (!gdk_rgba_equal (color, &GDK_RGBA("000")))
|
if (!gdk_color_equal (gsk_inset_shadow_node_get_color2 (node), &GDK_COLOR_SRGB (0, 0, 0, 1)))
|
||||||
append_rgba_param (p, "color", color);
|
append_color_param (p, "color", gsk_inset_shadow_node_get_color2 (node));
|
||||||
append_float_param (p, "dx", gsk_inset_shadow_node_get_dx (node), 1.0f);
|
append_float_param (p, "dx", gsk_inset_shadow_node_get_dx (node), 1.0f);
|
||||||
append_float_param (p, "dy", gsk_inset_shadow_node_get_dy (node), 1.0f);
|
append_float_param (p, "dy", gsk_inset_shadow_node_get_dy (node), 1.0f);
|
||||||
append_rounded_rect_param (p, "outline", gsk_inset_shadow_node_get_outline (node));
|
append_rounded_rect_param (p, "outline", gsk_inset_shadow_node_get_outline (node));
|
||||||
|
|||||||
@@ -324,6 +324,7 @@ node_parser_tests = [
|
|||||||
'blend-unknown-mode.node',
|
'blend-unknown-mode.node',
|
||||||
'blend-unknown-mode.ref.node',
|
'blend-unknown-mode.ref.node',
|
||||||
'border.node',
|
'border.node',
|
||||||
|
'box-shadow.node',
|
||||||
'color.node',
|
'color.node',
|
||||||
'color2.node',
|
'color2.node',
|
||||||
'color3.node',
|
'color3.node',
|
||||||
|
|||||||
4
testsuite/gsk/nodeparser/box-shadow.node
Normal file
4
testsuite/gsk/nodeparser/box-shadow.node
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
outset-shadow {
|
||||||
|
blur: 2;
|
||||||
|
color: color(rec2100-pq 1 0.5 0 / 0.75);
|
||||||
|
}
|
||||||
5
testsuite/gsk/nodeparser/box-shadow.ref.node
Normal file
5
testsuite/gsk/nodeparser/box-shadow.ref.node
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
outset-shadow {
|
||||||
|
blur: 2;
|
||||||
|
color: color(rec2100-pq 1 0.5 0 / 0.75);
|
||||||
|
outline: 0 0 50 50;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user