[gimp] app: update image bounding box when moving layer inside/outside of group
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: update image bounding box when moving layer inside/outside of group
- Date: Sat, 28 Sep 2019 08:14:39 +0000 (UTC)
commit 2a753170b955323b6e9d5892f539ef88b83746d6
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.
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 57cabe04d9..fe14db5c2d 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);
@@ -802,6 +805,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);
@@ -1050,6 +1060,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);
@@ -1627,6 +1641,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,
@@ -4571,8 +4593,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;
}
@@ -4690,8 +4710,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]