[gegl] ops: migrate more ops to macro based property meta-data



commit 32f9dd53dcd0e1924515f67082abd0561854c394
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue May 20 20:27:48 2014 +0200

    ops: migrate more ops to macro based property meta-data

 operations/common/mosaic.c               |  130 +++++++++++++-----------------
 operations/common/motion-blur-circular.c |   31 +++----
 operations/common/motion-blur-linear.c   |   23 +++---
 operations/common/motion-blur-zoom.c     |   34 ++++-----
 operations/common/noise-cell.c           |   55 +++++++-----
 operations/common/noise-cie-lch.c        |   23 +++---
 operations/common/noise-hsv.c            |   22 ++---
 operations/common/noise-hurl.c           |   12 +--
 operations/common/noise-perlin.c         |   38 +++++----
 operations/common/noise-pick.c           |   12 +--
 operations/common/noise-reduction.c      |    9 +-
 11 files changed, 180 insertions(+), 209 deletions(-)
---
diff --git a/operations/common/mosaic.c b/operations/common/mosaic.c
index 25e68a6..f02b26d 100644
--- a/operations/common/mosaic.c
+++ b/operations/common/mosaic.c
@@ -29,83 +29,63 @@
 #ifdef GEGL_PROPERTIES
 
 enum_start (gegl_mosaic_tile)
-  enum_value (GEGL_MOSAIC_TILE_SQUARES,   "SQUARES")
-  enum_value (GEGL_MOSAIC_TILE_HEXAGONS,  "HEXAGONS")
-  enum_value (GEGL_MOSAIC_TILE_OCTAGONS,  "OCTAGONS")
-  enum_value (GEGL_MOSAIC_TILE_TRIANGLES, "TRIANGLES")
+  enum_value (GEGL_MOSAIC_TILE_SQUARES,   "Squares")
+  enum_value (GEGL_MOSAIC_TILE_HEXAGONS,  "Hexagons")
+  enum_value (GEGL_MOSAIC_TILE_OCTAGONS,  "Octagons")
+  enum_value (GEGL_MOSAIC_TILE_TRIANGLES, "Triangles")
 enum_end (GeglMosaicTile)
 
