[gtk+/composite-templates] cssimage: Add transition code for linear-gradient()
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/composite-templates] cssimage: Add transition code for linear-gradient()
- Date: Sat, 6 Oct 2012 17:12:37 +0000 (UTC)
commit 04313f7f8f12a5b2cd4ea277a876597435fee074
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 2 19:30:02 2012 +0200
cssimage: Add transition code for linear-gradient()
This ensures feature-parity with the CSS spec and the -gtk-gradient()
notation.
gtk/gtkcssimagelinear.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c
index 39b6b3e..bd80d5f 100644
--- a/gtk/gtkcssimagelinear.c
+++ b/gtk/gtkcssimagelinear.c
@@ -451,6 +451,80 @@ gtk_css_image_linear_compute (GtkCssImage *image,
return GTK_CSS_IMAGE (copy);
}
+static GtkCssImage *
+gtk_css_image_linear_transition (GtkCssImage *start_image,
+ GtkCssImage *end_image,
+ guint property_id,
+ double progress)
+{
+ GtkCssImageLinear *start, *end, *result;
+ guint i;
+
+ start = GTK_CSS_IMAGE_LINEAR (start_image);
+
+ if (end_image == NULL)
+
+ if (!GTK_IS_CSS_IMAGE_LINEAR (end_image))
+ return GTK_CSS_IMAGE_CLASS (_gtk_css_image_linear_parent_class)->transition (start_image, end_image, property_id, progress);
+
+ end = GTK_CSS_IMAGE_LINEAR (end_image);
+
+ if ((start->repeating != end->repeating)
+ || (start->stops->len != end->stops->len))
+ return GTK_CSS_IMAGE_CLASS (_gtk_css_image_linear_parent_class)->transition (start_image, end_image, property_id, progress);
+
+ result = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
+ result->repeating = start->repeating;
+
+ result->angle = _gtk_css_value_transition (start->angle, end->angle, property_id, progress);
+ if (result->angle == NULL)
+ goto fail;
+
+ for (i = 0; i < start->stops->len; i++)
+ {
+ GtkCssImageLinearColorStop stop, *start_stop, *end_stop;
+
+ start_stop = &g_array_index (start->stops, GtkCssImageLinearColorStop, i);
+ end_stop = &g_array_index (end->stops, GtkCssImageLinearColorStop, i);
+
+ if ((start_stop->offset != NULL) != (end_stop->offset != NULL))
+ goto fail;
+
+ if (start_stop->offset == NULL)
+ {
+ stop.offset = NULL;
+ }
+ else
+ {
+ stop.offset = _gtk_css_value_transition (start_stop->offset,
+ end_stop->offset,
+ property_id,
+ progress);
+ if (stop.offset == NULL)
+ goto fail;
+ }
+
+ stop.color = _gtk_css_value_transition (start_stop->color,
+ end_stop->color,
+ property_id,
+ progress);
+ if (stop.color == NULL)
+ {
+ if (stop.offset)
+ _gtk_css_value_unref (stop.offset);
+ goto fail;
+ }
+
+ g_array_append_val (result->stops, stop);
+ }
+
+ return GTK_CSS_IMAGE (result);
+
+fail:
+ g_object_unref (result);
+ return GTK_CSS_IMAGE_CLASS (_gtk_css_image_linear_parent_class)->transition (start_image, end_image, property_id, progress);
+}
+
static void
gtk_css_image_linear_dispose (GObject *object)
{
@@ -481,6 +555,7 @@ _gtk_css_image_linear_class_init (GtkCssImageLinearClass *klass)
image_class->parse = gtk_css_image_linear_parse;
image_class->print = gtk_css_image_linear_print;
image_class->compute = gtk_css_image_linear_compute;
+ image_class->transition = gtk_css_image_linear_transition;
object_class->dispose = gtk_css_image_linear_dispose;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]