[gimp] When scaling a group layer, remove children that are scaled away



commit cd70850990d02de220bbc840d31a89ada1b0614d
Author: Michael Natterer <mitch gimp org>
Date:   Thu Aug 27 11:53:47 2009 +0200

    When scaling a group layer, remove children that are scaled away
    
    When a child's width or height becomes < 1, remove it rather than
    trying to scale it to impossible dimensions.

 app/core/gimpgrouplayer.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index ca68ab2..dfe5804 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -453,9 +453,9 @@ gimp_group_layer_scale (GimpItem              *item,
   old_offset_x = gimp_item_get_offset_x (item);
   old_offset_y = gimp_item_get_offset_y (item);
 
-  for (list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (group->children));
-       list;
-       list = g_list_next (list))
+  list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (group->children));
+
+  while (list)
     {
       GimpItem *child = list->data;
       gint      child_width;
@@ -463,6 +463,8 @@ gimp_group_layer_scale (GimpItem              *item,
       gint      child_offset_x;
       gint      child_offset_y;
 
+      list = g_list_next (list);
+
       child_width    = ROUND (width_factor  * gimp_item_get_width  (child));
       child_height   = ROUND (height_factor * gimp_item_get_height (child));
       child_offset_x = ROUND (width_factor  * (gimp_item_get_offset_x (child) -
@@ -473,10 +475,23 @@ gimp_group_layer_scale (GimpItem              *item,
       child_offset_x += new_offset_x;
       child_offset_y += new_offset_y;
 
-      gimp_item_scale (child,
-                       child_width, child_height,
-                       child_offset_x, child_offset_y,
-                       interpolation_type, progress);
+      if (child_width > 0 && child_height > 0)
+        {
+          gimp_item_scale (child,
+                           child_width, child_height,
+                           child_offset_x, child_offset_y,
+                           interpolation_type, progress);
+        }
+      else if (gimp_item_is_attached (item))
+        {
+          gimp_image_remove_layer (gimp_item_get_image (item),
+                                   GIMP_LAYER (child),
+                                   TRUE, NULL);
+        }
+      else
+        {
+          gimp_container_remove (group->children, GIMP_OBJECT (child));
+        }
     }
 
   mask = gimp_layer_get_mask (GIMP_LAYER (group));



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