-gegl_property_enum (tile_type, _("Tile geometry"),
-    GeglMosaicTile, gegl_mosaic_tile,
-    "description", _("What shape to use for tiles"),
-    "default", GEGL_MOSAIC_TILE_HEXAGONS,
-    NULL)
-
-gegl_property_double (tile_size, _("Tile size"),
-    "description", _("Average diameter of each tile (in pixels)"),
-    "default", 15.0, "min", 1.0, "max", 1000.0,
-    "ui-min", 5.0, "ui-max", 400.0,
-    "unit", "pixel-distance",
-    NULL)
-
-gegl_property_double (tile_height, _("Tile height"),
-    "description", _("Apparent height of each tile (in pixels)"),
-    "default", 4.0,
-    "min", 1.0, "max", 1000.0,
-    "ui-min", 1.0, "ui-max", 20.0,
-    "unit", "pixel-distance",
-    NULL)
-
-gegl_property_double (tile_neatness, _("Tile neatness"),
-    "description", _("Deviation from perfectly formed tiles"),
-    "default", 0.65, "min", 0.0, "max", 1.0,
-    NULL)
-
-gegl_property_double (color_variation, _("Tile color variation"),
-    "description", _("Magnitude of random color variations"),
-    "default", 0.2, "min", 0.0, "max", 1.0,
-    NULL)
-
-gegl_property_boolean (color_averaging, _("Color averaging"),
-    "description", _("Tile color based on average of subsumed pixels"),
-    "default", TRUE,
-    NULL)
-
-gegl_property_boolean (tile_surface, _("Rough tile surface"),
-    "description", _("Surface characteristics"), NULL)
-
-gegl_property_boolean (tile_allow_split, _("Allow splitting tiles"),
-    "description", _("Allows splitting tiles at hard edges"),
-    "default", TRUE,
-    NULL)
-
-gegl_property_double (tile_spacing, _("Tile spacing"),
-    "description", _("Inter-tile spacing (in pixels)"),
-    "default", 1.0, "min", 0.0, "max", 1000.0,
-    "ui-min", 0.5, "ui-max", 30.0,
-    "unit", "pixel-distance",
-    NULL)
-
-gegl_property_color (joints_color, _("Joints color"),
-    "default", "black",
-    NULL)
-
-gegl_property_color (light_color, _("Light color"),
-    "default", "white",
-    NULL)
-
-gegl_property_double (light_dir, _("Light direction"),
-    "description", _("Direction of light-source (in degrees)"),
-    "default", 135.0, "min", 0.0, "max", 360.0,
-    "unit", "degree",
-    NULL)
-
-gegl_property_boolean (antialiasing, _("Antialiasing"),
-    "description", _("Enables smoother tile output"),
-    "default", TRUE,
-    NULL)
-
-gegl_property_seed (seed, _("Random seed"), rand, NULL)
+property_enum (tile_type, _("Tile geometry"),
+    GeglMosaicTile, gegl_mosaic_tile, GEGL_MOSAIC_TILE_HEXAGONS)
+    description (_("What shape to use for tiles"))
+
+property_double (tile_size, _("Tile size"), 15.0)
+    description (_("Average diameter of each tile (in pixels)"))
+    value_range (1.0, 1000.0)
+    ui_range    (5.0, 400.0)
+    ui_meta     ("unit", "pixel-distance")
+
+property_double (tile_height, _("Tile height"), 4.0)
+    description (_("Apparent height of each tile (in pixels)"))
+    value_range (1.0, 1000.0)
+    ui_range    (1.0, 20.0)
+
+property_double (tile_neatness, _("Tile neatness"), 0.65)
+    description (_("Deviation from perfectly formed tiles"))
+    value_range (0.0, 1.0)
+
+property_double (color_variation, _("Tile color variation"), 0.2)
+    description (("Magnitude of random color variations"))
+    value_range (0.0, 1.0)
+
+property_boolean (color_averaging, _("Color averaging"), TRUE)
+    description (_("Tile color based on average of subsumed pixels"))
+
+property_boolean (tile_surface, _("Rough tile surface"), FALSE)
+    description (_("Surface characteristics"))
+
+property_boolean (tile_allow_split, _("Allow splitting tiles"), TRUE)
+    description (_("Allows splitting tiles at hard edges"))
+
+property_double (tile_spacing, _("Tile spacing"), 1.0)
+    description (_("Inter-tile spacing (in pixels)"))
+    value_range (0.0, 1000.0)
+    ui_range    (0.5, 30.0)
+    ui_meta     ("unit", "pixel-distance")
+
+property_color (joints_color, _("Joints color"), "black")
+
+property_color (light_color, _("Light color"), "white")
+
+property_double (light_dir, _("Light direction"), 135.0)
+    description (("Direction of light-source (in degrees)"))
+    value_range (0.0, 360.0)
+    ui_meta     ("unit", "degree")
+
+property_boolean (antialiasing, _("Antialiasing"), TRUE)
+    description  (_("Enables smoother tile output"))
+
+property_seed (seed, _("Random seed"), rand)
 
 #else
 
diff --git a/operations/common/motion-blur-circular.c b/operations/common/motion-blur-circular.c
index e9a171b..dc02df9 100644
--- a/operations/common/motion-blur-circular.c
+++ b/operations/common/motion-blur-circular.c
@@ -38,26 +38,21 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_double (center_x, _("Center X"),
-    "default", 20.0,
-    "ui-min", -100000.0, "ui-max", 100000.0,
-    "unit", "pixel-coordinate",
-    "axis", "x",
-    NULL)
-
-gegl_property_double (center_y, _("Center Y"),
-    "default", 20.0,
-    "ui-min", -100000.0, "ui-max", 100000.0,
-    "unit", "pixel-coordinate",
-    "axis", "y",
-    NULL)
+property_double (center_x, _("Center X"), 20.0)
+    ui_range    (-10000.0, 10000.0)
+    ui_meta     ("unit", "pixel-coordinate")
+    ui_meta     ("axis", "x")
+
+property_double (center_y, _("Center Y"), 20.0)
+    ui_range    (-10000.0, 10000.0)
+    ui_meta     ("unit", "pixel-coordinate")
+    ui_meta     ("axis", "y")
 
 /* FIXME: With a large angle, we lose AreaFilter's flavours */
