Commit 2a753170 authored by Ell's avatar Ell

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.
parent 1b48c687
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment