[gegl] scale-ratio: use gegl-op.h instead of custom chant



commit 4a28a57ec95d74887e751b25169701da9abf9b12
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Mar 3 14:54:46 2017 +0100

    scale-ratio: use gegl-op.h instead of custom chant

 operations/transform/module.c      |    4 +-
 operations/transform/scale-ratio.c |   58 ++++++++++++++++++++++++++++--------
 2 files changed, 47 insertions(+), 15 deletions(-)
---
diff --git a/operations/transform/module.c b/operations/transform/module.c
index 2270b53..61292c4 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.c
@@ -42,7 +42,7 @@ gegl_module_query (GTypeModule *module)
 GType gegl_op_rotate_register_type (GTypeModule *module);
 GType gegl_op_rotate_on_center_register_type (GTypeModule *module);
 GType gegl_op_reflect_register_type (GTypeModule *module);
-GType scale_ratio_get_type  (void);
+GType gegl_op_scale_ratio_register_type  (GTypeModule *module);
 GType scale_size_get_type   (void);
 GType scale_size_keepaspect_get_type   (void);
 GType shear_get_type       (void);
@@ -58,12 +58,12 @@ gegl_module_register (GTypeModule *module)
   transform_module = module;
 
   dummy = op_transform_get_type ();
-  dummy = scale_ratio_get_type ();
   dummy = scale_size_get_type ();
   dummy = scale_size_keepaspect_get_type ();
   dummy = shear_get_type ();
   dummy = translate_get_type ();
   dummy = transform_get_type ();
+  dummy = gegl_op_scale_ratio_register_type (module);
   dummy = gegl_op_rotate_register_type (module);
   dummy = gegl_op_reflect_register_type (module);
   dummy = gegl_op_rotate_on_center_register_type (module);
diff --git a/operations/transform/scale-ratio.c b/operations/transform/scale-ratio.c
index b5c32e3..5077e26 100644
--- a/operations/transform/scale-ratio.c
+++ b/operations/transform/scale-ratio.c
@@ -14,35 +14,67 @@
  * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
  *
  * Copyright 2006 Philip Lafleur
+ *           2017 Øyvind Kolås
  */
 
 #include "config.h"
 #include <glib/gi18n-lib.h>
 
+#ifdef GEGL_PROPERTIES
 
-#ifdef GEGL_CHANT_PROPERTIES
+property_double (x, _("X"), 0.0)
+    description (_("Horizontal scale factor"))
+    ui_range (0.0, 20.0)
+    value_range (-9000.0, 9000.0)
 
-gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 1.0,
-                   _("Horizontal scale factor"))
-gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 1.0,
-                   _("Vertical scale factor"))
+property_double (y, _("Y"), 0.0)
+    description (_("Vertical scale factor"))
+    ui_range (0.0, 20.0)
+    value_range (-9000.0, 9000.0)
 
 #else
 
-#define GEGL_CHANT_NAME scale_ratio
-#define GEGL_CHANT_OPERATION_NAME "gegl:scale-ratio"
-#define GEGL_CHANT_DESCRIPTION _("Scales the buffer according to a ratio.")
-#define GEGL_CHANT_SELF "scale-ratio.c"
-#include "chant.h"
+#include "gegl-operation-filter.h"
+#include "transform-core.h"
+#define GEGL_OP_NO_SOURCE
+#define GEGL_OP_Parent  OpTransform
+#define GEGL_OP_PARENT  TYPE_OP_TRANSFORM
+#define GEGL_OP_NAME    scale_ratio
+#define GEGL_OP_BUNDLE
+#define GEGL_OP_C_FILE  "scale-ratio.c"
+
+#include "gegl-op.h"
+
+#include <math.h>
 
 static void
 create_matrix (OpTransform *op,
                GeglMatrix3 *matrix)
 {
-  GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+  GeglProperties *o = GEGL_PROPERTIES (op);
+
+  matrix->coeff [0][0] = o->x;
+  matrix->coeff [1][1] = o->y;
+}
+
+#include <stdio.h>
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+  GeglOperationClass *operation_class;
+  OpTransformClass   *transform_class;
+
+  operation_class = GEGL_OPERATION_CLASS (klass);
+  transform_class = OP_TRANSFORM_CLASS (klass);
+  transform_class->create_matrix = create_matrix;
 
-  matrix->coeff [0][0] = chant->x;
-  matrix->coeff [1][1] = chant->y;
+  gegl_operation_class_set_keys (operation_class,
+    "name", "gegl:scale-ratio",
+    "title", _("Scale ratio"),
+    "categories", "transform",
+    "description", _("Scales the buffer according to a ratio."),
+    NULL);
 }
 
 #endif


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