[gegl] gegl: serialize, handle animated integer properties



commit 871e0c40c5ee7d21bd712d090b1664e51cd244d0
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Aug 11 00:59:28 2017 +0200

    gegl: serialize, handle animated integer properties

 gegl/gegl-serialize.c |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/gegl/gegl-serialize.c b/gegl/gegl-serialize.c
index a593fbd..b046459 100644
--- a/gegl/gegl-serialize.c
+++ b/gegl/gegl-serialize.c
@@ -155,17 +155,29 @@ gegl_create_chain_argv (char      **ops,
                 time = 0.001;
               gegl_path_calc_y_for_x (g_object_get_qdata (G_OBJECT (new),
                                       anim_quark), time, &y);
-              /* TODO: switch on int/double, thus permitting animating ints */
+
               {
-                GParamSpecDouble *spec = (void*)gegl_operation_find_property (
-                                gegl_node_get_operation (new),
-                                prop);
-                if (y < spec->minimum)
-                  y = spec->minimum;
-                if (y > spec->maximum)
-                  y = spec->maximum;
+                GParamSpec *pspec = gegl_operation_find_property (gegl_node_get_operation (new), prop);
+
+                if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
+                {
+                  GParamSpecDouble *double_spec = (void*)pspec;
+                  if (y <= double_spec->minimum)
+                    y = double_spec->minimum;
+                  if (y >= double_spec->maximum)
+                    y = double_spec->maximum;
+                  gegl_node_set (new, prop, y, NULL);
+                }
+                else if (GEGL_IS_PARAM_SPEC_INT (pspec))
+                {
+                  GParamSpecInt *int_spec = (void*)pspec;
+                  if (y <= int_spec->minimum)
+                    y = int_spec->minimum;
+                  if (y >= int_spec->maximum)
+                    y = int_spec->maximum;
+                  gegl_node_set (new, prop, (int)(y), NULL);
+                }
               }
-              gegl_node_set (new, prop, y, NULL);
 
               in_keyframes = 0;
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]