[gtk/wip/baedert/css-values: 3/6] cssdimensionvalue: Implement transition()
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values: 3/6] cssdimensionvalue: Implement transition()
- Date: Tue, 14 Jan 2020 16:34:39 +0000 (UTC)
commit ada5ff8a91e1935a16acd1682a67c63e1bde9cdc
Author: Timm Bäder <mail baedert org>
Date: Tue Jan 14 15:35:38 2020 +0100
cssdimensionvalue: Implement transition()
Instead of falling back to the generic gtk_css_number_value_transition
(which can allocate multiple new css values), just implement this here.
gtk/gtkcssdimensionvalue.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcssdimensionvalue.c b/gtk/gtkcssdimensionvalue.c
index b50d377e84..0ba4ca9550 100644
--- a/gtk/gtkcssdimensionvalue.c
+++ b/gtk/gtkcssdimensionvalue.c
@@ -243,13 +243,34 @@ gtk_css_value_dimension_get_calc_term_order (const GtkCssValue *value)
return 1000 + order_per_unit[value->unit];
}
+static GtkCssValue *
+gtk_css_value_dimension_transition (GtkCssValue *start,
+ GtkCssValue *end,
+ guint property_id,
+ double progress)
+{
+ if (progress == 0)
+ return _gtk_css_value_ref (start);
+
+ if (progress == 1)
+ return _gtk_css_value_ref (end);
+
+ if (start == end)
+ return _gtk_css_value_ref (start);
+
+ if (start->unit != end->unit)
+ return NULL;
+
+ return gtk_css_dimension_value_new (start->value + (end->value - start->value) * progress, start->unit);
+}
+
static const GtkCssNumberValueClass GTK_CSS_VALUE_DIMENSION = {
{
"GtkCssDimensionValue",
gtk_css_value_dimension_free,
gtk_css_value_dimension_compute,
gtk_css_value_dimension_equal,
- gtk_css_number_value_transition,
+ gtk_css_value_dimension_transition,
NULL,
NULL,
gtk_css_value_dimension_print
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]