Compare commits

...

14 Commits

Author SHA1 Message Date
Matthias Clasen 1681e2e671 css: Add more currentcolor style tests
These tests check various situations with inheritance and
currentColor. In particular the caret-color test was not
working correctly before we handled used values explicitly.
2024-05-21 17:54:24 -04:00
Matthias Clasen e98cac7849 css: Update style printing to show used values
This is what we want to see, most of the time.
2024-05-21 17:45:08 -04:00
Matthias Clasen 09541de0b8 gtk: Update all users to use used values
Update all widgets and rendering code to use the used values of
relevant css properties.
2024-05-21 17:45:08 -04:00
Matthias Clasen d55af81855 css: Update animated styles to resolve used values
We use the same method here as for static styles.
2024-05-21 17:45:08 -04:00
Matthias Clasen 354b3ee677 css: Implement used values for static styles
Change the style computation machinery to populate the used
values struct, and stop relying on NULL values in the values
structs to indicate currentColor occurrences. Instead, use
gtk_css_color_value_contains_current_color() when determining
style changes.
2024-05-21 17:45:08 -04:00
Matthias Clasen cc34938b03 css: Add some new style apis
Add separate apis for getting computed and used values, and
a method to resolve used values of a style.
2024-05-21 17:45:08 -04:00
Matthias Clasen 1ccb1b922e css: Introduce a struct for used values
The GtkCssUsedValues struct will hold the used values of those
css properties where that makes a difference. The new structs
are not used yet.
2024-05-21 17:45:08 -04:00
Matthias Clasen 563b47842a css: Make image values resolve used values
Separate out computed and used values for this type.
2024-05-21 17:45:08 -04:00
Matthias Clasen 9b47335d59 css: Add a way to resolve css images
This will be needed to separate out computed and used values
for css image values.
2024-05-21 17:45:08 -04:00
Matthias Clasen 653338fab8 css: Make shadow values resolve used values
Separate out computed and used values for this type.
2024-05-21 17:45:08 -04:00
Matthias Clasen 104d92efbc css: Make palette value resolve used values
Separate out computed and used values for this type.
2024-05-21 17:22:51 -04:00
Matthias Clasen 6db5a9e6a5 css: Make currentcolor compute to itself
This temporarily breaks currentcolor values. All uses of color
values will have to be fixed up to handle currentcolor at use time.
2024-05-21 17:22:51 -04:00
Matthias Clasen 37f0183bb3 css: Make color resolving more robust
Make gtk_css_color_value_resolve() handle situations where it can't
fully resolve a color expression. This will start to happen in the
next commits, when we make currentColor compute to itself.
2024-05-21 17:22:51 -04:00
Matthias Clasen 04681b13de css: Introduce gtk_css_value_contains_current_color
Track whether a value contains currentcolor (in which case
it needs to be resolved at use time).

