summaryrefslogtreecommitdiff
path: root/gtk/gtkcssarrayvalue.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-02-18 00:14:48 +0100
committerBenjamin Otte <otte@redhat.com>2018-03-16 06:04:44 +0100
commit7e39b128581de126dc8ebfc8527801f9e4a12c03 (patch)
treea9ba5b7f17c3f4e5ebb56d30e5bdfd4e24f1e6c7 /gtk/gtkcssarrayvalue.c
parent3faa7e04dbc69ec8f5a60f7bcc18c1b701796137 (diff)
downloadgtk+-7e39b128581de126dc8ebfc8527801f9e4a12c03.tar.gz
css: Implement dynamic values for array values
This makes animated background-images work.
Diffstat (limited to 'gtk/gtkcssarrayvalue.c')
-rw-r--r--gtk/gtkcssarrayvalue.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/gtk/gtkcssarrayvalue.c b/gtk/gtkcssarrayvalue.c
index 221632e059..d294d90892 100644
--- a/gtk/gtkcssarrayvalue.c
+++ b/gtk/gtkcssarrayvalue.c
@@ -298,6 +298,56 @@ gtk_css_value_array_transition (GtkCssValue *start,
}
}
+static gboolean
+gtk_css_value_array_is_dynamic (GtkCssValue *value)
+{
+ guint i;
+
+ for (i = 0; i < value->n_values; i++)
+ {
+ if (gtk_css_value_is_dynamic (value->values[i]))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static GtkCssValue *
+gtk_css_value_array_get_dynamic_value (GtkCssValue *value,
+ gint64 monotonic_time)
+{
+ GtkCssValue *result;
+ GtkCssValue *i_value;
+ guint i, j;
+
+ if (!gtk_css_value_is_dynamic (value))
+ return gtk_css_value_ref (value);
+
+ result = NULL;
+ for (i = 0; i < value->n_values; i++)
+ {
+ i_value = gtk_css_value_get_dynamic_value (value->values[i], monotonic_time);
+
+ if (result == NULL &&
+ i_value != value->values[i])
+ {
+ result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
+ for (j = 0; j < i; j++)
+ _gtk_css_value_ref (result->values[j]);
+ }
+
+ if (result != NULL)
+ result->values[i] = i_value;
+ else
+ _gtk_css_value_unref (i_value);
+ }
+
+ if (result == NULL)
+ return _gtk_css_value_ref (value);
+
+ return result;
+}
+
static void
gtk_css_value_array_print (const GtkCssValue *value,
GString *string)
@@ -323,8 +373,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_ARRAY = {
gtk_css_value_array_compute,
gtk_css_value_array_equal,
gtk_css_value_array_transition,
- NULL,
- NULL,
+ gtk_css_value_array_is_dynamic,
+ gtk_css_value_array_get_dynamic_value,
gtk_css_value_array_print
};