[gimp] Bug 600554 - Implement layer group transforms



commit 503acbae5434b0d74f5ade0e5509dc06cb11d795
Author: Michael Natterer <mitch gimp org>
Date:   Thu Mar 17 21:52:43 2011 +0100

    Bug 600554 - Implement layer group transforms
    
    When transforming layer groups, don't cut out a buffer to transform.
    Instead, simply call GimpTransformTool::transform() with
    tr_tool->original being NULL, just as when we are transforming a
    path. In the transform() implementations, simplify the code to not
    look at the type of item to be transformed; instead, simply look at
    tr_tool->original and transform it if it exists, otherwise call
    gimp_item_transform() which does the right thing for all sorts of
    items automatically.

 app/tools/gimpfliptool.c      |   35 +++++++++++-----------
 app/tools/gimptransformtool.c |   65 +++++++++++++++++++---------------------
 2 files changed, 49 insertions(+), 51 deletions(-)
---
diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c
index ba01ad1..4eafd18 100644
--- a/app/tools/gimpfliptool.c
+++ b/app/tools/gimpfliptool.c
@@ -179,11 +179,10 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
                           gboolean           mask_empty,
                           GimpDisplay       *display)
 {
-  GimpFlipOptions      *options    = GIMP_FLIP_TOOL_GET_OPTIONS (trans_tool);
-  GimpTransformOptions *tr_options = GIMP_TRANSFORM_OPTIONS (options);
-  GimpContext          *context    = GIMP_CONTEXT (options);
-  gdouble               axis       = 0.0;
-  TileManager          *ret        = NULL;
+  GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (trans_tool);
+  GimpContext     *context = GIMP_CONTEXT (options);
+  gdouble          axis    = 0.0;
+  TileManager     *ret     = NULL;
 
   switch (options->flip_type)
     {
@@ -215,21 +214,23 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
                       options->flip_type, axis, FALSE);
     }
 
-  switch (tr_options->type)
+  if (trans_tool->original)
     {
-    case GIMP_TRANSFORM_TYPE_LAYER:
-    case GIMP_TRANSFORM_TYPE_SELECTION:
-      if (trans_tool->original)
-        ret = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (active_item),
-                                                  context,
-                                                  trans_tool->original,
-                                                  options->flip_type, axis,
-                                                  FALSE);
-      break;
+      /*  this happens when transforming a normal drawable or the
+       *  selection
+       */
+
+      ret = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (active_item),
+                                                context,
+                                                trans_tool->original,
+                                                options->flip_type, axis,
+                                                FALSE);
+    }
+  else
+    {
+      /*  this happens for paths and layer groups  */
 
-    case GIMP_TRANSFORM_TYPE_PATH:
       gimp_item_flip (active_item, context, options->flip_type, axis, FALSE);
-      break;
     }
 
   return ret;
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index f1cd049..0f160b4 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -1180,37 +1180,35 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
                            progress);
     }
 
-  switch (options->type)
+  if (tr_tool->original)
     {
-    case GIMP_TRANSFORM_TYPE_LAYER:
-    case GIMP_TRANSFORM_TYPE_SELECTION:
-      {
-        GimpTransformResize clip_result = options->clip;
+      /*  this happens when transforming a normal drawable or the
+       *  selection
+       */
 
-        /*  always clip the selction and unfloated channels
-         *  so they keep their size
-         */
-        if (tr_tool->original)
-          {
-            if (GIMP_IS_CHANNEL (active_item) &&
-                tile_manager_bpp (tr_tool->original) == 1)
-              clip_result = GIMP_TRANSFORM_RESIZE_CLIP;
-
-            ret =
-              gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
-                                                    context,
-                                                    tr_tool->original,
-                                                    &tr_tool->transform,
-                                                    options->direction,
-                                                    options->interpolation,
-                                                    options->recursion_level,
-                                                    clip_result,
-                                                    progress);
-          }
-      }
-      break;
+      GimpTransformResize clip_result = options->clip;
+
+      /*  always clip the selction and unfloated channels
+       *  so they keep their size
+       */
+      if (GIMP_IS_CHANNEL (active_item) &&
+          tile_manager_bpp (tr_tool->original) == 1)
+        clip_result = GIMP_TRANSFORM_RESIZE_CLIP;
+
+      ret = gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
+                                                  context,
+                                                  tr_tool->original,
+                                                  &tr_tool->transform,
+                                                  options->direction,
+                                                  options->interpolation,
+                                                  options->recursion_level,
+                                                  clip_result,
+                                                  progress);
+    }
+  else
+    {
+      /*  this happens for paths and layer groups  */
 
-    case GIMP_TRANSFORM_TYPE_PATH:
       gimp_item_transform (active_item, context,
                            &tr_tool->transform,
                            options->direction,
@@ -1218,7 +1216,6 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
                            options->recursion_level,
                            options->clip,
                            progress);
-      break;
     }
 
   if (progress)
@@ -1310,9 +1307,10 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
   switch (options->type)
     {
     case GIMP_TRANSFORM_TYPE_LAYER:
-      tr_tool->original = gimp_drawable_transform_cut (tool->drawable,
-                                                       context,
-                                                       &new_layer);
+      if (! gimp_viewable_get_children (GIMP_VIEWABLE (tool->drawable)))
+        tr_tool->original = gimp_drawable_transform_cut (tool->drawable,
+                                                         context,
+                                                         &new_layer);
       break;
 
     case GIMP_TRANSFORM_TYPE_SELECTION:
@@ -1321,7 +1319,6 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
       break;
 
     case GIMP_TRANSFORM_TYPE_PATH:
-      tr_tool->original = NULL;
       break;
     }
 



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