[gimp/gimp-2-10] app: add gimp_item_get_clip()



commit 3a7972e5fbbbe3c56cd80736aa1b964d4a49df4f
Author: Ell <ell_se yahoo com>
Date:   Fri Aug 9 21:38:53 2019 +0300

    app: add gimp_item_get_clip()
    
    Add a new GimpItem::get_clip() virtual function, and a
    corresponding gimp_item_get_clip() function, which return the
    actual clipping mode to be used when transforming (or applying a
    filter to) a given item, given the original clipping mode.  This
    applies only to whole-item transformations (i.e., when not creating
    a floating selection), and should be used by the top-level code
    applying the transformation, rather than by the actual
    transformation code, so that the item can be transformed using a
    different clipping mode internally.
    
    Provide a default implementation that simply returns the input
    clipping mode, and override for GimpChannel (to always return CLIP)
    and for GimpVecotrs (to always return ADJUST).
    
    (cherry picked from commit d5cdcc6c02c15c5ce360be08a6a7ad761f061bf4)

 app/core/gimpchannel.c    | 11 +++++++++++
 app/core/gimpitem.c       | 20 ++++++++++++++++++++
 app/core/gimpitem.h       |  4 ++++
 app/vectors/gimpvectors.c | 11 +++++++++++
 4 files changed, 46 insertions(+)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 141602731d..622f66f3b8 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -128,6 +128,9 @@ static void       gimp_channel_transform     (GimpItem          *item,
                                               GimpInterpolationType interpolation_type,
                                               GimpTransformResize clip_result,
                                               GimpProgress      *progress);
+static GimpTransformResize
+                  gimp_channel_get_clip      (GimpItem          *item,
+                                              GimpTransformResize clip_result);
 static gboolean   gimp_channel_fill          (GimpItem          *item,
                                               GimpDrawable      *drawable,
                                               GimpFillOptions   *fill_options,
@@ -265,6 +268,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
   item_class->flip                 = gimp_channel_flip;
   item_class->rotate               = gimp_channel_rotate;
   item_class->transform            = gimp_channel_transform;
+  item_class->get_clip             = gimp_channel_get_clip;
   item_class->fill                 = gimp_channel_fill;
   item_class->stroke               = gimp_channel_stroke;
   item_class->to_selection         = gimp_channel_to_selection;
@@ -815,6 +819,13 @@ gimp_channel_transform (GimpItem               *item,
                                              progress);
 }
 
+static GimpTransformResize
+gimp_channel_get_clip (GimpItem            *item,
+                       GimpTransformResize  clip_result)
+{
+  return GIMP_TRANSFORM_RESIZE_CLIP;
+}
+
 static gboolean
 gimp_channel_fill (GimpItem         *item,
                    GimpDrawable     *drawable,
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 1cc0992ad8..61df00c161 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -163,6 +163,9 @@ static void       gimp_item_real_resize             (GimpItem       *item,
                                                      gint            new_height,
                                                      gint            offset_x,
                                                      gint            offset_y);
+static GimpTransformResize
+                  gimp_item_real_get_clip           (GimpItem       *item,
+                                                     GimpTransformResize clip_result);
 
 
 
@@ -271,6 +274,7 @@ gimp_item_class_init (GimpItemClass *klass)
   klass->flip                      = NULL;
   klass->rotate                    = NULL;
   klass->transform                 = NULL;
+  klass->get_clip                  = gimp_item_real_get_clip;
   klass->fill                      = NULL;
   klass->stroke                    = NULL;
   klass->to_selection              = NULL;
@@ -687,6 +691,13 @@ gimp_item_real_resize (GimpItem     *item,
                         private->offset_y - offset_y);
 }
 
+static GimpTransformResize
+gimp_item_real_get_clip (GimpItem            *item,
+                         GimpTransformResize  clip_result)
+{
+  return clip_result;
+}
+
 
 /*  public functions  */
 
@@ -1729,6 +1740,15 @@ gimp_item_transform (GimpItem               *item,
     gimp_image_undo_group_end (image);
 }
 
+GimpTransformResize
+gimp_item_get_clip (GimpItem            *item,
+                    GimpTransformResize  clip_result)
+{
+  g_return_val_if_fail (GIMP_IS_ITEM (item), GIMP_TRANSFORM_RESIZE_ADJUST);
+
+  return GIMP_ITEM_GET_CLASS (item)->get_clip (item, clip_result);
+}
+
 gboolean
 gimp_item_fill (GimpItem        *item,
                 GimpDrawable    *drawable,
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index bcfcedb7e9..6bc56e3dcb 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -113,6 +113,8 @@ struct _GimpItemClass
                                           GimpInterpolationType   interpolation_type,
                                           GimpTransformResize     clip_result,
                                           GimpProgress           *progress);
+  GimpTransformResize (* get_clip)       (GimpItem               *item,
+                                          GimpTransformResize     clip_result);
   gboolean        (* fill)               (GimpItem               *item,
                                           GimpDrawable           *drawable,
                                           GimpFillOptions        *fill_options,
@@ -288,6 +290,8 @@ void            gimp_item_transform          (GimpItem           *item,
                                               GimpInterpolationType interpolation_type,
                                               GimpTransformResize clip_result,
                                               GimpProgress       *progress);
+GimpTransformResize   gimp_item_get_clip     (GimpItem           *item,
+                                              GimpTransformResize clip_result);
 
 gboolean        gimp_item_fill               (GimpItem           *item,
                                               GimpDrawable       *drawable,
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index e9fe9d25ae..1a65eac3c1 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -116,6 +116,9 @@ static void       gimp_vectors_transform     (GimpItem          *item,
                                               GimpInterpolationType interp_type,
                                               GimpTransformResize   clip_result,
                                               GimpProgress      *progress);
+static GimpTransformResize
+                  gimp_vectors_get_clip      (GimpItem          *item,
+                                              GimpTransformResize clip_result);
 static gboolean   gimp_vectors_fill          (GimpItem          *item,
                                               GimpDrawable      *drawable,
                                               GimpFillOptions   *fill_options,
@@ -217,6 +220,7 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
   item_class->flip                  = gimp_vectors_flip;
   item_class->rotate                = gimp_vectors_rotate;
   item_class->transform             = gimp_vectors_transform;
+  item_class->get_clip              = gimp_vectors_get_clip;
   item_class->fill                  = gimp_vectors_fill;
   item_class->stroke                = gimp_vectors_stroke;
   item_class->to_selection          = gimp_vectors_to_selection;
@@ -652,6 +656,13 @@ gimp_vectors_transform (GimpItem               *item,
   gimp_vectors_thaw (vectors);
 }
 
+static GimpTransformResize
+gimp_vectors_get_clip (GimpItem            *item,
+                       GimpTransformResize  clip_result)
+{
+  return GIMP_TRANSFORM_RESIZE_ADJUST;
+}
+
 static gboolean
 gimp_vectors_fill (GimpItem         *item,
                    GimpDrawable     *drawable,


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