-gegl_property_double (angle, _("Angle"),
-    "description", _("Rotation blur angle. A large angle may take some time to render"),
-    "default", 5.0, "min", -180.0, "max", 180.0,
-    "unit", "degree",
-    NULL)
+property_double (angle, _("Angle"), 5.0)
+    description (_("Rotation blur angle. A large angle may take some time to render"))
+    value_range (-180.0, 180.0)
+    ui_meta     ("unit", "degree")
 
 #else
 
diff --git a/operations/common/motion-blur-linear.c b/operations/common/motion-blur-linear.c
index 7f21ae4..0c93208 100644
--- a/operations/common/motion-blur-linear.c
+++ b/operations/common/motion-blur-linear.c
@@ -23,18 +23,17 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_double (length, _("Length"),
-    "description", _("Length of blur in pixels"),
-    "default", 10.0, "min", 0.0, "max", 1000.0,
-    "ui-max", 300.0, "ui-gamma", 1.5,
-    "unit", "pixel-distance",
-    NULL)
-
-gegl_property_double (angle, _("Angle"),
-    "description", _("Angle of blur in degrees"),
-    "default", 0.0, "min", -180.0, "max", 180.0,
-    "unit", "degree",
-    NULL)
+property_double (length, _("Length"), 10.0)
+    description (_("Length of blur in pixels"))
+    value_range (0.0, 1000.0)
+    ui_range    (0.0, 300.0)
+    ui_gamma    (1.5)
+    ui_meta     ("unit", "pixel-distance")
+
+property_double (angle, _("Angle"), 0.0)
+    description (_("Angle of blur in degrees"))
+    value_range (-180, 180)
+    ui_meta     ("unit", "degree")
 
 #else
 
diff --git a/operations/common/motion-blur-zoom.c b/operations/common/motion-blur-zoom.c
index ca13f10..fb45a39 100644
--- a/operations/common/motion-blur-zoom.c
+++ b/operations/common/motion-blur-zoom.c
@@ -37,27 +37,23 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_double (center_x, _("Center X"),
-    "description", _("Horizontal center position"),
-    "default", 20.0,
-    "ui-min",  -100000.0, "ui-max", 100000.0,
-    "unit",    "pixel-coordinate",
-    "axis",    "x",
-    NULL)
-
-gegl_property_double (center_y, _("Center Y"),
-    "description", _("Vertical center position"),
-    "default", 20.0,
-    "ui-min",  -100000.0, "ui-max", 100000.0,
-    "unit",    "pixel-coordinate",
-    "axis",    "y",
-    NULL)
-
-gegl_property_double (factor, _("Factor"),
-    "description", _("Bluring factor"),
-    "default", 0.1, "min", -10.0, "max", 1.0,
-    "ui-min", -0.5, "ui-max", 1.0, "ui-gamma", 2.0,
-    NULL)
+property_double (center_x, _("Center X"), 20.0)
+    description (_("Horizontal center position"))
+    value_range (-10000, 10000)
+    ui_meta     ("unit", "pixel-coordinate")
+    ui_meta     ("axis", "x")
+
+property_double (center_y, _("Center Y"), 20.0)
+    description (_("Vertical center position"))
+    value_range (-10000, 10000)
+    ui_meta     ("unit", "pixel-coordinate")
+    ui_meta     ("axis", "y")
+
+property_double (factor, _("Factor"), 0.1)
+    description (_("Bluring factor"))
+    value_range (-10, 1.0)
+    ui_range    (-0.5, 1.0)
+    ui_gamma    (2.0)
 
 #else
 
