core: Put floating selections under layer effects

Resolves #11147

Applying the same reordering code
in cbb1e816 to adding a floating selection.
When anchored, floating selections were also
merging down all layer effects onto the original
image. This patch places the float selection
under the layer effect when added, both to prevent
this and because it seems to be the expected
behavior based on user feedback.
This commit is contained in:
Alx Sa 2024-03-30 15:44:39 +00:00
parent 781581379a
commit a4cfa25822

View file

@ -28,6 +28,7 @@
#include "gegl/gimpapplicator.h"
#include "gimpchannel.h"
#include "gimpcontainer.h"
#include "gimpdrawable-floating-selection.h"
#include "gimpdrawable-filters.h"
#include "gimpdrawable-private.h"
@ -192,10 +193,13 @@ void
_gimp_drawable_add_floating_sel_filter (GimpDrawable *drawable)
{
GimpDrawablePrivate *private = drawable->private;
GimpContainer *filters = gimp_drawable_get_filters (drawable);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpLayer *fs = gimp_drawable_get_floating_sel (drawable);
GeglNode *node;
GeglNode *fs_source;
gint end_index;
gint index;
if (! private->source_node)
return;
@ -234,6 +238,15 @@ _gimp_drawable_add_floating_sel_filter (GimpDrawable *drawable)
gimp_drawable_add_filter (drawable, private->fs_filter);
/* Move the floating selection below any non-destructive filters that
* may be active, so that it's directly affect the raw pixels. */
end_index = gimp_container_get_n_children (filters) - 1;
index =
gimp_container_get_child_index (filters, GIMP_OBJECT (private->fs_filter));
if (end_index > 0 && index != end_index)
gimp_container_reorder (filters, GIMP_OBJECT (private->fs_filter),
end_index);
g_signal_connect (fs, "notify",
G_CALLBACK (gimp_drawable_fs_notify),
drawable);