[gimp] app: add new API gimp_image_map_set_region()



commit f294225af216fc32c07b7db2a0f0db9a3a854006
Author: Michael Natterer <mitch gimp org>
Date:   Thu May 23 19:29:02 2013 +0200

    app: add new API gimp_image_map_set_region()
    
    which sets either SELECTION or DRAWABLE. In SELECTION mode (the
    previous hardcoded default), the effect is offset to the selection
    boundary, in DRAWABLE mode, the effect's coordinates are drawable
    coordinates.

 app/core/gimpimagemap.c |   50 ++++++++++++++++++++++++++++++----------------
 app/core/gimpimagemap.h |   30 ++++++++++++++++++---------
 2 files changed, 52 insertions(+), 28 deletions(-)
---
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index bd25a03..9855caa 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -58,19 +58,20 @@ enum
 
 struct _GimpImageMap
 {
-  GimpObject      parent_instance;
+  GimpObject          parent_instance;
 
-  GimpDrawable   *drawable;
-  gchar          *undo_desc;
-  GeglNode       *operation;
-  gchar          *stock_id;
+  GimpDrawable       *drawable;
+  gchar              *undo_desc;
+  GeglNode           *operation;
+  gchar              *stock_id;
+  GimpImageMapRegion  region;
 
-  gboolean        filtering;
-  GeglRectangle   filter_area;
+  gboolean            filtering;
+  GeglRectangle       filter_area;
 
-  GimpFilter     *filter;
-  GeglNode       *translate;
-  GimpApplicator *applicator;
+  GimpFilter         *filter;
+  GeglNode           *translate;
+  GimpApplicator     *applicator;
 };
 
 
@@ -112,6 +113,7 @@ gimp_image_map_class_init (GimpImageMapClass *klass)
 static void
 gimp_image_map_init (GimpImageMap *image_map)
 {
+  image_map->region = GIMP_IMAGE_MAP_REGION_SELECTION;
 }
 
 static void
@@ -195,6 +197,15 @@ gimp_image_map_new (GimpDrawable *drawable,
 }
 
 void
+gimp_image_map_set_region (GimpImageMap       *image_map,
+                           GimpImageMapRegion  region)
+{
+  g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
+
+  image_map->region = region;
+}
+
+void
 gimp_image_map_apply (GimpImageMap        *image_map,
                       const GeglRectangle *area)
 {
@@ -324,14 +335,17 @@ gimp_image_map_apply (GimpImageMap        *image_map,
                                 GIMP_REPLACE_MODE);
     }
 
-  gegl_node_set (image_map->translate,
-                 "x", (gdouble) -image_map->filter_area.x,
-                 "y", (gdouble) -image_map->filter_area.y,
-                 NULL);
-
-  gimp_applicator_set_apply_offset (image_map->applicator,
-                                    image_map->filter_area.x,
-                                    image_map->filter_area.y);
+  if (image_map->region == GIMP_IMAGE_MAP_REGION_SELECTION)
+    {
+      gegl_node_set (image_map->translate,
+                     "x", (gdouble) -image_map->filter_area.x,
+                     "y", (gdouble) -image_map->filter_area.y,
+                     NULL);
+
+      gimp_applicator_set_apply_offset (image_map->applicator,
+                                        image_map->filter_area.x,
+                                        image_map->filter_area.y);
+    }
 
   active_mask = gimp_drawable_get_active_mask (image_map->drawable);
 
diff --git a/app/core/gimpimagemap.h b/app/core/gimpimagemap.h
index fe5901a..1027d19 100644
--- a/app/core/gimpimagemap.h
+++ b/app/core/gimpimagemap.h
@@ -22,6 +22,13 @@
 #include "gimpobject.h"
 
 
+typedef enum
+{
+  GIMP_IMAGE_MAP_REGION_SELECTION,
+  GIMP_IMAGE_MAP_REGION_DRAWABLE
+} GimpImageMapRegion;
+
+
 #define GIMP_TYPE_IMAGE_MAP            (gimp_image_map_get_type ())
 #define GIMP_IMAGE_MAP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_MAP, 
GimpImageMap))
 #define GIMP_IMAGE_MAP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_MAP, 
GimpImageMapClass))
@@ -47,19 +54,22 @@ struct _GimpImageMapClass
  *  The image map is no longer valid after a call to commit or abort.
  */
 
-GType          gimp_image_map_get_type (void) G_GNUC_CONST;
+GType          gimp_image_map_get_type   (void) G_GNUC_CONST;
+
+GimpImageMap * gimp_image_map_new        (GimpDrawable        *drawable,
+                                          const gchar         *undo_desc,
+                                          GeglNode            *operation,
+                                          const gchar         *stock_id);
 
-GimpImageMap * gimp_image_map_new      (GimpDrawable        *drawable,
-                                        const gchar         *undo_desc,
-                                        GeglNode            *operation,
-                                        const gchar         *stock_id);
+void           gimp_image_map_set_region (GimpImageMap        *image_map,
+                                          GimpImageMapRegion   region);
 
-void           gimp_image_map_apply    (GimpImageMap        *image_map,
-                                        const GeglRectangle *area);
+void           gimp_image_map_apply      (GimpImageMap        *image_map,
+                                          const GeglRectangle *area);
 
-void           gimp_image_map_commit   (GimpImageMap        *image_map,
-                                        GimpProgress        *progress);
-void           gimp_image_map_abort    (GimpImageMap        *image_map);
+void           gimp_image_map_commit     (GimpImageMap        *image_map,
+                                          GimpProgress        *progress);
+void           gimp_image_map_abort      (GimpImageMap        *image_map);
 
 
 #endif /* __GIMP_IMAGE_MAP_H__ */


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