diff --git a/operations/common/noise-cell.c b/operations/common/noise-cell.c
index 793b85a..8da96b5 100644
--- a/operations/common/noise-cell.c
+++ b/operations/common/noise-cell.c
@@ -31,27 +31,36 @@
 
 #define MAX_RANK 3
 
-#ifdef GEGL_CHANT_PROPERTIES
-
-gegl_chant_double  (scale, _("Scale"), 0, 20.0, 1.0,
-                    _("The scale of the noise function"))
-gegl_chant_double  (shape, _("Shape"), 1.0, 2.0, 2.0,
-                    _("Interpolate between Manhattan and Euclidean distance."))
-gegl_chant_int     (rank, _("Rank"), 1, MAX_RANK, 1,
-                    _("Select the n-th closest point"))
-gegl_chant_int     (iterations, _("Iterations"), 1, 20, 1,
-                    _("The number of noise octaves."))
-gegl_chant_boolean (palettize, _("Palettize"), FALSE,
-                    _("Fill each cell with a random color"))
-gegl_chant_seed    (seed, rand, _("Random seed"),
-                    _("The random seed for the noise function"))
+#ifdef GEGL_PROPERTIES
+
+property_double  (scale, _("Scale"), 1.0)
+    description  (_("The scale of the noise function"))
+    value_range  (0, 20.0)
+
+property_double  (shape, _("Shape"), 2.0)
+    description  (_("Interpolate between Manhattan and Euclidean distance."))
+    value_range  (1.0, 2.0)
+
+property_int     (rank, _("Rank"), 1)
+    description  (_("Select the n-th closest point"))
+    value_range  (1, MAX_RANK)
+
+property_int     (iterations, _("Iterations"), 1)
+    description  (_("The number of noise octaves."))
+    value_range  (1, 20)
+
+property_boolean (palettize, _("Palettize"), FALSE)
+    description  (_("Fill each cell with a random color"))
+
+property_seed    (seed, _("Random seed"), rand)
+    description  (_("The random seed for the noise function"))
 
 #else
 
-#define GEGL_CHANT_TYPE_POINT_RENDER
-#define GEGL_CHANT_C_FILE "noise-cell.c"
+#define GEGL_OP_POINT_RENDER
+#define GEGL_OP_C_FILE "noise-cell.c"
 
-#include "gegl-chant.h"
+#include "gegl-op.h"
 #include <gegl-buffer-cl-iterator.h>
 #include <gegl-debug.h>
 #include <math.h>