This just adds the bit and the getter, it isn't used yet.
2024-05-21 17:22:51 -04:00
56 changed files with 1518 additions and 536 deletions
+2 -2
View File
@@ -928,10 +928,10 @@ _gtk_style_context_get_cursor_color (GtkStyleContext *context,
style = gtk_style_context_lookup_style (context);
if (primary_color)
*primary_color = *gtk_css_color_value_get_rgba (style->font->caret_color ? style->font->caret_color : style->core->color);
*primary_color = *gtk_css_color_value_get_rgba (style->used->caret_color);
if (secondary_color)
*secondary_color = *gtk_css_color_value_get_rgba (style->font->secondary_caret_color ? style->font->secondary_caret_color : style->core->color);
*secondary_color = *gtk_css_color_value_get_rgba (style->used->secondary_caret_color);
}
/**
+2 -2
View File
@@ -356,7 +356,7 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
node = gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget);
style = gtk_css_node_get_style (node);
fg_rgba = gtk_css_color_value_get_rgba (style->core->color);
fg_rgba = gtk_css_color_value_get_rgba (style->used->color);
}
else if (crenderer->state == GSK_PANGO_RENDERER_CURSOR && gtk_widget_has_focus (crenderer->widget))
{
@@ -365,7 +365,7 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
node = gtk_widget_get_css_node (crenderer->widget);
style = gtk_css_node_get_style (node);
fg_rgba = gtk_css_color_value_get_rgba (style->background->background_color);
fg_rgba = gtk_css_color_value_get_rgba (style->used->background_color);
}
else
fg_rgba = appearance->fg_rgba;
+10 -9
View File
@@ -1696,12 +1696,12 @@ follow_if_link (GtkAboutDialog *about,
if (uri && !g_ptr_array_find_with_equal_func (about->visited_links, uri, (GCompareFunc)strcmp, NULL))
{
GdkRGBA visited_link_color;
const GdkRGBA *visited_link_color;
GtkCssStyle *style;
style = gtk_css_node_get_style (about->visited_link_node);
visited_link_color = *gtk_css_color_value_get_rgba (style->core->color);
g_object_set (G_OBJECT (tag), "foreground-rgba", &visited_link_color, NULL);
visited_link_color = gtk_css_color_value_get_rgba (style->used->color);
g_object_set (G_OBJECT (tag), "foreground-rgba", visited_link_color, NULL);
g_ptr_array_add (about->visited_links, g_strdup (uri));
}
@@ -1836,17 +1836,18 @@ text_buffer_new (GtkAboutDialog *about,
char **p;
char *q0, *q1, *q2, *r1, *r2;
GtkTextBuffer *buffer;
GdkRGBA color;
GdkRGBA link_color;
GdkRGBA visited_link_color;
const GdkRGBA *color;
const GdkRGBA *link_color;
const GdkRGBA *visited_link_color;
GtkTextIter start_iter, end_iter;
GtkTextTag *tag;
GtkCssStyle *style;
style = gtk_css_node_get_style (about->link_node);
link_color = *gtk_css_color_value_get_rgba (style->core->color);
link_color = gtk_css_color_value_get_rgba (style->used->color);
style = gtk_css_node_get_style (about->visited_link_node);
visited_link_color = *gtk_css_color_value_get_rgba (style->core->color);
visited_link_color = gtk_css_color_value_get_rgba (style->used->color);
buffer = gtk_text_buffer_new (NULL);
@@ -1907,7 +1908,7 @@ text_buffer_new (GtkAboutDialog *about,
color = link_color;
tag = gtk_text_buffer_create_tag (buffer, NULL,
"foreground-rgba", &color,
"foreground-rgba", color,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
if (strcmp (link_type, "email") == 0)
+14
View File
@@ -1047,6 +1047,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssAnimatedStyle *result;
GtkCssStyle *style;
GPtrArray *animations = NULL;
GtkCssComputeContext context = { NULL, };
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
@@ -1092,6 +1093,12 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
gtk_css_animated_style_apply_animations (result);
context.provider = provider;
context.style = base_style;
context.parent_style = parent_style;
gtk_css_style_resolve_used_values ((GtkCssStyle *) result, &context);
return GTK_CSS_STYLE (result);
}
@@ -1106,6 +1113,7 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
GtkCssStyle *style;
GPtrArray *animations;
guint i;
GtkCssComputeContext context = { NULL, };
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
@@ -1165,6 +1173,12 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
gtk_css_animated_style_apply_animations (result);
context.provider = provider;
context.style = base_style;
context.parent_style = parent_style;
gtk_css_style_resolve_used_values ((GtkCssStyle *) result, &context);
return GTK_CSS_STYLE (result);
}
+3 -3
View File
@@ -161,9 +161,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = {
gtk_css_value_bg_size_print
};
static GtkCssValue auto_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, FALSE, NULL, NULL };
static GtkCssValue cover_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, FALSE, NULL, NULL };
static GtkCssValue contain_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, TRUE, NULL, NULL };
static GtkCssValue auto_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, 1, 0, 0, FALSE, FALSE, NULL, NULL };
static GtkCssValue cover_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, 1, 0, 0, TRUE, FALSE, NULL, NULL };
static GtkCssValue contain_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, 1, 0, 0, FALSE, TRUE, NULL, NULL };
GtkCssValue *
_gtk_css_bg_size_value_new (GtkCssValue *x,
+75 -72
View File
@@ -135,36 +135,7 @@ gtk_css_value_color_compute (GtkCssValue *value,
{
GtkCssValue *resolved;
/* The computed value of the currentColor keyword is the computed
* value of the color property. If the currentColor keyword is
* set on the color property itself, it is treated as color: inherit.
*/
if (property_id == GTK_CSS_PROPERTY_COLOR)
{
GtkCssValue *current;
if (context->parent_style)
current = context->parent_style->core->color;
else
current = NULL;
resolved = gtk_css_color_value_resolve (value,
context->provider,
current);
}
else if (value->type == COLOR_TYPE_LITERAL)
{
resolved = gtk_css_value_ref (value);
}
else
{
GtkCssValue *current = context->style->core->color;
resolved = gtk_css_color_value_resolve (value,
context->provider,
current);
}
resolved = gtk_css_color_value_resolve (value, context->provider, NULL);
if (resolved == NULL)
return gtk_css_value_color_get_fallback (property_id, context);
@@ -340,6 +311,16 @@ apply_mix (const GdkRGBA *in1,
}
}
/* This function can be called at compute time or at use time.
*
* When called at compute time, it needs to be given a provider
* (for looking up named colors), and current must be NULL,
* since currentcolor computed to itself.
*
* When called at use time, provider can be NULL (since named
* colors should have already been resolved at compute time),
* and current must be the value to use for currentcolor.
*/
static GtkCssValue *
gtk_css_color_value_do_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
@@ -354,11 +335,14 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
{
case COLOR_TYPE_LITERAL:
return gtk_css_value_ref (color);
case COLOR_TYPE_NAME:
{
GtkCssValue *named;
GSList cycle = { color, cycle_list };
g_assert (provider != NULL);
/* If color exists in cycle_list, we're currently resolving it.
* So we've detected a cycle. */
if (g_slist_find (cycle_list, color))
@@ -372,81 +356,97 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
if (value == NULL)
return NULL;
}
break;
case COLOR_TYPE_SHADE:
{
const GdkRGBA *c;
GtkCssValue *val;
GdkRGBA shade;
val = gtk_css_color_value_do_resolve (color->shade.color, provider, current, cycle_list);
if (val == NULL)
return NULL;
c = gtk_css_color_value_get_rgba (val);
apply_shade (c, &shade, color->shade.factor);
if (val->type == COLOR_TYPE_LITERAL)
{
const GdkRGBA *c = gtk_css_color_value_get_rgba (val);
GdkRGBA shade;
apply_shade (c, &shade, color->shade.factor);
value = gtk_css_color_value_new_literal (&shade);
}
else
{
value = gtk_css_color_value_new_shade (val, color->shade.factor);
}
value = gtk_css_color_value_new_literal (&shade);
gtk_css_value_unref (val);
}
break;
case COLOR_TYPE_ALPHA:
{
const GdkRGBA *c;
GtkCssValue *val;
GdkRGBA alpha;
val = gtk_css_color_value_do_resolve (color->alpha.color, provider, current, cycle_list);
if (val == NULL)
return NULL;
c = gtk_css_color_value_get_rgba (val);
apply_alpha (c, &alpha, color->alpha.factor);
if (val->type == COLOR_TYPE_LITERAL)
{
const GdkRGBA *c = gtk_css_color_value_get_rgba (val);
GdkRGBA alpha;
apply_alpha (c, &alpha, color->alpha.factor);
value = gtk_css_color_value_new_literal (&alpha);
}
else
{
value = gtk_css_color_value_new_alpha (val, color->alpha.factor);
}
value = gtk_css_color_value_new_literal (&alpha);
gtk_css_value_unref (val);
}
break;
case COLOR_TYPE_MIX:
{
const GdkRGBA *color1, *color2;
GtkCssValue *val1, *val2;
GdkRGBA res;
val1 = gtk_css_color_value_do_resolve (color->mix.color1, provider, current, cycle_list);
if (val1 == NULL)
return NULL;
color1 = gtk_css_color_value_get_rgba (val1);
val2 = gtk_css_color_value_do_resolve (color->mix.color2, provider, current, cycle_list);
if (val2 == NULL)
if (val1 == NULL || val2 == NULL)
return NULL;
color2 = gtk_css_color_value_get_rgba (val2);
apply_mix (color1, color2, &res, color->mix.factor);
if (val1->type == COLOR_TYPE_LITERAL && val2->type == COLOR_TYPE_LITERAL)
{
const GdkRGBA *color1 = gtk_css_color_value_get_rgba (val1);
const GdkRGBA *color2 = gtk_css_color_value_get_rgba (val2);
GdkRGBA res;
apply_mix (color1, color2, &res, color->mix.factor);
value = gtk_css_color_value_new_literal (&res);
}
else
{
value = gtk_css_color_value_new_mix (val1, val2, color->mix.factor);
}
value = gtk_css_color_value_new_literal (&res);
gtk_css_value_unref (val1);
gtk_css_value_unref (val2);
}
break;
case COLOR_TYPE_CURRENT_COLOR:
if (current == NULL)
{
current = _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR));
g_assert (current->class == &GTK_CSS_VALUE_COLOR);
g_assert (current->type == COLOR_TYPE_LITERAL);
}
if (current)
value = gtk_css_value_ref (current);
else
value = gtk_css_value_ref (color);
break;
default:
value = NULL;
g_assert_not_reached ();
}
@@ -474,11 +474,12 @@ gtk_css_color_value_resolve (GtkCssValue *color,
return gtk_css_color_value_do_resolve (color, provider, current, NULL);
}
static GtkCssValue transparent_black_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
static GtkCssValue transparent_black_singleton = { &GTK_CSS_VALUE_COLOR, 1, 1, 0, 0, COLOR_TYPE_LITERAL, NULL,
.rgba = {0, 0, 0, 0} };
static GtkCssValue white_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
static GtkCssValue white_singleton = { &GTK_CSS_VALUE_COLOR, 1, 1, 0, 0, COLOR_TYPE_LITERAL, NULL,
.rgba = {1, 1, 1, 1} };
static GtkCssValue current_color_singleton = { &GTK_CSS_VALUE_COLOR, 1, 0, 0, 1, COLOR_TYPE_CURRENT_COLOR, NULL, };
GtkCssValue *
gtk_css_color_value_new_transparent (void)
@@ -492,6 +493,12 @@ gtk_css_color_value_new_white (void)
return gtk_css_value_ref (&white_singleton);
}
GtkCssValue *
gtk_css_color_value_new_current_color (void)
{
return gtk_css_value_ref (&current_color_singleton);
}
GtkCssValue *
gtk_css_color_value_new_literal (const GdkRGBA *color)
{
@@ -546,6 +553,7 @@ gtk_css_color_value_new_shade (GtkCssValue *color,
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_SHADE;
value->contains_current_color = color->contains_current_color;
value->shade.color = gtk_css_value_ref (color);
value->shade.factor = factor;
@@ -571,6 +579,7 @@ gtk_css_color_value_new_alpha (GtkCssValue *color,
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_ALPHA;
value->contains_current_color = color->contains_current_color;
value->alpha.color = gtk_css_value_ref (color);
value->alpha.factor = factor;
@@ -600,6 +609,8 @@ gtk_css_color_value_new_mix (GtkCssValue *color1,
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_MIX;
value->contains_current_color = color1->contains_current_color ||
color2->contains_current_color;
value->mix.color1 = gtk_css_value_ref (color1);
value->mix.color2 = gtk_css_value_ref (color2);
value->mix.factor = factor;
@@ -607,14 +618,6 @@ gtk_css_color_value_new_mix (GtkCssValue *color1,
return value;
}
GtkCssValue *
gtk_css_color_value_new_current_color (void)
{
static GtkCssValue current_color = { &GTK_CSS_VALUE_COLOR, 1, FALSE, FALSE, COLOR_TYPE_CURRENT_COLOR, NULL, };
return gtk_css_value_ref (&current_color);
}
typedef struct
{
GtkCssValue *color;
+8 -8
View File
@@ -108,14 +108,14 @@ static const GtkCssValueClass GTK_CSS_VALUE_CORNER = {
};
static GtkCssValue corner_singletons[] = {
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, 1, 0, 0, NULL, NULL },
};
static inline void
+87 -87
View File
@@ -85,16 +85,16 @@ static const GtkCssValueClass GTK_CSS_VALUE_BORDER_STYLE = {
};
static GtkCssValue border_style_values[] = {
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_NONE, "none" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_INSET, "inset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_OUTSET, "outset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_HIDDEN, "hidden" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOTTED, "dotted" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DASHED, "dashed" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_GROOVE, "groove" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_RIDGE, "ridge" }
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_NONE, "none" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_INSET, "inset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_OUTSET, "outset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_HIDDEN, "hidden" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_DOTTED, "dotted" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_DASHED, "dashed" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_GROOVE, "groove" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, 1, 0, 0, GTK_BORDER_STYLE_RIDGE, "ridge" }
};
GtkCssValue *
@@ -143,22 +143,22 @@ static const GtkCssValueClass GTK_CSS_VALUE_BLEND_MODE = {
};
static GtkCssValue blend_mode_values[] = {
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DEFAULT, "normal" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_MULTIPLY, "multiply" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SCREEN, "screen" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_OVERLAY, "overlay" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DARKEN, "darken" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LIGHTEN, "lighten" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DIFFERENCE, "difference" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR, "color" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HUE, "hue" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SATURATION, "saturation" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_DEFAULT, "normal" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_MULTIPLY, "multiply" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_SCREEN, "screen" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_OVERLAY, "overlay" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_DARKEN, "darken" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_LIGHTEN, "lighten" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_DIFFERENCE, "difference" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_COLOR, "color" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_HUE, "hue" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_SATURATION, "saturation" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, 1, 0, 0, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
};
GtkCssValue *
@@ -296,15 +296,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
};
static GtkCssValue font_size_values[] = {
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, 0, 0, 0, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
};
GtkCssValue *
@@ -353,9 +353,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
};
static GtkCssValue font_style_values[] = {
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_OBLIQUE, "oblique" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_ITALIC, "italic" }
{ &GTK_CSS_VALUE_FONT_STYLE, 1, 1, 0, 0, PANGO_STYLE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, 1, 0, 0, PANGO_STYLE_OBLIQUE, "oblique" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, 1, 0, 0, PANGO_STYLE_ITALIC, "italic" }
};
GtkCssValue *
@@ -450,8 +450,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = {
};
static GtkCssValue font_weight_values[] = {
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, BOLDER, "bolder" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, LIGHTER, "lighter" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, 0, 0, 0, BOLDER, "bolder" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, 0, 0, 0, LIGHTER, "lighter" },
};
GtkCssValue *
@@ -500,15 +500,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = {
};
static GtkCssValue font_stretch_values[] = {
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_CONDENSED, "condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXPANDED, "expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_CONDENSED, "condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_EXPANDED, "expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, 1, 0, 0, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
};
GtkCssValue *
@@ -557,9 +557,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_STYLE = {
};
static GtkCssValue text_decoration_style_values[] = {
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, 1, 0, 0, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, 1, 0, 0, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, 1, 0, 0, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
};
GtkCssValue *
@@ -608,9 +608,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
};
static GtkCssValue area_values[] = {
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_BORDER_BOX, "border-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
{ &GTK_CSS_VALUE_AREA, 1, 1, 0, 0, GTK_CSS_AREA_BORDER_BOX, "border-box" },
{ &GTK_CSS_VALUE_AREA, 1, 1, 0, 0, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
{ &GTK_CSS_VALUE_AREA, 1, 1, 0, 0, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
};
GtkCssValue *
@@ -665,10 +665,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_DIRECTION = {
};
static GtkCssValue direction_values[] = {
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
{ &GTK_CSS_VALUE_DIRECTION, 1, 1, 0, 0, GTK_CSS_DIRECTION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_DIRECTION, 1, 1, 0, 0, GTK_CSS_DIRECTION_REVERSE, "reverse" },
{ &GTK_CSS_VALUE_DIRECTION, 1, 1, 0, 0, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
{ &GTK_CSS_VALUE_DIRECTION, 1, 1, 0, 0, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
};
GtkCssValue *
@@ -726,8 +726,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_PLAY_STATE = {
};
static GtkCssValue play_state_values[] = {
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_RUNNING, "running" },
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
{ &GTK_CSS_VALUE_PLAY_STATE, 1, 1, 0, 0, GTK_CSS_PLAY_STATE_RUNNING, "running" },
{ &GTK_CSS_VALUE_PLAY_STATE, 1, 1, 0, 0, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
};
GtkCssValue *
@@ -782,10 +782,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILL_MODE = {
};
static GtkCssValue fill_mode_values[] = {
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_NONE, "none" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_FORWARDS, "forwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BACKWARDS, "backwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BOTH, "both" }
{ &GTK_CSS_VALUE_FILL_MODE, 1, 1, 0, 0, GTK_CSS_FILL_NONE, "none" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, 1, 0, 0, GTK_CSS_FILL_FORWARDS, "forwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, 1, 0, 0, GTK_CSS_FILL_BACKWARDS, "backwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, 1, 0, 0, GTK_CSS_FILL_BOTH, "both" }
};
GtkCssValue *
@@ -840,9 +840,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = {
};
static GtkCssValue icon_style_values[] = {
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
{ &GTK_CSS_VALUE_ICON_STYLE, 1, 1, 0, 0, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, 1, 0, 0, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, 1, 0, 0, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
};
GtkCssValue *
@@ -897,9 +897,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_KERNING = {
};
static GtkCssValue font_kerning_values[] = {
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NONE, "none" }
{ &GTK_CSS_VALUE_FONT_KERNING, 1, 1, 0, 0, GTK_CSS_FONT_KERNING_AUTO, "auto" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, 1, 0, 0, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, 1, 0, 0, GTK_CSS_FONT_KERNING_NONE, "none" }
};
GtkCssValue *
@@ -954,9 +954,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_POSITION = {
};
static GtkCssValue font_variant_position_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
};
GtkCssValue *
@@ -1011,13 +1011,13 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_CAPS = {
};
static GtkCssValue font_variant_caps_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
};
GtkCssValue *
@@ -1072,8 +1072,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE = {
};
static GtkCssValue font_variant_alternate_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, 1, 0, 0, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
};
GtkCssValue *
@@ -1581,10 +1581,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_TRANSFORM = {
};
static GtkCssValue text_transform_values[] = {
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, 1, 0, 0, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, 1, 0, 0, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, 1, 0, 0, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, 1, 0, 0, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
};
GtkCssValue *
+1 -1
View File
@@ -717,7 +717,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILTER = {
gtk_css_value_filter_print
};
static GtkCssValue filter_none_singleton = { &GTK_CSS_VALUE_FILTER, 1, TRUE, FALSE, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue filter_none_singleton = { &GTK_CSS_VALUE_FILTER, 1, 1, 0, 0, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue *
gtk_css_filter_value_alloc (guint n_filters)
+38 -6
View File
@@ -120,6 +120,19 @@ gtk_css_image_real_is_computed (GtkCssImage *image)
return FALSE;
}
static gboolean
gtk_css_image_real_contains_current_color (GtkCssImage *image)
{
return FALSE;
}
static GtkCssImage *
gtk_css_image_real_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
return g_object_ref (image);
}
static void
_gtk_css_image_class_init (GtkCssImageClass *klass)
{
@@ -133,6 +146,8 @@ _gtk_css_image_class_init (GtkCssImageClass *klass)
klass->is_dynamic = gtk_css_image_real_is_dynamic;
klass->get_dynamic_image = gtk_css_image_real_get_dynamic_image;
klass->is_computed = gtk_css_image_real_is_computed;
klass->contains_current_color = gtk_css_image_real_contains_current_color;
klass->resolve = gtk_css_image_real_resolve;
}
static void
@@ -239,11 +254,11 @@ _gtk_css_image_equal (GtkCssImage *image1,
return klass->equal (image1, image2);
}
void
_gtk_css_image_draw (GtkCssImage *image,
cairo_t *cr,
double width,
double height)
static void
gtk_css_image_draw (GtkCssImage *image,
cairo_t *cr,
double width,
double height)
{
GtkSnapshot *snapshot;
GskRenderNode *node;
@@ -497,7 +512,7 @@ _gtk_css_image_get_surface (GtkCssImage *image,
surface_height);
cr = cairo_create (result);
_gtk_css_image_draw (image, cr, surface_width, surface_height);
gtk_css_image_draw (image, cr, surface_width, surface_height);
cairo_destroy (cr);
return result;
@@ -588,3 +603,20 @@ gtk_css_image_is_computed (GtkCssImage *image)
return klass->is_computed (image);
}
gboolean
gtk_css_image_contains_current_color (GtkCssImage *image)
{
GtkCssImageClass *klass = GTK_CSS_IMAGE_GET_CLASS (image);
return klass->contains_current_color (image);
}
GtkCssImage *
gtk_css_image_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
GtkCssImageClass *klass = GTK_CSS_IMAGE_GET_CLASS (image);
return klass->resolve (image, current_color);
}
+50 -1
View File
@@ -327,7 +327,7 @@ gtk_css_image_conic_compute (GtkCssImage *image,
copy->rotation = gtk_css_value_compute (self->rotation, property_id, context);
copy->n_stops = self->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * copy->n_stops);
copy->color_stops = g_new (GtkCssImageConicColorStop, self->n_stops);
for (i = 0; i < self->n_stops; i++)
{
const GtkCssImageConicColorStop *stop = &self->color_stops[i];
@@ -503,6 +503,53 @@ gtk_css_image_conic_is_computed (GtkCssImage *image)
return computed;
}
static gboolean
gtk_css_image_conic_contains_current_color (GtkCssImage *image)
{
GtkCssImageConic *self = GTK_CSS_IMAGE_CONIC (image);
for (guint i = 0; i < self->n_stops; i ++)
{
const GtkCssImageConicColorStop *stop = &self->color_stops[i];
if (gtk_css_value_contains_current_color (stop->color))
return TRUE;
}
return FALSE;
}
static GtkCssImage *
gtk_css_image_conic_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
GtkCssImageConic *self = GTK_CSS_IMAGE_CONIC (image);
GtkCssImageConic *resolved;
if (!gtk_css_image_conic_contains_current_color (image))
return g_object_ref (image);
resolved = g_object_new (GTK_TYPE_CSS_IMAGE_CONIC, NULL);
resolved->center = gtk_css_value_ref (self->center);
resolved->rotation = gtk_css_value_ref (self->rotation);
resolved->n_stops = self->n_stops;
resolved->color_stops = g_new (GtkCssImageConicColorStop, self->n_stops);
for (guint i = 0; i < self->n_stops; i++)
{
if (self->color_stops[i].offset)
resolved->color_stops[i].offset = gtk_css_value_ref (self->color_stops[i].offset);
else
resolved->color_stops[i].offset = NULL;
resolved->color_stops[i].color = gtk_css_color_value_resolve (self->color_stops[i].color, NULL, current_color);
}
return GTK_CSS_IMAGE (resolved);
}
static void
gtk_css_image_conic_class_init (GtkCssImageConicClass *klass)
{
@@ -516,6 +563,8 @@ gtk_css_image_conic_class_init (GtkCssImageConicClass *klass)
image_class->equal = gtk_css_image_conic_equal;
image_class->transition = gtk_css_image_conic_transition;
image_class->is_computed = gtk_css_image_conic_is_computed;
image_class->contains_current_color = gtk_css_image_conic_contains_current_color;
image_class->resolve = gtk_css_image_conic_resolve;
object_class->dispose = gtk_css_image_conic_dispose;
}
+69 -1
View File
@@ -72,7 +72,10 @@ gtk_css_image_fallback_snapshot (GtkCssImage *image,
{
if (fallback->color)
{
const GdkRGBA *color = gtk_css_color_value_get_rgba (fallback->color);
const GdkRGBA *color;
color = gtk_css_color_value_get_rgba (fallback->color);
if (!gdk_rgba_is_clear (color))
gtk_snapshot_append_color (snapshot, color,
&GRAPHENE_RECT_INIT (0, 0, width, height));
@@ -301,6 +304,69 @@ gtk_css_image_fallback_is_computed (GtkCssImage *image)
return TRUE;
}
static gboolean
gtk_css_image_fallback_contains_current_color (GtkCssImage *image)
{
GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image);
if (fallback->used < 0)
{
guint i;
if (fallback->color && !fallback->images)
return gtk_css_value_contains_current_color (fallback->color);
for (i = 0; i < fallback->n_images; i++)
{
if (gtk_css_image_contains_current_color (fallback->images[i]))
return TRUE;
}
}
return FALSE;
}
static GtkCssImage *
gtk_css_image_fallback_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image);
GtkCssImageFallback *resolved;
int i;
if (fallback->used < 0)
{
GtkCssValue *resolved_color = NULL;
if (fallback->color)
resolved_color = gtk_css_color_value_resolve (fallback->color, NULL, current_color);
/* image($color) that didn't change */
if (resolved_color && !fallback->images && resolved_color == fallback->color)
return g_object_ref (image);
resolved = g_object_new (_gtk_css_image_fallback_get_type (), NULL);
resolved->n_images = fallback->n_images;
resolved->images = g_new (GtkCssImage *, fallback->n_images);
for (i = 0; i < fallback->n_images; i++)
{
resolved->images[i] = g_object_ref (fallback->images[i]);
if (gtk_css_image_is_invalid (resolved->images[i]))
continue;
if (resolved->used < 0)
resolved->used = i;
}
resolved->color = resolved_color;
return GTK_CSS_IMAGE (resolved);
}
else
return GTK_CSS_IMAGE (g_object_ref (image));
}
static void
_gtk_css_image_fallback_class_init (GtkCssImageFallbackClass *klass)
{
@@ -316,6 +382,8 @@ _gtk_css_image_fallback_class_init (GtkCssImageFallbackClass *klass)
image_class->print = gtk_css_image_fallback_print;
image_class->equal = gtk_css_image_fallback_equal;
image_class->is_computed = gtk_css_image_fallback_is_computed;
image_class->contains_current_color = gtk_css_image_fallback_contains_current_color;
image_class->resolve = gtk_css_image_fallback_resolve;
object_class->dispose = gtk_css_image_fallback_dispose;
}
+64 -3
View File
@@ -29,6 +29,8 @@
#include "gtkstyleproviderprivate.h"
#include "gtksymbolicpaintable.h"
#include "gtkiconthemeprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcsspalettevalueprivate.h"
G_DEFINE_TYPE (GtkCssImageIconTheme, _gtk_css_image_icon_theme, GTK_TYPE_CSS_IMAGE)
@@ -50,6 +52,7 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
double icon_width, icon_height;
int size;
double x, y;
GdkRGBA colors[4];
size = floor (MIN (width, height));
if (size <= 0)
@@ -89,11 +92,15 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
}
for (guint i = 0; i < 4; i++)
colors[i] = *gtk_css_color_value_get_rgba (icon_theme->colors[i]);
gtk_symbolic_paintable_snapshot_symbolic (GTK_SYMBOLIC_PAINTABLE (icon),
snapshot,
icon_width,
icon_height,
icon_theme->colors,
colors,
G_N_ELEMENTS (icon_theme->colors));
if (x != 0 || y != 0)
gtk_snapshot_restore (snapshot);
@@ -146,6 +153,7 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
GtkCssImageIconTheme *copy;
GtkSettings *settings;
GdkDisplay *display;
const char *names[4] = { NULL, "success", "warning", "error" };
copy = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
copy->name = g_strdup (icon_theme->name);
@@ -154,7 +162,18 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
copy->icon_theme = gtk_icon_theme_get_for_display (display);
copy->serial = gtk_icon_theme_get_serial (copy->icon_theme);
copy->scale = gtk_style_provider_get_scale (context->provider);
gtk_css_style_lookup_symbolic_colors (context->style, copy->colors);
for (guint i = 0; i < 4; i++)
{
GtkCssValue *color = NULL;
if (names[i])
color = gtk_css_palette_value_get_color (context->style->core->icon_palette, names[i]);
if (color)
copy->colors[i] = gtk_css_value_ref (color);
else
copy->colors[i] = gtk_css_value_ref (context->style->core->color);
}
return GTK_CSS_IMAGE (copy);
}
@@ -180,10 +199,51 @@ gtk_css_image_icon_theme_dispose (GObject *object)
icon_theme->name = NULL;
g_clear_object (&icon_theme->cached_icon);
g_clear_pointer (&icon_theme->colors[0], gtk_css_value_unref);
g_clear_pointer (&icon_theme->colors[1], gtk_css_value_unref);
g_clear_pointer (&icon_theme->colors[2], gtk_css_value_unref);
g_clear_pointer (&icon_theme->colors[3], gtk_css_value_unref);
G_OBJECT_CLASS (_gtk_css_image_icon_theme_parent_class)->dispose (object);
}
static gboolean
gtk_css_image_icon_theme_contains_current_color (GtkCssImage *image)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
for (guint i = 0; i < 4; i++)
{
if (!icon_theme->colors[i] ||
gtk_css_value_contains_current_color (icon_theme->colors[i]))
return TRUE;
}
return FALSE;
}
static GtkCssImage *
gtk_css_image_icon_theme_resolve (GtkCssImage *image,
GtkCssValue *current)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GtkCssImageIconTheme *copy;
if (!gtk_css_image_icon_theme_contains_current_color (image))
return g_object_ref (image);
copy = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
copy->name = g_strdup (icon_theme->name);
copy->icon_theme = icon_theme->icon_theme;
copy->serial = icon_theme->serial;
copy->scale = icon_theme->scale;
for (guint i = 0; i < 4; i++)
copy->colors[i] = gtk_css_color_value_resolve (icon_theme->colors[i], NULL, current);
return GTK_CSS_IMAGE (copy);
}
static void
_gtk_css_image_icon_theme_class_init (GtkCssImageIconThemeClass *klass)
{
@@ -196,7 +256,8 @@ _gtk_css_image_icon_theme_class_init (GtkCssImageIconThemeClass *klass)
image_class->print = gtk_css_image_icon_theme_print;
image_class->compute = gtk_css_image_icon_theme_compute;
image_class->equal = gtk_css_image_icon_theme_equal;
image_class->contains_current_color = gtk_css_image_icon_theme_contains_current_color;
image_class->resolve = gtk_css_image_icon_theme_resolve;
object_class->dispose = gtk_css_image_icon_theme_dispose;
}
+1 -1
View File
@@ -39,7 +39,7 @@ struct _GtkCssImageIconTheme
GtkCssImage parent;
GtkIconTheme *icon_theme;
GdkRGBA colors[4];
GtkCssValue *colors[4];
int serial;
int scale;
char *name;
+65 -8
View File
@@ -134,10 +134,10 @@ gtk_css_image_linear_compute_start_point (double angle_in_degrees,
}
static void
gtk_css_image_linear_snapshot (GtkCssImage *image,
GtkSnapshot *snapshot,
double width,
double height)
gtk_css_image_linear_snapshot (GtkCssImage *image,
GtkSnapshot *snapshot,
double width,
double height)
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
GskColorStop *stops;
@@ -188,12 +188,16 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
if (start == end)
{
/* repeating gradients with all color stops sharing the same offset
* get the color of the last color stop */
/* Repeating gradients with all color stops sharing the same offset
* get the color of the last color stop
*/
const GtkCssImageLinearColorStop *stop = &linear->color_stops[linear->n_stops - 1];
const GdkRGBA *color;
color = gtk_css_color_value_get_rgba (stop->color);
gtk_snapshot_append_color (snapshot,
gtk_css_color_value_get_rgba (stop->color),
color,
&GRAPHENE_RECT_INIT (0, 0, width, height));
return;
}
@@ -236,8 +240,9 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
offset += step;
stops[last].offset = (offset - start) / (end - start);
stops[last].color = *gtk_css_color_value_get_rgba (stop->color);
stops[last].offset = (offset - start) / (end - start);
}
offset = pos;
@@ -689,6 +694,56 @@ gtk_css_image_linear_is_computed (GtkCssImage *image)
return computed;
}
static gboolean
gtk_css_image_linear_contains_current_color (GtkCssImage *image)
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
for (guint i = 0; i < linear->n_stops; i ++)
{
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
if (gtk_css_value_contains_current_color (stop->color))
return TRUE;
}
return FALSE;
}
static GtkCssImage *
gtk_css_image_linear_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
GtkCssImageLinear *copy;
guint i;
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating;
copy->side = linear->side;
if (linear->angle)
copy->angle = gtk_css_value_ref (linear->angle);
copy->n_stops = linear->n_stops;
copy->color_stops = g_new (GtkCssImageLinearColorStop, copy->n_stops);
for (i = 0; i < linear->n_stops; i++)
{
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
GtkCssImageLinearColorStop *scopy = &copy->color_stops[i];
scopy->color = gtk_css_color_value_resolve (stop->color, NULL, current_color);
if (stop->offset)
scopy->offset = gtk_css_value_ref (stop->offset);
else
scopy->offset = NULL;
}
return GTK_CSS_IMAGE (copy);
}
static void
_gtk_css_image_linear_class_init (GtkCssImageLinearClass *klass)
{
@@ -702,6 +757,8 @@ _gtk_css_image_linear_class_init (GtkCssImageLinearClass *klass)
image_class->equal = gtk_css_image_linear_equal;
image_class->transition = gtk_css_image_linear_transition;
image_class->is_computed = gtk_css_image_linear_is_computed;
image_class->contains_current_color = gtk_css_image_linear_contains_current_color;
image_class->resolve = gtk_css_image_linear_resolve;
object_class->dispose = gtk_css_image_linear_dispose;
}
+7 -4
View File
@@ -91,6 +91,9 @@ struct _GtkCssImageClass
void (* print) (GtkCssImage *image,
GString *string);
gboolean (* is_computed) (GtkCssImage *image);
gboolean (* contains_current_color) (GtkCssImage *image);
GtkCssImage *( * resolve) (GtkCssImage *image,
GtkCssValue *current_color);
};
GType _gtk_css_image_get_type (void) G_GNUC_CONST;
@@ -112,10 +115,6 @@ GtkCssImage * _gtk_css_image_transition (GtkCssImage *
guint property_id,
double progress);
void _gtk_css_image_draw (GtkCssImage *image,
cairo_t *cr,
double width,
double height);
void gtk_css_image_snapshot (GtkCssImage *image,
GtkSnapshot *snapshot,
double width,
@@ -142,6 +141,10 @@ cairo_surface_t *
int surface_height);
gboolean gtk_css_image_is_computed (GtkCssImage *image) G_GNUC_PURE;
gboolean gtk_css_image_contains_current_color (GtkCssImage *image) G_GNUC_PURE;
GtkCssImage * gtk_css_image_resolve (GtkCssImage *image,
GtkCssValue *current_color);
G_END_DECLS
+58
View File
@@ -724,6 +724,62 @@ gtk_css_image_radial_is_computed (GtkCssImage *image)
return computed;
}
static gboolean
gtk_css_image_radial_contains_current_color (GtkCssImage *image)
{
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
for (guint i = 0; i < radial->n_stops; i ++)
{
const GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
if (gtk_css_value_contains_current_color (stop->color))
return TRUE;
}
return FALSE;
}
static GtkCssImage *
gtk_css_image_radial_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
GtkCssImageRadial *copy;
copy = g_object_new (GTK_TYPE_CSS_IMAGE_RADIAL, NULL);
copy->repeating = radial->repeating;
copy->circle = radial->circle;
copy->size = radial->size;
copy->position = gtk_css_value_ref (radial->position);
if (radial->sizes[0])
copy->sizes[0] = gtk_css_value_ref (radial->sizes[0]);
if (radial->sizes[1])
copy->sizes[1] = gtk_css_value_ref (radial->sizes[1]);
copy->n_stops = radial->n_stops;
copy->color_stops = g_new (GtkCssImageRadialColorStop, copy->n_stops);
for (guint i = 0; i < radial->n_stops; i++)
{
const GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
GtkCssImageRadialColorStop *scopy = &copy->color_stops[i];
scopy->color = gtk_css_color_value_resolve (stop->color, NULL, current_color);
if (stop->offset)
scopy->offset = gtk_css_value_ref (stop->offset);
else
scopy->offset = NULL;
}
return GTK_CSS_IMAGE (copy);
}
static void
_gtk_css_image_radial_class_init (GtkCssImageRadialClass *klass)
{
@@ -737,6 +793,8 @@ _gtk_css_image_radial_class_init (GtkCssImageRadialClass *klass)
image_class->transition = gtk_css_image_radial_transition;
image_class->equal = gtk_css_image_radial_equal;
image_class->is_computed = gtk_css_image_radial_is_computed;
image_class->contains_current_color = gtk_css_image_radial_contains_current_color;
image_class->resolve = gtk_css_image_radial_resolve;
object_class->dispose = gtk_css_image_radial_dispose;
}
+67 -47
View File
@@ -55,43 +55,13 @@ gtk_css_image_recolor_dispose (GObject *object)
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (object);
g_clear_pointer (&recolor->palette, gtk_css_value_unref);
g_clear_pointer (&recolor->color, gtk_css_value_unref);
g_clear_object (&recolor->file);
g_clear_object (&recolor->texture);
G_OBJECT_CLASS (_gtk_css_image_recolor_parent_class)->dispose (object);
}
static void
lookup_symbolic_colors (GtkCssStyle *style,
GtkCssValue *palette,
GdkRGBA *color_out,
GdkRGBA *success_out,
GdkRGBA *warning_out,
GdkRGBA *error_out)
{
const GdkRGBA *lookup;
*color_out = *gtk_css_color_value_get_rgba (style->core->color);
lookup = gtk_css_palette_value_get_color (palette, "success");
if (lookup)
*success_out = *lookup;
else
*success_out = *color_out;
lookup = gtk_css_palette_value_get_color (palette, "warning");
if (lookup)
*warning_out = *lookup;
else
*warning_out = *color_out;
lookup = gtk_css_palette_value_get_color (palette, "error");
if (lookup)
*error_out = *lookup;
else
*error_out = *color_out;
}
static void
gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
GError **error)
@@ -127,21 +97,22 @@ gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
}
static GtkCssImage *
gtk_css_image_recolor_load (GtkCssImageRecolor *recolor,
GtkCssStyle *style,
GtkCssValue *palette,
int scale,
GError **gerror)
gtk_css_image_recolor_load (GtkCssImageRecolor *recolor,
GtkCssComputeContext *context,
GtkCssValue *palette,
int scale,
GError **gerror)
{
GError *local_error = NULL;
GtkCssImageRecolor *image;
image = g_object_new (GTK_TYPE_CSS_IMAGE_RECOLOR, NULL);
lookup_symbolic_colors (style, palette, &image->color, &image->success, &image->warning, &image->error);
gtk_css_image_recolor_load_texture (recolor, &local_error);
image->file = g_object_ref (recolor->file);
image->palette = gtk_css_value_ref (palette);
image->color = gtk_css_value_ref (context->style->core->color);
gtk_css_image_recolor_load_texture (recolor, &local_error);
if (recolor->texture)
image->texture = g_object_ref (recolor->texture);
@@ -172,16 +143,34 @@ gtk_css_image_recolor_snapshot (GtkCssImage *image,
double height)
{
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (image);
const GdkRGBA *fg = &recolor->color;
const GdkRGBA *sc = &recolor->success;
const GdkRGBA *wc = &recolor->warning;
const GdkRGBA *ec = &recolor->error;
const GdkRGBA *fg, *sc, *wc, *ec;
const GtkCssValue *color;
graphene_matrix_t matrix;
graphene_vec4_t offset;
if (recolor->texture == NULL)
return;
fg = gtk_css_color_value_get_rgba (recolor->color);
color = gtk_css_palette_value_get_color (recolor->palette, "success");
if (color)
sc = gtk_css_color_value_get_rgba (color);
else
sc = fg;
color = gtk_css_palette_value_get_color (recolor->palette, "warning");
if (color)
wc = gtk_css_color_value_get_rgba (color);
else
wc = fg;
color = gtk_css_palette_value_get_color (recolor->palette, "error");
if (color)
ec = gtk_css_color_value_get_rgba (color);
else
ec = fg;
graphene_matrix_init_from_float (&matrix,
(float[16]) {
sc->red - fg->red, sc->green - fg->green, sc->blue - fg->blue, 0,
@@ -218,7 +207,7 @@ gtk_css_image_recolor_compute (GtkCssImage *image,
else
palette = gtk_css_value_ref (context->style->core->icon_palette);
img = gtk_css_image_recolor_load (recolor, context->style, palette, scale, &error);
img = gtk_css_image_recolor_load (recolor, context, palette, scale, &error);
if (error)
{
@@ -267,7 +256,7 @@ gtk_css_image_recolor_parse_arg (GtkCssParser *parser,
static gboolean
gtk_css_image_recolor_parse (GtkCssImage *image,
GtkCssParser *parser)
GtkCssParser *parser)
{
if (!gtk_css_parser_has_function (parser, "-gtk-recolor"))
{
@@ -309,8 +298,37 @@ gtk_css_image_recolor_is_computed (GtkCssImage *image)
{
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (image);
return recolor->texture &&
(!recolor->palette || gtk_css_value_is_computed (recolor->palette));
return recolor->texture && gtk_css_value_is_computed (recolor->palette);
}
static gboolean
gtk_css_image_recolor_contains_current_color (GtkCssImage *image)
{
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (image);
if (!recolor->palette || !recolor->color)
return TRUE;
return gtk_css_value_contains_current_color (recolor->palette) ||
gtk_css_value_contains_current_color (recolor->color);
}
static GtkCssImage *
gtk_css_image_recolor_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (image);
GtkCssImageRecolor *img;
img = g_object_new (GTK_TYPE_CSS_IMAGE_RECOLOR, NULL);
img->palette = gtk_css_palette_value_resolve (recolor->palette, current_color);
img->color = gtk_css_color_value_resolve (recolor->color, NULL, current_color);
img->file = g_object_ref (recolor->file);
if (recolor->texture)
img->texture = g_object_ref (recolor->texture);
return GTK_CSS_IMAGE (img);
}
static void
@@ -326,6 +344,8 @@ _gtk_css_image_recolor_class_init (GtkCssImageRecolorClass *klass)
image_class->parse = gtk_css_image_recolor_parse;
image_class->print = gtk_css_image_recolor_print;
image_class->is_computed = gtk_css_image_recolor_is_computed;
image_class->contains_current_color = gtk_css_image_recolor_contains_current_color;
image_class->resolve = gtk_css_image_recolor_resolve;
object_class->dispose = gtk_css_image_recolor_dispose;
}
+1 -4
View File
@@ -39,12 +39,9 @@ struct _GtkCssImageRecolor
GtkCssImage parent;
GFile *file;
GtkCssValue *color;
GtkCssValue *palette;
GdkTexture *texture;
GdkRGBA color;
GdkRGBA success;
GdkRGBA warning;
GdkRGBA error;
};
struct _GtkCssImageRecolorClass
+38
View File
@@ -208,6 +208,42 @@ gtk_css_image_scaled_is_computed (GtkCssImage *image)
gtk_css_image_is_computed (self->images[0]);
}
static gboolean
gtk_css_image_scaled_contains_current_color (GtkCssImage *image)
{
GtkCssImageScaled *self = GTK_CSS_IMAGE_SCALED (image);
for (guint i = 0; i < self->n_images; i++)
{
if (gtk_css_image_contains_current_color (self->images[i]))
return TRUE;
}
return FALSE;
}
static GtkCssImage *
gtk_css_image_scaled_resolve (GtkCssImage *image,
GtkCssValue *current_color)
{
GtkCssImageScaled *self = GTK_CSS_IMAGE_SCALED (image);
GtkCssImageScaled *res;
res = g_object_new (GTK_TYPE_CSS_IMAGE_SCALED, NULL);
res->n_images = self->n_images;
res->images = g_new (GtkCssImage *, self->n_images);
res->scales = g_new (int, self->n_images);
for (guint i = 0; i < self->n_images; i++)
{
res->images[i] = gtk_css_image_resolve (self->images[i], current_color);
res->scales[i] = self->scales[i];
}
return GTK_CSS_IMAGE (res);
}
static void
_gtk_css_image_scaled_class_init (GtkCssImageScaledClass *klass)
{
@@ -222,6 +258,8 @@ _gtk_css_image_scaled_class_init (GtkCssImageScaledClass *klass)
image_class->compute = gtk_css_image_scaled_compute;
image_class->print = gtk_css_image_scaled_print;
image_class->is_computed = gtk_css_image_scaled_is_computed;
image_class->contains_current_color = gtk_css_image_scaled_contains_current_color;
image_class->resolve = gtk_css_image_scaled_resolve;
object_class->dispose = gtk_css_image_scaled_dispose;
}
+11 -1
View File
@@ -134,7 +134,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
GtkCssValue *
_gtk_css_image_value_new (GtkCssImage *image)
{
static GtkCssValue image_none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, TRUE, FALSE, NULL };
static GtkCssValue image_none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, 1, 0, 0, NULL };
GtkCssValue *value;
if (image == NULL)
@@ -143,6 +143,7 @@ _gtk_css_image_value_new (GtkCssImage *image)
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IMAGE);
value->image = image;
value->is_computed = gtk_css_image_is_computed (image);
value->contains_current_color = gtk_css_image_contains_current_color (image);
return value;
}
@@ -155,3 +156,12 @@ _gtk_css_image_value_get_image (const GtkCssValue *value)
return value->image;
}
GtkCssValue *
gtk_css_image_value_resolve (GtkCssValue *value,
GtkCssValue *current_color)
{
if (!gtk_css_value_contains_current_color (value))
return gtk_css_value_ref (value);
return _gtk_css_image_value_new (gtk_css_image_resolve (_gtk_css_image_value_get_image (value), current_color));
}
+3
View File
@@ -28,6 +28,9 @@ GtkCssValue * _gtk_css_image_value_new (GtkCssImage *image);
GtkCssImage * _gtk_css_image_value_get_image (const GtkCssValue *image);
GtkCssValue * gtk_css_image_value_resolve (GtkCssValue *value,
GtkCssValue *current_color);
G_END_DECLS
+24 -24
View File
@@ -607,38 +607,38 @@ gtk_css_dimension_value_new (double value,
GtkCssUnit unit)
{
static GtkCssValue number_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 96 }} }, /* DPI default */
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 96 }} }, /* DPI default */
};
static GtkCssValue px_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 2 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 3 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 4 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 5 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 6 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 7 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 8 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 16 }} }, /* Icon size default */
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 32 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 64 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 2 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 3 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 4 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 5 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 6 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 7 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 8 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 16 }} }, /* Icon size default */
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 32 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PX, 64 }} },
};
static GtkCssValue percent_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, FALSE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 50 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, FALSE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 100 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 0, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 50 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 0, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 100 }} },
};
static GtkCssValue second_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_S, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_S, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_S, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_S, 1 }} },
};
static GtkCssValue deg_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 90 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 180 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 270 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_DEG, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_DEG, 90 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_DEG, 180 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, 1, 0, 0, TYPE_DIMENSION, {{ GTK_CSS_DEG, 270 }} },
};
GtkCssValue *result;
+22 -2
View File
@@ -323,6 +323,7 @@ gtk_css_palette_value_parse (GtkCssParser *parser)
}
result->is_computed = result->is_computed && gtk_css_value_is_computed (color);
result->contains_current_color = result->contains_current_color || gtk_css_value_contains_current_color (color);
g_ptr_array_add (names, ident);
g_ptr_array_add (colors, color);
@@ -336,7 +337,7 @@ gtk_css_palette_value_parse (GtkCssParser *parser)
return result;
}
const GdkRGBA *
GtkCssValue *
gtk_css_palette_value_get_color (GtkCssValue *value,
const char *name)
{
@@ -347,8 +348,27 @@ gtk_css_palette_value_get_color (GtkCssValue *value,
for (i = 0; i < value->n_colors; i ++)
{
if (strcmp (value->color_names[i], name) == 0)
return gtk_css_color_value_get_rgba (value->color_values[i]);
return value->color_values[i];
}
return NULL;
}
GtkCssValue *
gtk_css_palette_value_resolve (GtkCssValue *value,
GtkCssValue *current_color)
{
GtkCssValue *result;
if (!gtk_css_value_contains_current_color (value))
return gtk_css_value_ref (value);
result = gtk_css_palette_value_new_sized (value->n_colors);
for (guint i = 0; i < value->n_colors; i++)
{
result->color_names[i] = g_strdup (value->color_names[i]);
result->color_values[i] = gtk_css_color_value_resolve (value->color_values[i], NULL, current_color);
}
return result;
}
+4 -1
View File
@@ -30,8 +30,11 @@ GtkCssValue * gtk_css_palette_value_new_default (void);
GtkCssValue * gtk_css_palette_value_parse (GtkCssParser *parser);
const GdkRGBA * gtk_css_palette_value_get_color (GtkCssValue *value,
GtkCssValue * gtk_css_palette_value_get_color (GtkCssValue *value,
const char *color_name);
GtkCssValue * gtk_css_palette_value_resolve (GtkCssValue *value,
GtkCssValue *current_color);
G_END_DECLS
+32 -32
View File
@@ -138,28 +138,28 @@ static struct {
GtkCssValue values[4];
} background_repeat_values[4] = {
{ "no-repeat",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "repeat",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "round",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "space",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
} }
};
@@ -232,28 +232,28 @@ static struct {
GtkCssValue values[4];
} border_repeat_values[4] = {
{ "stretch",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "repeat",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "round",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "space",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, 1, 0, 0, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
} }
};
+47 -40
View File
@@ -26,6 +26,7 @@
#include "gtkcsscolorvalueprivate.h"
#include "gtksnapshotprivate.h"
#include "gtkpangoprivate.h"
#include "gtkcssnodeprivate.h"
#include "gsk/gskcairoblurprivate.h"
#include "gsk/gskroundedrectprivate.h"
@@ -285,7 +286,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_SHADOW = {
gtk_css_value_shadow_print
};
static GtkCssValue shadow_none_singleton = { &GTK_CSS_VALUE_SHADOW, 1, TRUE, FALSE, 0 };
static GtkCssValue shadow_none_singleton = { &GTK_CSS_VALUE_SHADOW, 1, 1, 0, 0, 0, 0 };
GtkCssValue *
gtk_css_shadow_value_new_none (void)
@@ -315,15 +316,18 @@ gtk_css_shadow_value_new (ShadowValue *shadows,
{
const ShadowValue *shadow = &retval->shadows[i];
if (!gtk_css_value_is_computed (shadow->hoffset) ||
!gtk_css_value_is_computed (shadow->voffset) ||
!gtk_css_value_is_computed (shadow->spread) ||
!gtk_css_value_is_computed (shadow->radius) ||
!gtk_css_value_is_computed (shadow->color))
if (retval->is_computed &&
(!gtk_css_value_is_computed (shadow->hoffset) ||
!gtk_css_value_is_computed (shadow->voffset) ||
!gtk_css_value_is_computed (shadow->spread) ||
!gtk_css_value_is_computed (shadow->radius) ||
!gtk_css_value_is_computed (shadow->color)))
{
retval->is_computed = FALSE;
break;
}
if (gtk_css_value_contains_current_color (shadow->color))
retval->contains_current_color = TRUE;
}
return retval;
@@ -711,60 +715,63 @@ gboolean
gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
GtkSnapshot *snapshot)
{
gboolean need_shadow = FALSE;
GskShadow *shadows;
guint i;
if (gtk_css_shadow_value_is_clear (value))
return FALSE;
shadows = g_newa (GskShadow, value->n_shadows);
for (i = 0; i < value->n_shadows; i++)
{
const ShadowValue *shadow = &value->shadows[i];
if (!gdk_rgba_is_clear (gtk_css_color_value_get_rgba (shadow->color)))
{
need_shadow = TRUE;
break;
}
shadows[i].color = *gtk_css_color_value_get_rgba (shadow->color);
shadows[i].dx = gtk_css_number_value_get (shadow->hoffset, 0);
shadows[i].dy = gtk_css_number_value_get (shadow->voffset, 0);
shadows[i].radius = gtk_css_number_value_get (shadow->radius, 0);
if (value->is_filter)
shadows[i].radius *= 2;
}
if (need_shadow)
{
GskShadow *shadows = g_newa (GskShadow, value->n_shadows);
gtk_snapshot_push_shadow (snapshot, shadows, value->n_shadows);
for (i = 0; i < value->n_shadows; i++)
{
const ShadowValue *shadow = &value->shadows[i];
shadows[i].dx = gtk_css_number_value_get (shadow->hoffset, 0);
shadows[i].dy = gtk_css_number_value_get (shadow->voffset, 0);
shadows[i].color = *gtk_css_color_value_get_rgba (shadow->color);
shadows[i].radius = gtk_css_number_value_get (shadow->radius, 0);
if (value->is_filter)
shadows[i].radius *= 2;
}
gtk_snapshot_push_shadow (snapshot, shadows, value->n_shadows);
}
return need_shadow;
return TRUE;
}
void
gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value,
GtkSnapshot *snapshot)
{
gboolean need_shadow = FALSE;
if (!gtk_css_shadow_value_is_clear (value))
gtk_snapshot_pop (snapshot);
}
GtkCssValue *
gtk_css_shadow_value_resolve (GtkCssValue *value,
GtkCssValue *current_color)
{
guint i;
ShadowValue *shadows;
if (!gtk_css_value_contains_current_color (value))
return gtk_css_value_ref (value);
shadows = g_alloca (sizeof (ShadowValue) * value->n_shadows);
for (i = 0; i < value->n_shadows; i++)
{
const ShadowValue *shadow = &value->shadows[i];
if (!gdk_rgba_is_clear (gtk_css_color_value_get_rgba (shadow->color)))
{
need_shadow = TRUE;
break;
}
shadows[i].hoffset = gtk_css_value_ref (shadow->hoffset);
shadows[i].voffset = gtk_css_value_ref (shadow->voffset);
shadows[i].radius = gtk_css_value_ref (shadow->radius);
shadows[i].spread = gtk_css_value_ref (shadow->spread);
shadows[i].color = gtk_css_color_value_resolve (shadow->color, NULL, current_color);
shadows[i].inset = shadow->inset;
}
if (need_shadow)
gtk_snapshot_pop (snapshot);
return gtk_css_shadow_value_new (shadows, value->n_shadows, value->is_filter);
}
+3
View File
@@ -56,5 +56,8 @@ gboolean gtk_css_shadow_value_push_snapshot (const GtkCssValue
void gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value,
GtkSnapshot *snapshot);
GtkCssValue * gtk_css_shadow_value_resolve (GtkCssValue *value,
GtkCssValue *current_color);
G_END_DECLS
+40 -11
View File
@@ -57,14 +57,17 @@ gtk_css_## NAME ## _values_compute_changes_and_affects (GtkCssStyle *style1, \
{ \
GtkCssValue **g1 = GET_VALUES (style1->NAME); \
GtkCssValue **g2 = GET_VALUES (style2->NAME); \
GtkCssValue **u1 = GET_VALUES (style1->used); \
GtkCssValue **u2 = GET_VALUES (style2->used); \
int i; \
for (i = 0; i < G_N_ELEMENTS (NAME ## _props); i++) \
{ \
GtkCssValue *v1 = g1[i] ? g1[i] : style1->core->color; \
GtkCssValue *v2 = g2[i] ? g2[i] : style2->core->color; \
guint id = NAME ## _props[i]; \
int j = used_props_map[id]; \
GtkCssValue *v1 = j < 0 ? g1[i] : u1[j]; \
GtkCssValue *v2 = j < 0 ? g2[i] : u2[j]; \
if (!gtk_css_value_equal (v1, v2)) \
{ \
guint id = NAME ## _props[i]; \
*changes = _gtk_bitmask_set (*changes, id, TRUE); \
*affects |= _gtk_css_style_property_get_affects (_gtk_css_style_property_lookup_by_id (id)); \
} \
@@ -171,6 +174,21 @@ verify_style_groups (void)
#undef VERIFY_MASK
static void
verify_used_map (void)
{
for (guint id = 0; id < GTK_CSS_PROPERTY_N_PROPERTIES; id++)
{
if (used_props_map[id] != -1)
g_assert (used_props[used_props_map[id]] == id);
}
for (guint i = 0; i < G_N_ELEMENTS (used_props); i++)
{
g_assert (used_props_map[used_props[i]] == i);
}
}
G_DEFINE_TYPE (GtkCssStaticStyle, gtk_css_static_style, GTK_TYPE_CSS_STYLE)
static GtkCssSection *
@@ -250,6 +268,7 @@ gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
gtk_css_other_values_init ();
verify_style_groups ();
verify_used_map ();
}
static void
@@ -638,12 +657,18 @@ gtk_css_static_style_get_default (void)
return default_style;
}
static inline GtkCssValue *
initial_color (void)
{
return _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR));
}
static GtkCssValues *
gtk_css_core_create_initial_values (void)
{
return NULL;
}
static GtkCssValues *
gtk_css_background_create_initial_values (void)
{
@@ -685,10 +710,10 @@ gtk_css_border_create_initial_values (void)
values->border_top_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS, &context);
values->border_bottom_left_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS, &context);
values->border_bottom_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS, &context);
values->border_top_color = NULL;
values->border_right_color = NULL;
values->border_bottom_color = NULL;
values->border_left_color = NULL;
values->border_top_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_COLOR, &context);
values->border_right_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR, &context);
values->border_bottom_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR, &context);
values->border_left_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_COLOR, &context);
values->border_image_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE, &context);
values->border_image_repeat = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT, &context);
values->border_image_slice = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE, &context);
@@ -708,7 +733,7 @@ gtk_css_outline_create_initial_values (void)
values->outline_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_STYLE, &context);
values->outline_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_WIDTH, &context);
values->outline_offset = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_OFFSET, &context);
values->outline_color = NULL;
values->outline_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_COLOR, &context);
return (GtkCssValues *)values;
}
@@ -734,7 +759,7 @@ gtk_css_font_variant_create_initial_values (void)
values = (GtkCssFontVariantValues *)gtk_css_values_new (GTK_CSS_FONT_VARIANT_INITIAL_VALUES);
values->text_decoration_line = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_LINE, &context);
values->text_decoration_color = NULL;
values->text_decoration_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR, &context);
values->text_decoration_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE, &context);
values->text_transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_TRANSFORM, &context);
values->font_kerning = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_KERNING, &context);
@@ -898,6 +923,8 @@ gtk_css_lookup_resolve (GtkCssLookup *lookup,
gtk_css_font_values_new_compute (sstyle, lookup, &context);
}
gtk_css_style_resolve_used_values (style, &context);
return;
}
@@ -956,6 +983,8 @@ gtk_css_lookup_resolve (GtkCssLookup *lookup,
else
gtk_css_other_values_new_compute (sstyle, lookup, &context);
gtk_css_style_resolve_used_values (style, &context);
for (unsigned int i = 0; i < GTK_CSS_SHORTHAND_PROPERTY_N_PROPERTIES; i++)
{
if (shorthands[i])
@@ -1064,7 +1093,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkCssValue *parent_original_value;
/* Just take the style from the parent */
value = gtk_css_value_ref (gtk_css_style_get_value (context->parent_style, id));
value = gtk_css_value_ref (gtk_css_style_get_computed_value (context->parent_style, id));
parent_original_value = gtk_css_style_get_original_value (context->parent_style, id);
+337 -29
View File
@@ -26,11 +26,13 @@
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssimagevalueprivate.h"
#include "gtkcssinheritvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcsspalettevalueprivate.h"
#include "gtkcssshadowvalueprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcssstringvalueprivate.h"
#include "gtkcssfontvariationsvalueprivate.h"
@@ -41,6 +43,7 @@
#include "gtkstyleanimationprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkcssvaluesprivate.h"
G_DEFINE_ABSTRACT_TYPE (GtkCssStyle, gtk_css_style, G_TYPE_OBJECT)
@@ -100,6 +103,209 @@ gtk_css_style_init (GtkCssStyle *style)
GtkCssValue *
gtk_css_style_get_value (GtkCssStyle *style,
guint id)
{
return gtk_css_style_get_used_value (style, id);
}
GtkCssValue *
gtk_css_style_get_used_value (GtkCssStyle *style,
guint id)
{
switch (id)
{
case GTK_CSS_PROPERTY_COLOR:
return style->used->color;
case GTK_CSS_PROPERTY_DPI:
return style->core->dpi;
case GTK_CSS_PROPERTY_FONT_SIZE:
return style->core->font_size;
case GTK_CSS_PROPERTY_ICON_PALETTE:
return style->used->icon_palette;
case GTK_CSS_PROPERTY_BACKGROUND_COLOR:
return style->used->background_color;
case GTK_CSS_PROPERTY_FONT_FAMILY:
return style->font->font_family;
case GTK_CSS_PROPERTY_FONT_STYLE:
return style->font->font_style;
case GTK_CSS_PROPERTY_FONT_WEIGHT:
return style->font->font_weight;
case GTK_CSS_PROPERTY_FONT_STRETCH:
return style->font->font_stretch;
case GTK_CSS_PROPERTY_LETTER_SPACING:
return style->font->letter_spacing;
case GTK_CSS_PROPERTY_LINE_HEIGHT:
return style->font->line_height;
case GTK_CSS_PROPERTY_TEXT_DECORATION_LINE:
return style->font_variant->text_decoration_line;
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
return style->used->text_decoration_color;
case GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE:
return style->font_variant->text_decoration_style;
case GTK_CSS_PROPERTY_TEXT_TRANSFORM:
return style->font_variant->text_transform;
case GTK_CSS_PROPERTY_FONT_KERNING:
return style->font_variant->font_kerning;
case GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES:
return style->font_variant->font_variant_ligatures;
case GTK_CSS_PROPERTY_FONT_VARIANT_POSITION:
return style->font_variant->font_variant_position;
case GTK_CSS_PROPERTY_FONT_VARIANT_CAPS:
return style->font_variant->font_variant_caps;
case GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC:
return style->font_variant->font_variant_numeric;
case GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES:
return style->font_variant->font_variant_alternates;
case GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN:
return style->font_variant->font_variant_east_asian;
case GTK_CSS_PROPERTY_TEXT_SHADOW:
return style->used->text_shadow;
case GTK_CSS_PROPERTY_BOX_SHADOW:
return style->used->box_shadow;
case GTK_CSS_PROPERTY_MARGIN_TOP:
return style->size->margin_top;
case GTK_CSS_PROPERTY_MARGIN_LEFT:
return style->size->margin_left;
case GTK_CSS_PROPERTY_MARGIN_BOTTOM:
return style->size->margin_bottom;
case GTK_CSS_PROPERTY_MARGIN_RIGHT:
return style->size->margin_right;
case GTK_CSS_PROPERTY_PADDING_TOP:
return style->size->padding_top;
case GTK_CSS_PROPERTY_PADDING_LEFT:
return style->size->padding_left;
case GTK_CSS_PROPERTY_PADDING_BOTTOM:
return style->size->padding_bottom;
case GTK_CSS_PROPERTY_PADDING_RIGHT:
return style->size->padding_right;
case GTK_CSS_PROPERTY_BORDER_TOP_STYLE:
return style->border->border_top_style;
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
return style->border->border_top_width;
case GTK_CSS_PROPERTY_BORDER_LEFT_STYLE:
return style->border->border_left_style;
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
return style->border->border_left_width;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE:
return style->border->border_bottom_style;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
return style->border->border_bottom_width;
case GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE:
return style->border->border_right_style;
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
return style->border->border_right_width;
case GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS:
return style->border->border_top_left_radius;
case GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS:
return style->border->border_top_right_radius;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS:
return style->border->border_bottom_right_radius;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS:
return style->border->border_bottom_left_radius;
case GTK_CSS_PROPERTY_OUTLINE_STYLE:
return style->outline->outline_style;
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
return style->outline->outline_width;
case GTK_CSS_PROPERTY_OUTLINE_OFFSET:
return style->outline->outline_offset;
case GTK_CSS_PROPERTY_BACKGROUND_CLIP:
return style->background->background_clip;
case GTK_CSS_PROPERTY_BACKGROUND_ORIGIN:
return style->background->background_origin;
case GTK_CSS_PROPERTY_BACKGROUND_SIZE:
return style->background->background_size;
case GTK_CSS_PROPERTY_BACKGROUND_POSITION:
return style->background->background_position;
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
return style->used->border_top_color;
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
return style->used->border_right_color;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
return style->used->border_bottom_color;
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
return style->used->border_left_color;
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
return style->used->outline_color;
case GTK_CSS_PROPERTY_BACKGROUND_REPEAT:
return style->background->background_repeat;
case GTK_CSS_PROPERTY_BACKGROUND_IMAGE:
return style->used->background_image;
case GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE:
return style->background->background_blend_mode;
case GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE:
return style->used->border_image_source;
case GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT:
return style->border->border_image_repeat;
case GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE:
return style->border->border_image_slice;
case GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH:
return style->border->border_image_width;
case GTK_CSS_PROPERTY_ICON_SOURCE:
return style->used->icon_source;
case GTK_CSS_PROPERTY_ICON_SIZE:
return style->icon->icon_size;
case GTK_CSS_PROPERTY_ICON_SHADOW:
return style->used->icon_shadow;
case GTK_CSS_PROPERTY_ICON_STYLE:
return style->icon->icon_style;
case GTK_CSS_PROPERTY_ICON_TRANSFORM:
return style->other->icon_transform;
case GTK_CSS_PROPERTY_ICON_FILTER:
return style->other->icon_filter;
case GTK_CSS_PROPERTY_BORDER_SPACING:
return style->size->border_spacing;
case GTK_CSS_PROPERTY_TRANSFORM:
return style->other->transform;
case GTK_CSS_PROPERTY_TRANSFORM_ORIGIN:
return style->other->transform_origin;
case GTK_CSS_PROPERTY_MIN_WIDTH:
return style->size->min_width;
case GTK_CSS_PROPERTY_MIN_HEIGHT:
return style->size->min_height;
case GTK_CSS_PROPERTY_TRANSITION_PROPERTY:
return style->transition->transition_property;
case GTK_CSS_PROPERTY_TRANSITION_DURATION:
return style->transition->transition_duration;
case GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION:
return style->transition->transition_timing_function;
case GTK_CSS_PROPERTY_TRANSITION_DELAY:
return style->transition->transition_delay;
case GTK_CSS_PROPERTY_ANIMATION_NAME:
return style->animation->animation_name;
case GTK_CSS_PROPERTY_ANIMATION_DURATION:
return style->animation->animation_duration;
case GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION:
return style->animation->animation_timing_function;
case GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT:
return style->animation->animation_iteration_count;
case GTK_CSS_PROPERTY_ANIMATION_DIRECTION:
return style->animation->animation_direction;
case GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE:
return style->animation->animation_play_state;
case GTK_CSS_PROPERTY_ANIMATION_DELAY:
return style->animation->animation_delay;
case GTK_CSS_PROPERTY_ANIMATION_FILL_MODE:
return style->animation->animation_fill_mode;
case GTK_CSS_PROPERTY_OPACITY:
return style->other->opacity;
case GTK_CSS_PROPERTY_FILTER:
return style->other->filter;
case GTK_CSS_PROPERTY_CARET_COLOR:
return style->used->caret_color;
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
return style->used->secondary_caret_color;
case GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS:
return style->font->font_feature_settings;
case GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS:
return style->font->font_variation_settings;
default:
g_assert_not_reached ();
}
}
GtkCssValue *
gtk_css_style_get_computed_value (GtkCssStyle *style,
guint id)
{
switch (id)
{
@@ -128,7 +334,7 @@ gtk_css_style_get_value (GtkCssStyle *style,
case GTK_CSS_PROPERTY_TEXT_DECORATION_LINE:
return style->font_variant->text_decoration_line;
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
return style->font_variant->text_decoration_color ? style->font_variant->text_decoration_color : style->core->color;
return style->font_variant->text_decoration_color;
case GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE:
return style->font_variant->text_decoration_style;
case GTK_CSS_PROPERTY_TEXT_TRANSFORM:
@@ -206,15 +412,15 @@ gtk_css_style_get_value (GtkCssStyle *style,
case GTK_CSS_PROPERTY_BACKGROUND_POSITION:
return style->background->background_position;
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
return style->border->border_top_color ? style->border->border_top_color : style->core->color;
return style->border->border_top_color;
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
return style->border->border_right_color ? style->border->border_right_color : style->core->color;
return style->border->border_right_color;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
return style->border->border_bottom_color ? style->border->border_bottom_color : style->core->color;
return style->border->border_bottom_color;
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
return style->border->border_left_color ? style->border->border_left_color: style->core->color;
return style->border->border_left_color;
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
return style->outline->outline_color ? style->outline->outline_color : style->core->color;
return style->outline->outline_color;
case GTK_CSS_PROPERTY_BACKGROUND_REPEAT:
return style->background->background_repeat;
case GTK_CSS_PROPERTY_BACKGROUND_IMAGE:
@@ -280,9 +486,9 @@ gtk_css_style_get_value (GtkCssStyle *style,
case GTK_CSS_PROPERTY_FILTER:
return style->other->filter;
case GTK_CSS_PROPERTY_CARET_COLOR:
return style->font->caret_color ? style->font->caret_color : style->core->color;
return style->font->caret_color;
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
return style->font->secondary_caret_color ? style->font->secondary_caret_color : style->core->color;
return style->font->secondary_caret_color;
case GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS:
return style->font->font_feature_settings;
case GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS:
@@ -355,16 +561,23 @@ gtk_css_style_print (GtkCssStyle *style,
{
GtkCssSection *section;
GtkCssStyleProperty *prop;
GtkCssValue *value;
GtkCssValue *value, *computed, *initial;
const char *name;
section = gtk_css_style_get_section (style, i);
if (!section && skip_initial)
continue;
prop = _gtk_css_style_property_lookup_by_id (i);
name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop));
value = gtk_css_style_get_value (style, i);
computed = gtk_css_style_get_computed_value (style, i);
value = gtk_css_style_get_used_value (style, i);
initial = _gtk_css_style_property_get_initial_value (prop);
section = gtk_css_style_get_section (style, i);
if (skip_initial)
{
if (!section &&
(computed == initial ||
!gtk_css_value_contains_current_color (computed)))
continue;
}
g_string_append_printf (string, "%*s%s: ", indent, "", name);
gtk_css_value_print (value, string);
@@ -647,20 +860,22 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
GtkTextDecorationStyle decoration_style;
const GdkRGBA *color;
const GdkRGBA *decoration_color;
gboolean has_decoration_color;
double letter_spacing;
/* text-decoration */
decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
color = gtk_css_color_value_get_rgba (style->core->color);
decoration_color = gtk_css_color_value_get_rgba (style->font_variant->text_decoration_color
? style->font_variant->text_decoration_color
: style->core->color);
color = gtk_css_color_value_get_rgba (style->used->color);
decoration_color = gtk_css_color_value_get_rgba (style->used->text_decoration_color);
has_decoration_color = !gdk_rgba_equal (color, decoration_color);
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE)
{
attrs = add_pango_attr (attrs, pango_attr_underline_new (get_pango_underline_from_style (decoration_style)));
if (!gdk_rgba_equal (color, decoration_color))
if (has_decoration_color)
attrs = add_pango_attr (attrs, pango_attr_underline_color_new (decoration_color->red * 65535. + 0.5,
decoration_color->green * 65535. + 0.5,
decoration_color->blue * 65535. + 0.5));
@@ -668,7 +883,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_OVERLINE)
{
attrs = add_pango_attr (attrs, pango_attr_overline_new (get_pango_overline_from_style (decoration_style)));
if (!gdk_rgba_equal (color, decoration_color))
if (has_decoration_color)
attrs = add_pango_attr (attrs, pango_attr_overline_color_new (decoration_color->red * 65535. + 0.5,
decoration_color->green * 65535. + 0.5,
decoration_color->blue * 65535. + 0.5));
@@ -676,7 +891,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH)
{
attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
if (!gdk_rgba_equal (color, decoration_color))
if (!has_decoration_color)
attrs = add_pango_attr (attrs, pango_attr_strikethrough_color_new (decoration_color->red * 65535. + 0.5,
decoration_color->green * 65535. + 0.5,
decoration_color->blue * 65535. + 0.5));
@@ -805,24 +1020,22 @@ void
gtk_css_style_lookup_symbolic_colors (GtkCssStyle *style,
GdkRGBA color_out[4])
{
GtkCssValue *palette, *color;
const char *names[4] = {
[GTK_SYMBOLIC_COLOR_ERROR] = "error",
[GTK_SYMBOLIC_COLOR_WARNING] = "warning",
[GTK_SYMBOLIC_COLOR_SUCCESS] = "success"
};
color = style->core->color;
palette = style->core->icon_palette;
color_out[GTK_SYMBOLIC_COLOR_FOREGROUND] = *gtk_css_color_value_get_rgba (color);
color_out[GTK_SYMBOLIC_COLOR_FOREGROUND] = *gtk_css_color_value_get_rgba (style->used->color);
for (gsize i = 1; i < 4; i++)
{
const GdkRGBA *lookup;
GtkCssValue *lookup;
lookup = gtk_css_palette_value_get_color (style->used->icon_palette, names[i]);
lookup = gtk_css_palette_value_get_color (palette, names[i]);
if (lookup)
color_out[i] = *lookup;
color_out[i] = *gtk_css_color_value_get_rgba (lookup);
else
color_out[i] = color_out[GTK_SYMBOLIC_COLOR_FOREGROUND];
}
@@ -841,7 +1054,8 @@ static const int values_size[] = {
sizeof (GtkCssAnimationValues),
sizeof (GtkCssTransitionValues),
sizeof (GtkCssSizeValues),
sizeof (GtkCssOtherValues)
sizeof (GtkCssOtherValues),
sizeof (GtkCssUsedValues)
};
#define TYPE_INDEX(type) ((type) - ((type) % 2))
@@ -932,3 +1146,97 @@ gtk_css_style_list_custom_properties (GtkCssStyle *style)
return NULL;
}
static GtkCssValue *
gtk_css_style_resolve_used_value (GtkCssStyle *style,
GtkCssValue *value,
guint id,
GtkCssComputeContext *context)
{
GtkCssValue *used;
switch (id)
{
case GTK_CSS_PROPERTY_COLOR:
{
GtkCssValue *current;
if (context->parent_style)
current = context->parent_style->used->color;
else
current = _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR));
used = gtk_css_color_value_resolve (value, NULL, current);
}
break;
case GTK_CSS_PROPERTY_BACKGROUND_COLOR:
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
case GTK_CSS_PROPERTY_CARET_COLOR:
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
used = gtk_css_color_value_resolve (value, NULL, style->used->color);
break;
case GTK_CSS_PROPERTY_BOX_SHADOW:
case GTK_CSS_PROPERTY_TEXT_SHADOW:
case GTK_CSS_PROPERTY_ICON_SHADOW:
used = gtk_css_shadow_value_resolve (value, style->used->color);
break;
case GTK_CSS_PROPERTY_ICON_PALETTE:
used = gtk_css_palette_value_resolve (value, style->used->color);
break;
case GTK_CSS_PROPERTY_BACKGROUND_IMAGE:
case GTK_CSS_PROPERTY_ICON_SOURCE:
case GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE:
used = gtk_css_image_value_resolve (value, style->used->color);
break;
default:
return NULL;
}
g_assert (!gtk_css_value_contains_current_color (used));
return used;
}
static inline void
gtk_css_take_value (GtkCssValue **variable,
GtkCssValue *value)
{
if (*variable)
gtk_css_value_unref (*variable);
*variable = value;
}
void
gtk_css_style_resolve_used_values (GtkCssStyle *style,
GtkCssComputeContext *context)
{
GtkCssValue **values;
style->used = (GtkCssUsedValues *) gtk_css_values_new (GTK_CSS_USED_VALUES);
values = &style->used->color;
for (guint i = 0; i < G_N_ELEMENTS (used_props); i++)
{
guint id = used_props[i];
GtkCssValue *value, *used;
value = gtk_css_style_get_computed_value (style, id);
if (gtk_css_value_contains_current_color (value))
used = gtk_css_style_resolve_used_value (style, value, id, context);
else
used = gtk_css_value_ref (value);
gtk_css_take_value (&values[i], used);
}
}
+20 -12
View File
@@ -26,7 +26,8 @@ compute_change (GtkCssStyleChange *change)
{
gboolean color_changed = FALSE;
if (change->old_style->core != change->new_style->core)
if (change->old_style->core != change->new_style->core ||
gtk_css_value_contains_current_color (change->old_style->core->color))
{
gtk_css_core_values_compute_changes_and_affects (change->old_style,
change->new_style,
@@ -35,45 +36,51 @@ compute_change (GtkCssStyleChange *change)
color_changed = _gtk_bitmask_get (change->changes, GTK_CSS_PROPERTY_COLOR);
}
if (change->old_style->background != change->new_style->background)
if (change->old_style->background != change->new_style->background ||
(color_changed && (gtk_css_value_contains_current_color (change->old_style->background->background_color) ||
gtk_css_value_contains_current_color (change->old_style->background->box_shadow) ||
gtk_css_value_contains_current_color (change->old_style->background->background_image))))
gtk_css_background_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->border != change->new_style->border ||
(color_changed && (change->old_style->border->border_top_color == NULL ||
change->old_style->border->border_right_color == NULL ||
change->old_style->border->border_bottom_color == NULL ||
change->old_style->border->border_left_color == NULL)))
(color_changed && (gtk_css_value_contains_current_color (change->old_style->border->border_top_color) ||
gtk_css_value_contains_current_color (change->old_style->border->border_right_color) ||
gtk_css_value_contains_current_color (change->old_style->border->border_bottom_color) ||
gtk_css_value_contains_current_color (change->old_style->border->border_left_color) ||
gtk_css_value_contains_current_color (change->old_style->border->border_image_source))))
gtk_css_border_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->icon != change->new_style->icon)
if (change->old_style->icon != change->new_style->icon ||
(color_changed && (gtk_css_value_contains_current_color (change->old_style->icon->icon_shadow))))
gtk_css_icon_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->outline != change->new_style->outline ||
(color_changed && change->old_style->outline->outline_color == NULL))
(color_changed && gtk_css_value_contains_current_color (change->old_style->outline->outline_color)))
gtk_css_outline_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->font != change->new_style->font ||
(color_changed && (change->old_style->font->caret_color == NULL ||
change->old_style->font->secondary_caret_color == NULL)))
(color_changed && (gtk_css_value_contains_current_color (change->old_style->font->caret_color) ||
gtk_css_value_contains_current_color (change->old_style->font->secondary_caret_color) ||
gtk_css_value_contains_current_color (change->old_style->font->text_shadow))))
gtk_css_font_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->font_variant != change->new_style->font_variant ||
(color_changed && change->old_style->font_variant->text_decoration_color == NULL))
(color_changed && gtk_css_value_contains_current_color (change->old_style->font_variant->text_decoration_color)))
gtk_css_font_variant_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
@@ -97,7 +104,8 @@ compute_change (GtkCssStyleChange *change)
&change->changes,
&change->affects);
if (change->old_style->other != change->new_style->other)
if (change->old_style->other != change->new_style->other ||
(color_changed && gtk_css_value_contains_current_color (change->old_style->other->icon_source)))
gtk_css_other_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
+41 -8
View File
@@ -59,6 +59,7 @@ typedef enum {
GTK_CSS_SIZE_INITIAL_VALUES,
GTK_CSS_OTHER_VALUES,
GTK_CSS_OTHER_INITIAL_VALUES,
GTK_CSS_USED_VALUES,
} GtkCssValuesType;
typedef struct _GtkCssValues GtkCssValues;
@@ -73,6 +74,7 @@ typedef struct _GtkCssAnimationValues GtkCssAnimationValues;
typedef struct _GtkCssTransitionValues GtkCssTransitionValues;
typedef struct _GtkCssSizeValues GtkCssSizeValues;
typedef struct _GtkCssOtherValues GtkCssOtherValues;
typedef struct _GtkCssUsedValues GtkCssUsedValues;
struct _GtkCssValues {
int ref_count;
@@ -117,10 +119,10 @@ struct _GtkCssBorderValues {
GtkCssValue *border_top_right_radius;
GtkCssValue *border_bottom_right_radius;
GtkCssValue *border_bottom_left_radius;
GtkCssValue *border_top_color; // NULL if currentColor
GtkCssValue *border_right_color; // NULL if currentColor
GtkCssValue *border_bottom_color; // NULL if currentColor
GtkCssValue *border_left_color; // NULL if currentColor
GtkCssValue *border_top_color;
GtkCssValue *border_right_color;
GtkCssValue *border_bottom_color;
GtkCssValue *border_left_color;
GtkCssValue *border_image_source;
GtkCssValue *border_image_repeat;
GtkCssValue *border_image_slice;
@@ -142,7 +144,7 @@ struct _GtkCssOutlineValues {
GtkCssValue *outline_style;
GtkCssValue *outline_width;
GtkCssValue *outline_offset;
GtkCssValue *outline_color; // NULL if currentColor
GtkCssValue *outline_color;
};
struct _GtkCssFontValues {
@@ -154,8 +156,8 @@ struct _GtkCssFontValues {
GtkCssValue *font_stretch;
GtkCssValue *letter_spacing;
GtkCssValue *text_shadow;
GtkCssValue *caret_color; // NULL if currentColor
GtkCssValue *secondary_caret_color; // NULL if currentColor
GtkCssValue *caret_color;
GtkCssValue *secondary_caret_color;
GtkCssValue *font_feature_settings;
GtkCssValue *font_variation_settings;
GtkCssValue *line_height;
@@ -165,7 +167,7 @@ struct _GtkCssFontVariantValues {
GtkCssValues base;
GtkCssValue *text_decoration_line;
GtkCssValue *text_decoration_color; // NULL if currentColor
GtkCssValue *text_decoration_color;
GtkCssValue *text_decoration_style;
GtkCssValue *text_transform;
GtkCssValue *font_kerning;
@@ -227,6 +229,28 @@ struct _GtkCssOtherValues {
GtkCssValue *filter;
};
struct _GtkCssUsedValues {
GtkCssValues base;
GtkCssValue *color;
GtkCssValue *icon_palette;
GtkCssValue *background_color;
GtkCssValue *box_shadow;
GtkCssValue *background_image;
GtkCssValue *border_top_color;
GtkCssValue *border_right_color;
GtkCssValue *border_bottom_color;
GtkCssValue *border_left_color;
GtkCssValue *border_image_source;
GtkCssValue *icon_shadow;
GtkCssValue *outline_color;
GtkCssValue *caret_color;
GtkCssValue *secondary_caret_color;
GtkCssValue *text_shadow;
GtkCssValue *text_decoration_color;
GtkCssValue *icon_source;
};
/* typedef struct _GtkCssStyle GtkCssStyle; */
typedef struct _GtkCssStyleClass GtkCssStyleClass;
@@ -245,6 +269,8 @@ struct _GtkCssStyle
GtkCssTransitionValues *transition;
GtkCssSizeValues *size;
GtkCssOtherValues *other;
GtkCssUsedValues *used;
GtkCssVariableSet *variables;
GtkCssValue *variable_values;
@@ -272,6 +298,10 @@ GType gtk_css_style_get_type (void) G_GNUC_CO
GtkCssValue * gtk_css_style_get_value (GtkCssStyle *style,
guint id) G_GNUC_PURE;
GtkCssValue * gtk_css_style_get_computed_value (GtkCssStyle *style,
guint id) G_GNUC_PURE;
GtkCssValue * gtk_css_style_get_used_value (GtkCssStyle *style,
guint id) G_GNUC_PURE;
GtkCssSection * gtk_css_style_get_section (GtkCssStyle *style,
guint id) G_GNUC_PURE;
gboolean gtk_css_style_is_static (GtkCssStyle *style) G_GNUC_PURE;
@@ -298,6 +328,9 @@ GtkCssVariableValue * gtk_css_style_get_custom_property (GtkCssStyle
int id);
GArray * gtk_css_style_list_custom_properties (GtkCssStyle *style);
void gtk_css_style_resolve_used_values (GtkCssStyle *style,
GtkCssComputeContext *context);
GtkCssValues *gtk_css_values_new (GtkCssValuesType type);
GtkCssValues *gtk_css_values_ref (GtkCssValues *values);
void gtk_css_values_unref (GtkCssValues *values);
+1 -1
View File
@@ -795,7 +795,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TRANSFORM = {
gtk_css_value_transform_print
};
static GtkCssValue transform_none_singleton = { &GTK_CSS_VALUE_TRANSFORM, 1, TRUE, FALSE, 0, { { GTK_CSS_TRANSFORM_NONE } } };
static GtkCssValue transform_none_singleton = { &GTK_CSS_VALUE_TRANSFORM, 1, 1, 0, 0, 0, { { GTK_CSS_TRANSFORM_NONE } } };
static GtkCssValue *
gtk_css_transform_value_alloc (guint n_transforms)
+10 -1
View File
@@ -39,7 +39,8 @@ typedef struct _GtkCssValueClass GtkCssValueClass;
const GtkCssValueClass *class; \
int ref_count; \
guint is_computed: 1; \
guint contains_variables: 1;
guint contains_variables: 1; \
guint contains_current_color: 1;
typedef struct {
GtkStyleProvider *provider;
@@ -142,5 +143,13 @@ gtk_css_value_contains_variables (const GtkCssValue *value)
return value_base->contains_variables;
}
static inline gboolean
gtk_css_value_contains_current_color (const GtkCssValue *value)
{
GtkCssValueBase *value_base = (GtkCssValueBase *) value;
return value_base->contains_current_color;
}
G_END_DECLS
+61
View File
@@ -148,4 +148,65 @@ static const int other_props[] = {
GTK_CSS_PROPERTY_FILTER,
};
static const int used_props[] = {
GTK_CSS_PROPERTY_COLOR,
GTK_CSS_PROPERTY_ICON_PALETTE,
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
GTK_CSS_PROPERTY_BOX_SHADOW,
GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
GTK_CSS_PROPERTY_ICON_SHADOW,
GTK_CSS_PROPERTY_OUTLINE_COLOR,
GTK_CSS_PROPERTY_CARET_COLOR,
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GTK_CSS_PROPERTY_TEXT_SHADOW,
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
GTK_CSS_PROPERTY_ICON_SOURCE,
};
/* Maps back from css property ids to position in used_props.
* -1 means 'not present'.
*/
static const int used_props_map[] = {
0, /* color */
-1, -1,
1, /* icon-palette */
2, /* background-color */
-1, -1, -1, -1, -1, -1,
15, /* text-decoration-color */
-1, -1, -1, -1, -1, -1, -1, -1,
-1,
14, /* text-shadow */
3, /* box-shadow */
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1,
5, /* border-top-color */
6, /* border-right-color */
7, /* border-bottom-color */
8, /* border-left-color */
11, /* outline-color */
-1,
4, /* background-image */
-1,
9, /* border-image-source */
-1, -1, -1,
16, /* icon-source */
-1,
10, /* icon-shadow */
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1,
12, /* caret-color */
13, /* secondary-caret-color */
-1, -1, -1,
};
G_STATIC_ASSERT (G_N_ELEMENTS (used_props_map) == GTK_CSS_PROPERTY_N_PROPERTIES);
G_END_DECLS
+1 -1
View File
@@ -2609,7 +2609,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_append_path (cr, path);
cairo_path_destroy (path);
border_color = gtk_css_color_value_get_rgba (style->border->border_top_color ? style->border->border_top_color : style->core->color);
border_color = gtk_css_color_value_get_rgba (style->used->border_top_color);
border_width = round (gtk_css_number_value_get (style->border->border_left_width, 100));
cairo_set_line_width (cr, border_width);
+2 -1
View File
@@ -839,7 +839,8 @@ gtk_label_update_layout_attributes (GtkLabel *self,
g_slist_free (attributes);
}
link_color = gtk_css_color_value_get_rgba (style->core->color);
link_color = gtk_css_color_value_get_rgba (style->used->color);
attr = pango_attr_foreground_new (link_color->red * 65535,
link_color->green * 65535,
link_color->blue * 65535);
+27 -24
View File
@@ -341,13 +341,9 @@ subtract_decoration_corners_from_region (cairo_region_t *region,
}
static int
get_translucent_border_edge (const GtkCssValue *color,
const GtkCssValue *border_color,
const GtkCssValue *border_width)
get_translucent_border_edge (GtkCssValue *border_color,
GtkCssValue *border_width)
{
if (border_color == NULL)
border_color = color;
if (!gdk_rgba_is_opaque (gtk_css_color_value_get_rgba (border_color)))
return round (gtk_css_number_value_get (border_width, 100));
@@ -361,29 +357,36 @@ get_translucent_border_width (GtkWidget *widget,
GtkCssNode *css_node = gtk_widget_get_css_node (widget);
GtkCssStyle *style = gtk_css_node_get_style (css_node);
border->top = get_translucent_border_edge (style->core->color,
style->border->border_top_color,
border->top = get_translucent_border_edge (style->used->border_top_color,
style->border->border_top_width);
border->bottom = get_translucent_border_edge (style->core->color,
style->border->border_bottom_color,
border->bottom = get_translucent_border_edge (style->used->border_bottom_color,
style->border->border_bottom_width);
border->left = get_translucent_border_edge (style->core->color,
style->border->border_left_color,
border->left = get_translucent_border_edge (style->used->border_left_color,
style->border->border_left_width);
border->right = get_translucent_border_edge (style->core->color,
style->border->border_right_color,
border->right = get_translucent_border_edge (style->used->border_right_color,
style->border->border_right_width);
}
static gboolean
get_opaque_rect (GtkWidget *widget,
const GtkCssStyle *style,
cairo_rectangle_int_t *rect)
{
gboolean is_opaque = gdk_rgba_is_opaque (gtk_css_color_value_get_rgba (style->background->background_color));
gboolean is_opaque;
if (is_opaque && gtk_widget_get_opacity (widget) < 1.0)
if (gtk_widget_get_opacity (widget) < 1)
is_opaque = FALSE;
else
{
GtkCssNode *node;
GtkCssStyle *style;
const GdkRGBA *color;
node = gtk_widget_get_css_node (widget);
style = gtk_css_node_get_style (node);
color = gtk_css_color_value_get_rgba (style->used->background_color);
is_opaque = gdk_rgba_is_opaque (color);
}
if (is_opaque)
{
@@ -429,8 +432,6 @@ gtk_native_update_opaque_region (GtkNative *native,
{
cairo_rectangle_int_t rect;
cairo_region_t *opaque_region = NULL;
const GtkCssStyle *style;
GtkCssNode *css_node;
GdkSurface *surface;
GtkBorder shadow;
@@ -444,17 +445,14 @@ gtk_native_update_opaque_region (GtkNative *native,
!_gtk_widget_get_realized (contents))
return;
css_node = gtk_widget_get_css_node (contents);
if (subtract_shadow)
get_shadow_width (contents, &shadow, resize_handle_size);
else
shadow = (GtkBorder) {0, 0, 0, 0};
surface = gtk_native_get_surface (native);
style = gtk_css_node_get_style (css_node);
if (get_opaque_rect (contents, style, &rect))
if (get_opaque_rect (contents, &rect))
{
double native_x, native_y;
@@ -476,7 +474,12 @@ gtk_native_update_opaque_region (GtkNative *native,
opaque_region = cairo_region_create_rectangle (&rect);
if (subtract_decoration_corners)
subtract_decoration_corners_from_region (opaque_region, &rect, style);
{
GtkCssStyle *style;
style = gtk_css_node_get_style (gtk_widget_get_css_node (contents));
subtract_decoration_corners_from_region (opaque_region, &rect, style);
}
}
gdk_surface_set_opaque_region (surface, opaque_region);
+1 -1
View File
@@ -1627,7 +1627,7 @@ create_arrow_render_node (GtkPopover *popover)
{
const GdkRGBA *border_color;
border_color = gtk_css_color_value_get_rgba (style->border->border_left_color ? style->border->border_left_color : style->core->color);
border_color = gtk_css_color_value_get_rgba (style->used->border_left_color);
gtk_popover_apply_tail_path (popover, cr);
gdk_cairo_set_source_rgba (cr, border_color);
+15 -14
View File
@@ -49,10 +49,11 @@ gtk_theming_background_snapshot_color (GtkCssBoxes *boxes,
const GdkRGBA *bg_color,
guint n_bg_values)
{
GtkCssStyle *style = boxes->style;
const GskRoundedRect *box;
GtkCssArea clip;
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (boxes->style->background->background_clip, n_bg_values - 1));
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (style->background->background_clip, n_bg_values - 1));
box = gtk_css_boxes_get_box (boxes, clip);
if (gsk_rounded_rect_is_rectilinear (box))
@@ -76,7 +77,7 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
guint idx,
GtkSnapshot *snapshot)
{
GtkCssBackgroundValues *background = bg->style->background;
GtkCssStyle *style = bg->style;
GtkCssRepeatStyle hrepeat, vrepeat;
const GtkCssValue *pos, *repeat;
GtkCssImage *image;
@@ -85,17 +86,17 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
double width, height;
double x, y;
image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background->background_image, idx));
image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (style->used->background_image, idx));
if (image == NULL)
return;
pos = _gtk_css_array_value_get_nth (background->background_position, idx);
repeat = _gtk_css_array_value_get_nth (background->background_repeat, idx);
pos = _gtk_css_array_value_get_nth (style->background->background_position, idx);
repeat = _gtk_css_array_value_get_nth (style->background->background_repeat, idx);
origin = gtk_css_boxes_get_box (bg,
_gtk_css_area_value_get (
_gtk_css_array_value_get_nth (background->background_origin, idx)));
_gtk_css_array_value_get_nth (style->background->background_origin, idx)));
width = origin->bounds.size.width;
height = origin->bounds.size.height;
@@ -105,9 +106,9 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
clip = gtk_css_boxes_get_box (bg,
_gtk_css_area_value_get (
_gtk_css_array_value_get_nth (background->background_clip, idx)));
_gtk_css_array_value_get_nth (style->background->background_clip, idx)));
_gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (background->background_size, idx),
_gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (style->background->background_size, idx),
image,
width,
height,
@@ -245,7 +246,7 @@ void
gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
GtkSnapshot *snapshot)
{
const GtkCssBackgroundValues *background = boxes->style->background;
GtkCssStyle *style = boxes->style;
GtkCssValue *background_image;
const GdkRGBA *bg_color;
const GtkCssValue *box_shadow;
@@ -255,12 +256,12 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
int idx;
guint number_of_layers;
if (background->base.type == GTK_CSS_BACKGROUND_INITIAL_VALUES)
if (style->background->base.type == GTK_CSS_BACKGROUND_INITIAL_VALUES)
return;
background_image = background->background_image;
bg_color = gtk_css_color_value_get_rgba (background->background_color);
box_shadow = background->box_shadow;
background_image = style->used->background_image;
bg_color = gtk_css_color_value_get_rgba (style->used->background_color);
box_shadow = style->used->box_shadow;
has_bg_color = !gdk_rgba_is_clear (bg_color);
has_bg_image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) != NULL;
@@ -281,7 +282,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
if (has_bg_image)
{
GtkCssValue *blend_modes = background->background_blend_mode;
GtkCssValue *blend_modes = style->background->background_blend_mode;
GskBlendMode *blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers);
for (idx = number_of_layers - 1; idx >= 0; idx--)
+27 -26
View File
@@ -569,7 +569,7 @@ snapshot_border (GtkSnapshot *snapshot,
else
dont_draw |= (1 << j);
}
snapshot_frame_stroke (snapshot, border_box, border_width, colors, dont_draw, border_style[i]);
}
break;
@@ -647,22 +647,22 @@ void
gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
GtkSnapshot *snapshot)
{
const GtkCssBorderValues *border = boxes->style->border;
GtkCssStyle *style = boxes->style;
GtkBorderImage border_image;
float border_width[4];
if (border->base.type == GTK_CSS_BORDER_INITIAL_VALUES)
if (style->border->base.type == GTK_CSS_BORDER_INITIAL_VALUES)
return;
if (gtk_border_image_init (&border_image, boxes->style))
if (gtk_border_image_init (&border_image, style))
{
cairo_t *cr;
const graphene_rect_t *bounds;
border_width[0] = gtk_css_number_value_get (border->border_top_width, 100);
border_width[1] = gtk_css_number_value_get (border->border_right_width, 100);
border_width[2] = gtk_css_number_value_get (border->border_bottom_width, 100);
border_width[3] = gtk_css_number_value_get (border->border_left_width, 100);
border_width[0] = gtk_css_number_value_get (style->border->border_top_width, 100);
border_width[1] = gtk_css_number_value_get (style->border->border_right_width, 100);
border_width[2] = gtk_css_number_value_get (style->border->border_bottom_width, 100);
border_width[3] = gtk_css_number_value_get (style->border->border_left_width, 100);
bounds = gtk_css_boxes_get_border_rect (boxes);
@@ -683,24 +683,24 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
gtk_css_boxes_get_padding_rect (boxes)))
return;
colors[0] = *gtk_css_color_value_get_rgba (border->border_top_color ? border->border_top_color : boxes->style->core->color);
colors[1] = *gtk_css_color_value_get_rgba (border->border_right_color ? border->border_right_color : boxes->style->core->color);
colors[2] = *gtk_css_color_value_get_rgba (border->border_bottom_color ? border->border_bottom_color : boxes->style->core->color);
colors[3] = *gtk_css_color_value_get_rgba (border->border_left_color ? border->border_left_color : boxes->style->core->color);
colors[0] = *gtk_css_color_value_get_rgba (style->used->border_top_color);
colors[1] = *gtk_css_color_value_get_rgba (style->used->border_right_color);
colors[2] = *gtk_css_color_value_get_rgba (style->used->border_bottom_color);
colors[3] = *gtk_css_color_value_get_rgba (style->used->border_left_color);
alpha_test_vector = graphene_simd4f_init (colors[0].alpha, colors[1].alpha, colors[2].alpha, colors[3].alpha);
if (graphene_simd4f_is_zero4 (alpha_test_vector))
return;
border_style[0] = _gtk_css_border_style_value_get (border->border_top_style);
border_style[1] = _gtk_css_border_style_value_get (border->border_right_style);
border_style[2] = _gtk_css_border_style_value_get (border->border_bottom_style);
border_style[3] = _gtk_css_border_style_value_get (border->border_left_style);
border_style[0] = _gtk_css_border_style_value_get (style->border->border_top_style);
border_style[1] = _gtk_css_border_style_value_get (style->border->border_right_style);
border_style[2] = _gtk_css_border_style_value_get (style->border->border_bottom_style);
border_style[3] = _gtk_css_border_style_value_get (style->border->border_left_style);
border_width[0] = gtk_css_number_value_get (border->border_top_width, 100);
border_width[1] = gtk_css_number_value_get (border->border_right_width, 100);
border_width[2] = gtk_css_number_value_get (border->border_bottom_width, 100);
border_width[3] = gtk_css_number_value_get (border->border_left_width, 100);
border_width[0] = gtk_css_number_value_get (style->border->border_top_width, 100);
border_width[1] = gtk_css_number_value_get (style->border->border_right_width, 100);
border_width[2] = gtk_css_number_value_get (style->border->border_bottom_width, 100);
border_width[3] = gtk_css_number_value_get (style->border->border_left_width, 100);
gtk_snapshot_push_debug (snapshot, "CSS border");
if (border_style[0] <= GTK_BORDER_STYLE_SOLID &&
@@ -730,21 +730,22 @@ void
gtk_css_style_snapshot_outline (GtkCssBoxes *boxes,
GtkSnapshot *snapshot)
{
GtkCssOutlineValues *outline = boxes->style->outline;
GtkCssStyle *style = boxes->style;
GtkBorderStyle border_style[4];
float border_width[4];
GdkRGBA colors[4];
border_style[0] = _gtk_css_border_style_value_get (outline->outline_style);
border_style[0] = _gtk_css_border_style_value_get (style->outline->outline_style);
if (border_style[0] != GTK_BORDER_STYLE_NONE)
{
const GdkRGBA *color = gtk_css_color_value_get_rgba (outline->outline_color ?
outline->outline_color :
boxes->style->core->color);
const GdkRGBA *color;
color = gtk_css_color_value_get_rgba (style->used->outline_color);
if (gdk_rgba_is_clear (color))
return;
border_width[0] = gtk_css_number_value_get (outline->outline_width, 100);
border_width[0] = gtk_css_number_value_get (style->outline->outline_width, 100);
if (G_APPROX_VALUE (border_width[0], 0, FLT_EPSILON))
return;
+9 -9
View File
@@ -35,22 +35,22 @@
#include <math.h>
void
gtk_css_style_snapshot_icon (GtkCssStyle *style,
GtkSnapshot *snapshot,
double width,
double height)
gtk_css_style_snapshot_icon (GtkCssStyle *style,
GtkSnapshot *snapshot,
double width,
double height)
{
GskTransform *transform;
GtkCssImage *image;
gboolean has_shadow;
g_return_if_fail (GTK_IS_CSS_STYLE (style));
g_return_if_fail (style != NULL);
g_return_if_fail (snapshot != NULL);
if (width == 0.0 || height == 0.0)
return;
image = _gtk_css_image_value_get_image (style->other->icon_source);
image = _gtk_css_image_value_get_image (style->used->icon_source);
if (image == NULL)
return;
@@ -60,7 +60,7 @@ gtk_css_style_snapshot_icon (GtkCssStyle *style,
gtk_css_filter_value_push_snapshot (style->other->icon_filter, snapshot);
has_shadow = gtk_css_shadow_value_push_snapshot (style->icon->icon_shadow, snapshot);
has_shadow = gtk_css_shadow_value_push_snapshot (style->used->icon_shadow, snapshot);
if (transform == NULL)
{
@@ -102,7 +102,7 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
gboolean is_symbolic_paintable;
GdkRGBA colors[4];
g_return_if_fail (GTK_IS_CSS_STYLE (style));
g_return_if_fail (style != NULL);
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GDK_IS_PAINTABLE (paintable));
g_return_if_fail (width > 0);
@@ -112,7 +112,7 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
gtk_css_filter_value_push_snapshot (style->other->icon_filter, snapshot);
has_shadow = gtk_css_shadow_value_push_snapshot (style->icon->icon_shadow, snapshot);
has_shadow = gtk_css_shadow_value_push_snapshot (style->used->icon_shadow, snapshot);
is_symbolic_paintable = GTK_IS_SYMBOLIC_PAINTABLE (paintable);
if (is_symbolic_paintable)
+8 -7
View File
@@ -47,8 +47,9 @@ gtk_css_style_snapshot_layout (GtkCssBoxes *boxes,
}
style = boxes->style;
color = gtk_css_color_value_get_rgba (style->core->color);
has_shadow = gtk_css_shadow_value_push_snapshot (style->font->text_shadow, snapshot);
color = gtk_css_color_value_get_rgba (style->used->color);
has_shadow = gtk_css_shadow_value_push_snapshot (style->used->text_shadow, snapshot);
gtk_snapshot_append_layout (snapshot, layout, color);
@@ -187,12 +188,12 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
PangoDirection direction,
gboolean draw_arrow)
{
GdkRGBA color;
const GdkRGBA *color;
if (is_primary)
color = *gtk_css_color_value_get_rgba (style->font->caret_color ? style->font->caret_color : style->core->color);
color = gtk_css_color_value_get_rgba (style->used->caret_color);
else
color = *gtk_css_color_value_get_rgba (style->font->secondary_caret_color ? style->font->secondary_caret_color : style->core->color);
color = gtk_css_color_value_get_rgba (style->used->secondary_caret_color);
if (width != 0 || draw_arrow)
{
@@ -202,7 +203,7 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
get_insertion_cursor_bounds (width, height, aspect_ratio, direction, draw_arrow, &bounds);
cr = gtk_snapshot_append_cairo (snapshot, &bounds);
draw_insertion_cursor (cr, 0, 0, width, height, aspect_ratio, &color, direction, draw_arrow);
draw_insertion_cursor (cr, 0, 0, width, height, aspect_ratio, color, direction, draw_arrow);
cairo_destroy (cr);
}
@@ -220,7 +221,7 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
offset = stem_width - stem_width / 2;
gtk_snapshot_append_color (snapshot,
&color,
color,
&GRAPHENE_RECT_INIT (- offset, 0, stem_width, height));
}
}
+1 -1
View File
@@ -4834,7 +4834,7 @@ gtk_text_draw_cursor (GtkText *self,
gtk_css_boxes_init_border_box (&boxes, style, 0, 0, width, height);
gtk_snapshot_push_clip (snapshot, &bounds);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_layout (&boxes,snapshot, x, y, layout);
gtk_css_style_snapshot_layout (&boxes, snapshot, x, y, layout);
gtk_snapshot_pop (snapshot);
}
+18 -12
View File
@@ -4030,8 +4030,9 @@ render_para (GskPangoRenderer *crenderer,
(line_display->insert_index < byte_offset + pango_layout_line_get_length (line) ||
(at_last_line && line_display->insert_index == byte_offset + pango_layout_line_get_length (line))))
{
GtkCssNode *node;
GtkCssStyle *style;
GdkRGBA cursor_color;
const GdkRGBA *cursor_color;
graphene_rect_t bounds = {
.origin.x = line_display->x_offset + line_display->block_cursor.x,
.origin.y = line_display->block_cursor.y + line_display->top_margin,
@@ -4042,11 +4043,13 @@ render_para (GskPangoRenderer *crenderer,
/* we draw text using base color on filled cursor rectangle
* of cursor color (normally white on black)
*/
style = gtk_css_node_get_style (gtk_widget_get_css_node (crenderer->widget));
cursor_color = *gtk_css_color_value_get_rgba (style->font->caret_color ? style->font->caret_color : style->core->color);
node = gtk_widget_get_css_node (crenderer->widget);
style = gtk_css_node_get_style (node);
cursor_color = gtk_css_color_value_get_rgba (style->used->caret_color);
gtk_snapshot_push_opacity (crenderer->snapshot, cursor_alpha);
gtk_snapshot_append_color (crenderer->snapshot, &cursor_color, &bounds);
gtk_snapshot_append_color (crenderer->snapshot, cursor_color, &bounds);
/* draw text under the cursor if any */
if (!line_display->cursor_at_line_end)
@@ -4101,11 +4104,12 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
gboolean have_selection;
gboolean draw_selection_text;
const GdkRGBA *selection;
GdkRGBA color;
const GdkRGBA *color;
GtkSnapshot *cursor_snapshot;
GtkTextBTree *btree;
GtkTextLine *first_line;
GtkTextLine *last_line;
GtkCssNode *node;
GtkCssStyle *style;
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
@@ -4128,8 +4132,10 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
if (last_line == NULL)
last_line = _gtk_text_btree_get_end_iter_line (btree);
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
color = *gtk_css_color_value_get_rgba (style->core->color);
node = gtk_widget_get_css_node (widget);
style = gtk_css_node_get_style (node);
color = gtk_css_color_value_get_rgba (style->used->color);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (0, offset_y));
offset_y = 0;
@@ -4142,7 +4148,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
crenderer->widget = widget;
crenderer->snapshot = snapshot;
crenderer->fg_color = &color;
crenderer->fg_color = color;
have_selection = gtk_text_buffer_get_selection_bounds (layout->buffer,
&selection_start,
@@ -4150,7 +4156,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
if (have_selection)
{
GtkCssNode *selection_node;
GdkRGBA text_color;
const GdkRGBA *text_color;
selection_start_line = gtk_text_iter_get_line (&selection_start);
selection_end_line = gtk_text_iter_get_line (&selection_end);
@@ -4158,10 +4164,10 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
selection_node = gtk_text_view_get_selection_node ((GtkTextView*)widget);
style = gtk_css_node_get_style (selection_node);
selection = gtk_css_color_value_get_rgba (style->background->background_color);
text_color = *gtk_css_color_value_get_rgba (style->core->color);
selection = gtk_css_color_value_get_rgba (style->used->background_color);
text_color = gtk_css_color_value_get_rgba (style->used->color);
draw_selection_text = text_color.alpha > 0;
draw_selection_text = text_color->alpha > 0;
}
else
{
+3 -3
View File
@@ -132,7 +132,7 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
snapshot = gtk_snapshot_new ();
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
color = gtk_css_color_value_get_rgba (style->core->color);
color = gtk_css_color_value_get_rgba (style->used->color);
display = gtk_widget_get_display (widget);
@@ -179,8 +179,8 @@ set_attributes_from_style (GtkWidget *widget,
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
*values->appearance.bg_rgba = *gtk_css_color_value_get_rgba (style->background->background_color);
*values->appearance.fg_rgba = *gtk_css_color_value_get_rgba (style->core->color);
*values->appearance.bg_rgba = *gtk_css_color_value_get_rgba (style->used->background_color);
*values->appearance.fg_rgba = *gtk_css_color_value_get_rgba (style->used->color);
if (values->font)
pango_font_description_free (values->font);
+4 -10
View File
@@ -7836,7 +7836,6 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
{
GtkCssStyle *style;
const GdkRGBA black = { 0, };
const GdkRGBA *color;
const GdkRGBA *decoration_color;
GtkTextDecorationLine decoration_line;
GtkTextDecorationStyle decoration_style;
@@ -7846,12 +7845,10 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
if (!values->appearance.fg_rgba)
values->appearance.fg_rgba = gdk_rgba_copy (&black);
style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (text_view)));
style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (text_view)));;
color = gtk_css_color_value_get_rgba (style->background->background_color);
*values->appearance.bg_rgba = *color;
color = gtk_css_color_value_get_rgba (style->core->color);
*values->appearance.fg_rgba = *color;
*values->appearance.bg_rgba = *gtk_css_color_value_get_rgba (style->used->background_color);
*values->appearance.fg_rgba = *gtk_css_color_value_get_rgba (style->used->color);
if (values->font)
pango_font_description_free (values->font);
@@ -7862,9 +7859,7 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
decoration_color = gtk_css_color_value_get_rgba (style->font_variant->text_decoration_color
? style->font_variant->text_decoration_color
: style->core->color);
decoration_color = gtk_css_color_value_get_rgba (style->used->text_decoration_color);
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE)
{
@@ -7925,7 +7920,6 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
values->letter_spacing = gtk_css_number_value_get (style->font->letter_spacing, 100) * PANGO_SCALE;
/* line-height */
values->line_height = gtk_css_line_height_value_get (style->font->line_height);
values->line_height_is_absolute = FALSE;
if (values->line_height != 0.0)
+1 -1
View File
@@ -13172,7 +13172,7 @@ gtk_widget_get_color (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget));
style = gtk_css_node_get_style (priv->cssnode);
*color = *gtk_css_color_value_get_rgba (style->core->color);
*color = *gtk_css_color_value_get_rgba (style->used->color);
}
/*< private >
+4 -2
View File
@@ -2425,14 +2425,16 @@ draw_page (GtkDrawingArea *da,
}
style = gtk_css_node_get_style (dialog->page_layout_paper_node);
color = *gtk_css_color_value_get_rgba (style->core->color);
color = *gtk_css_color_value_get_rgba (style->used->color);
pos_x = (width - w) / 2;
pos_y = (height - h) / 2 - 10;
cairo_translate (cr, pos_x, pos_y);
snapshot = gtk_snapshot_new ();
gtk_css_boxes_init_border_box (&boxes, style, 1, 1, w, h);
gtk_css_boxes_init_border_box (&boxes,
gtk_css_node_get_style (dialog->page_layout_paper_node),
1, 1, w, h);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
+11
View File
@@ -0,0 +1,11 @@
.a {
color: red;
}
.b {
color: mix(blue, currentcolor, 0.5);
}
.c {
background-color: currentcolor;
}
+9
View File
@@ -0,0 +1,9 @@
window.a:dir(ltr)
color: rgb(255,0,0); /* currentcolor2.css:2:3-14 */
box.b:dir(ltr)
color: rgb(128,0,128); /* currentcolor2.css:6:3-39 */
label.c:dir(ltr)
color: rgb(64,0,191);
background-color: rgb(64,0,191); /* currentcolor2.css:10:3-34 */
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="decorated">0</property>
<property name="css-classes">a</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="css-classes">b</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Hello World!</property>
<property name="css-classes">c</property>
</object>
</child>
</object>
</child>
</object>
</interface>
+8
View File
@@ -0,0 +1,8 @@
entry {
caret-color: mix(currentcolor, yellow, 0.4);
color: blue;
}
text {
color: red;
}
+13
View File
@@ -0,0 +1,13 @@
window.background:dir(ltr)
entry:dir(ltr)
color: rgb(0,0,255); /* currentcolor3.css:3:3-15 */
caret-color: rgb(102,102,153); /* currentcolor3.css:2:3-47 */
text:dir(ltr)
color: rgb(255,0,0); /* currentcolor3.css:7:3-14 */
caret-color: rgb(255,102,0);
undershoot.left:dir(ltr)
caret-color: rgb(255,102,0);
undershoot.right:dir(ltr)
caret-color: rgb(255,102,0);
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="decorated">0</property>
<child>
<object class="GtkEntry">
<property name="visible">True</property>
<property name="text" translatable="yes">Hello World!</property>
</object>
</child>
</object>
</interface>
+6 -3
View File
@@ -54,11 +54,14 @@ value_is_near (int prop,
break;
case GTK_CSS_PROPERTY_ICON_PALETTE:
return color_is_near (gtk_css_palette_value_get_color (value1, "error"),
return value_is_near (GTK_CSS_PROPERTY_COLOR,
gtk_css_palette_value_get_color (value1, "error"),
gtk_css_palette_value_get_color (value2, "error")) &&
color_is_near (gtk_css_palette_value_get_color (value1, "warning"),
value_is_near (GTK_CSS_PROPERTY_COLOR,
gtk_css_palette_value_get_color (value1, "warning"),
gtk_css_palette_value_get_color (value2, "warning")) &&
color_is_near (gtk_css_palette_value_get_color (value1, "test"),
value_is_near (GTK_CSS_PROPERTY_COLOR,
gtk_css_palette_value_get_color (value1, "test"),
gtk_css_palette_value_get_color (value2, "test"));
break;