[gimp/gimp-2-10] app: update image bounding box when moving layer inside/outside of group



commit e4c7f869c4c532e74818f1e9ca875ecf73ec8ca0
Author: Ell <ell_se yahoo com>
Date:   Sat Sep 28 10:53:52 2019 +0300

    app: update image bounding box when moving layer inside/outside of group
    
    In GimpImage, update the image's bounding box in response to the
    layer container's "add" and "remove" signals, instead of during
    gimp_image_{add,remove}_layer(), so that the bounding box is
    properly updated when moving an existing layer inside/outside of a
    layer group, instead of only when adding/removing a new layer.
    
    Even though moving a layer across group boundary doesn't change the
    overall image bounding box, it does change the group's bounding
    box, affecting the image bounding box.  It's therefore necessary to
    update the image bounding box again when the layer is re-added to
    the layer stack, so that the bounding box doesn't get stuck in an
    intermediate state.
    
    (cherry picked from commit 2a753170b955323b6e9d5892f539ef88b83746d6)

 app/core/gimpimage.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index db7a584c4d..8b51f3ab56 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -233,6 +233,9 @@ static void     gimp_image_mask_update           (GimpDrawable      *drawable,
                                                   gint               width,
                                                   gint               height,
                                                   GimpImage         *image);
+static void     gimp_image_layers_changed        (GimpContainer     *container,
+                                                  GimpChannel       *channel,
+                                                  GimpImage         *image);
 static void     gimp_image_layer_offset_changed  (GimpDrawable      *drawable,
                                                   const GParamSpec  *pspec,
                                                   GimpImage         *image);
@@ -815,6 +818,13 @@ gimp_image_init (GimpImage *image)
                                 G_CALLBACK (gimp_image_layer_alpha_changed),
                                 image);
 
+  g_signal_connect (private->layers->container, "add",
+                    G_CALLBACK (gimp_image_layers_changed),
+                    image);
+  g_signal_connect (private->layers->container, "remove",
+                    G_CALLBACK (gimp_image_layers_changed),
+                    image);
+
   g_signal_connect_swapped (private->channels->container, "update",
                             G_CALLBACK (gimp_image_invalidate),
                             image);
@@ -1063,6 +1073,10 @@ gimp_image_dispose (GObject *object)
   gimp_container_remove_handler (private->layers->container,
                                  private->layer_alpha_handler);
 
+  g_signal_handlers_disconnect_by_func (private->layers->container,
+                                        gimp_image_layers_changed,
+                                        image);
+
   g_signal_handlers_disconnect_by_func (private->channels->container,
                                         gimp_image_invalidate,
                                         image);
@@ -1652,6 +1666,14 @@ gimp_image_mask_update (GimpDrawable *drawable,
   GIMP_IMAGE_GET_PRIVATE (image)->flush_accum.mask_changed = TRUE;
 }
 
+static void
+gimp_image_layers_changed (GimpContainer *container,
+                           GimpChannel   *channel,
+                           GimpImage     *image)
+{
+  gimp_image_update_bounding_box (image);
+}
+
 static void
 gimp_image_layer_offset_changed (GimpDrawable     *drawable,
                                  const GParamSpec *pspec,
@@ -4582,8 +4604,6 @@ gimp_image_add_layer (GimpImage *image,
   if (old_has_alpha != gimp_image_has_alpha (image))
     private->flush_accum.alpha_changed = TRUE;
 
-  gimp_image_update_bounding_box (image);
-
   return TRUE;
 }
 
@@ -4701,8 +4721,6 @@ gimp_image_remove_layer (GimpImage *image,
   if (old_has_alpha != gimp_image_has_alpha (image))
     private->flush_accum.alpha_changed = TRUE;
 
-  gimp_image_update_bounding_box (image);
-
   if (push_undo)
     gimp_image_undo_group_end (image);
 }


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