@@ -250,7 +259,7 @@ cl_process (GeglOperation       *operation,
             cl_mem               out_tex,
             const GeglRectangle *roi)
 {
-  GeglChantO   *o          = GEGL_CHANT_PROPERTIES (operation);
+  GeglProperties *o        = GEGL_PROPERTIES (operation);
   const size_t  gbl_size[] = {roi->width, roi->height};
   size_t        work_group_size;
   cl_uint       cl_iterations   = o->iterations;
@@ -314,10 +323,10 @@ c_process (GeglOperation       *operation,
            const GeglRectangle *roi,
            gint                 level)
 {
-  GeglChantO *o         = GEGL_CHANT_PROPERTIES (operation);
-  Context     context;
-  gfloat     *pixel;
-  gint        s, t;
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+  Context         context;
+  gfloat         *pixel;
+  gint            s, t;
 
   context.seed = o->seed;
   context.rank = o->rank;
@@ -395,7 +404,7 @@ process (GeglOperation       *operation,
 }
 
 static void
-gegl_chant_class_init (GeglChantClass *klass)
+gegl_op_class_init (GeglOpClass *klass)
 {
   GeglOperationClass       *operation_class;
   GeglOperationSourceClass *source_class;
diff --git a/operations/common/noise-cie-lch.c b/operations/common/noise-cie-lch.c
index 6c06df1..e7b3392 100644
--- a/operations/common/noise-cie-lch.c
+++ b/operations/common/noise-cie-lch.c
@@ -22,22 +22,19 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_int (holdness, _("Holdness"),
-    "default", 2, "min", 1, "max", 8,
-    NULL)
-
-gegl_property_double (lightness_distance, _("Lightness"),
-    "default", 40.0, "min", 0.0, "max", 100.0,
-    NULL)
-
-gegl_property_double (chroma_distance, _("Chroma"),
-    "default", 40.0, "min", 0.0, "max", 100.0,
-    NULL)
-
-gegl_property_double (hue_distance, _("Hue"),
-    "default", 3.0, "min", 0.0, "max", 180.0,
-    NULL)
-gegl_property_seed   (seed, _("Random seed"), rand, NULL)
+property_int   (holdness, _("Holdness"), 2)
+   value_range (1, 8)
+
+property_double (lightness_distance, _("Lightness"), 40.0)
+   value_range  (0.0, 100.0)
+
+property_double (chroma_distance, _("Chroma"), 40.0)
+   value_range  (0.0, 100.0)
+
+property_double (hue_distance, _("Hue"), 3.0)
+   value_range  (0.0, 180.0)
+
+property_seed   (seed, _("Random seed"), rand)
 
 #else
 
diff --git a/operations/common/noise-hsv.c b/operations/common/noise-hsv.c
index 1e30738..a11bfe8 100644
--- a/operations/common/noise-hsv.c
+++ b/operations/common/noise-hsv.c
@@ -24,23 +24,19 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_int (holdness, _("Holdness"),
-    "default", 2, "min", 1, "max", 8,
-    NULL)
+property_int  (holdness, _("Holdness"), 2)
+  value_range (1, 8)
 
-gegl_property_double (hue_distance, _("Hue"),
-    "default", 3.0, "min", 0.0, "max", 180.0,
-    NULL)
+property_double (hue_distance, _("Hue"), 3.0)
+  value_range   (0.0, 180.0)
 
-gegl_property_double (saturation_distance, _("Saturation"),
-    "default", 0.04, "min", 0.0, "max", 1.0,
-    NULL)
+property_double (saturation_distance, _("Saturation"), 0.04)
+  value_range   (0.0, 1.0)
 
-gegl_property_double (value_distance, _("Value"),
-    "default", 0.04, "min", 0.0, "max", 1.0,
-    NULL)
+property_double (value_distance, _("Value"), 0.04)
+  value_range   (0.0, 1.0)
 
-gegl_property_seed   (seed, _("Random seed"), rand, NULL)
+property_seed   (seed, _("Random seed"), rand)
 
 #else
 
diff --git a/operations/common/noise-hurl.c b/operations/common/noise-hurl.c
index 8ead326..db94310 100644
--- a/operations/common/noise-hurl.c
+++ b/operations/common/noise-hurl.c
@@ -28,15 +28,13 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_double (pct_random, _("Randomization (%)"),
-    "default", 50.0, "min", 0.0, "max", 100.0,
-    NULL)
+property_double (pct_random, _("Randomization (%)"), 50.0)
+    value_range (0.0, 100.0)
 
-gegl_property_int (repeat, _("Repeat"),
-    "default", 1, "min", 1, "max", 100, 
-    NULL)
+property_int   (repeat, _("Repeat"), 1)
+   value_range (1, 100)
 
-gegl_property_seed (seed, _("Random seed"), rand, NULL) 
+property_seed (seed, _("Random seed"), rand) 
 
 #else
 
diff --git a/operations/common/noise-perlin.c b/operations/common/noise-perlin.c
index ab0bdd4..0525e1f 100644
--- a/operations/common/noise-perlin.c
+++ b/operations/common/noise-perlin.c
@@ -20,25 +20,29 @@
 #include <glib/gi18n-lib.h>
 
 
-#ifdef GEGL_CHANT_PROPERTIES
-
-gegl_chant_double_ui (alpha, _("Alpha"),    -G_MAXDOUBLE, G_MAXDOUBLE, 1.2, 0.0, 4.0, 1.0,
-                      NULL)
-gegl_chant_double_ui (scale, _("Scale"),    -G_MAXDOUBLE, G_MAXDOUBLE, 1.8, 0.0, 20.0, 1.0,
-                      NULL)
-gegl_chant_double_ui (zoff,  _("Z offset"), -G_MAXDOUBLE, G_MAXDOUBLE,  -1, -1.0, 8.0, 1.0,
-                      NULL)
-gegl_chant_int       (n,     _("Iteration"), 0, 20, 3,
-                      NULL)
-gegl_chant_double_ui (seed,  _("Random seed"), -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, 0.0, 100.0, 1.0,
-                      NULL)
+#ifdef GEGL_PROPERTIES
+
+property_double (alpha, _("Alpha"), 1.2)
+    ui_range    (0.0, 4.0)
+property_double (scale, _("Scale"), 1.8)
+    ui_range    (0.0, 20.0)
+
+property_double (zoff,  _("Z offset"), -1)
+    ui_range    (-1.0, 8.0)
+
+property_int (n, _("Iterations"), 3)
+  value_range     (0, 20)
+
+  /* XXX: what? */
+property_double (seed, _("Random seed"), 0.0)
+  ui_range (0.0, 100.0)
 
 #else
 
-#define GEGL_CHANT_TYPE_POINT_RENDER
-#define GEGL_CHANT_C_FILE "noise-perlin.c"
+#define GEGL_OP_POINT_RENDER
+#define GEGL_OP_C_FILE "noise-perlin.c"
 
-#include "gegl-chant.h"
+#include "gegl-op.h"
 #include "perlin/perlin.c"
 #include "perlin/perlin.h"
 
@@ -62,7 +66,7 @@ process (GeglOperation       *operation,
          const GeglRectangle *roi,
          gint                 level)
 {
-  GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+  GeglProperties *o = GEGL_PROPERTIES (operation);
   gfloat     *out_pixel = out_buf;
   gint        x = roi->x; /* initial x                   */
   gint        y = roi->y; /*           and y coordinates */
@@ -91,7 +95,7 @@ process (GeglOperation       *operation,
 }
 
 static void
-gegl_chant_class_init (GeglChantClass *klass)
+gegl_op_class_init (GeglOpClass *klass)
 {
   GeglOperationClass            *operation_class;
   GeglOperationPointRenderClass *point_render_class;
diff --git a/operations/common/noise-pick.c b/operations/common/noise-pick.c
index 6c4105c..1503621 100644
--- a/operations/common/noise-pick.c
+++ b/operations/common/noise-pick.c
@@ -29,15 +29,13 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_double (pct_random, _("Randomization (%)"),
-    "default", 50.0, "min", 0.0, "max", 100.0,
-    NULL)
+property_double (pct_random, _("Randomization (%)"), 50.0)
+    value_range (0.0, 100.0)
 
-gegl_property_int (repeat, _("Repeat"),
-    "default", 1, "min", 1, "max", 100,
-    NULL)
+property_int    (repeat, _("Repeat"), 1)
+    value_range (1, 100)
 
-gegl_property_seed (seed, _("Random seed"), rand, NULL)
+property_seed (seed, _("Random seed"), rand)
 
 #else
 
diff --git a/operations/common/noise-reduction.c b/operations/common/noise-reduction.c
index 5df206f..ea3917b 100644
--- a/operations/common/noise-reduction.c
+++ b/operations/common/noise-reduction.c
@@ -23,11 +23,10 @@
 
 #ifdef GEGL_PROPERTIES
 
-gegl_property_int (iterations, _("Strength"),
-    "description", _("Controls the number of iterations; lower values give better results."),
-    "default", 4, "min",    1, "max", 32,
-    "ui-min",  1, "ui-max", 8,
-    NULL)
+property_int  (iterations, _("Strength"), 4)
+  description (_("Controls the number of iterations; lower values give less plastic results"))
+  value_range (1, 32)
+  ui_range    (1, 8)
 
 #else
 


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