app: fix regression: make the selection clip the FS again

This commit is contained in:
Michael Natterer 2013-04-12 18:26:34 +02:00
parent 05e6f6d848
commit 38e983c724
2 changed files with 81 additions and 21 deletions

View File

@ -31,6 +31,8 @@ struct _GimpDrawablePrivate
GimpFilter *fs_filter; GimpFilter *fs_filter;
GeglNode *fs_crop_node; GeglNode *fs_crop_node;
GeglNode *fs_offset_node; GeglNode *fs_offset_node;
GeglNode *fs_mask_node;
GeglNode *fs_mask_offset_node;
GeglNode *fs_mode_node; GeglNode *fs_mode_node;
GeglNode *fs_affect_node; GeglNode *fs_affect_node;

View File

@ -179,9 +179,11 @@ static void gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
static void gimp_drawable_fs_notify (GimpLayer *fs, static void gimp_drawable_fs_notify (GimpLayer *fs,
const GParamSpec *pspec, const GParamSpec *pspec,
GimpDrawable *drawable); GimpDrawable *drawable);
static void gimp_drawable_fs_image_changed (GimpImage *image, static void gimp_drawable_fs_affect_changed (GimpImage *image,
GimpChannelType channel, GimpChannelType channel,
GimpDrawable *drawable); GimpDrawable *drawable);
static void gimp_drawable_fs_mask_changed (GimpImage *image,
GimpDrawable *drawable);
static void gimp_drawable_fs_update (GimpLayer *fs, static void gimp_drawable_fs_update (GimpLayer *fs,
gint x, gint x,
gint y, gint y,
@ -904,11 +906,13 @@ static GimpFilter *
gimp_drawable_create_fs_filter (GimpDrawable *drawable, gimp_drawable_create_fs_filter (GimpDrawable *drawable,
GimpDrawable *fs) GimpDrawable *fs)
{ {
GimpFilter *filter; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglNode *node; GimpChannel *mask = gimp_image_get_mask (image);
GeglNode *input; GimpFilter *filter;
GeglNode *output; GeglNode *node;
GeglNode *fs_source; GeglNode *input;
GeglNode *output;
GeglNode *fs_source;
filter = gimp_filter_new ("Floating Selection"); filter = gimp_filter_new ("Floating Selection");
@ -935,15 +939,30 @@ gimp_drawable_create_fs_filter (GimpDrawable *drawable,
gegl_node_connect_to (drawable->private->fs_crop_node, "output", gegl_node_connect_to (drawable->private->fs_crop_node, "output",
drawable->private->fs_offset_node, "input"); drawable->private->fs_offset_node, "input");
drawable->private->fs_mask_node =
gegl_node_new_child (node,
"operation", "gegl:buffer-source",
"buffer", gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)),
NULL);
drawable->private->fs_mask_offset_node =
gegl_node_new_child (node,
"operation", "gegl:translate",
NULL);
gegl_node_connect_to (drawable->private->fs_mask_node, "output",
drawable->private->fs_mask_offset_node, "input");
drawable->private->fs_mode_node = drawable->private->fs_mode_node =
gegl_node_new_child (node, gegl_node_new_child (node,
"operation", "gimp:normal-mode", "operation", "gimp:normal-mode",
NULL); NULL);
gegl_node_connect_to (input, "output", gegl_node_connect_to (input, "output",
drawable->private->fs_mode_node, "input"); drawable->private->fs_mode_node, "input");
gegl_node_connect_to (drawable->private->fs_offset_node, "output", gegl_node_connect_to (drawable->private->fs_offset_node, "output",
drawable->private->fs_mode_node, "aux"); drawable->private->fs_mode_node, "aux");
/* don't connect the mask, that's done dynamically in sync_fs_filter */
drawable->private->fs_affect_node = drawable->private->fs_affect_node =
gegl_node_new_child (node, gegl_node_new_child (node,
@ -973,8 +992,10 @@ gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
if (fs && ! detach_fs) if (fs && ! detach_fs)
{ {
gint off_x, off_y; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gint fs_off_x, fs_off_y; GimpChannel *mask = gimp_image_get_mask (image);
gint off_x, off_y;
gint fs_off_x, fs_off_y;
if (! drawable->private->fs_filter) if (! drawable->private->fs_filter)
{ {
@ -1001,7 +1022,10 @@ gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
G_CALLBACK (gimp_drawable_fs_notify), G_CALLBACK (gimp_drawable_fs_notify),
drawable); drawable);
g_signal_connect (image, "component-active-changed", g_signal_connect (image, "component-active-changed",
G_CALLBACK (gimp_drawable_fs_image_changed), G_CALLBACK (gimp_drawable_fs_affect_changed),
drawable);
g_signal_connect (image, "mask-changed",
G_CALLBACK (gimp_drawable_fs_mask_changed),
drawable); drawable);
} }
@ -1020,6 +1044,21 @@ gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
"y", (gdouble) (fs_off_y - off_y), "y", (gdouble) (fs_off_y - off_y),
NULL); NULL);
gegl_node_set (drawable->private->fs_mask_offset_node,
"x", (gdouble) - off_x,
"y", (gdouble) - off_y,
NULL);
if (gimp_channel_is_empty (mask))
{
gegl_node_disconnect (drawable->private->fs_mode_node, "aux2");
}
else
{
gegl_node_connect_to (drawable->private->fs_mask_offset_node, "output",
drawable->private->fs_mode_node, "aux2");
}
gimp_gegl_mode_node_set (drawable->private->fs_mode_node, gimp_gegl_mode_node_set (drawable->private->fs_mode_node,
gimp_layer_get_mode (fs), gimp_layer_get_mode (fs),
gimp_layer_get_opacity (fs), gimp_layer_get_opacity (fs),
@ -1039,7 +1078,10 @@ gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
gimp_drawable_fs_notify, gimp_drawable_fs_notify,
drawable); drawable);
g_signal_handlers_disconnect_by_func (image, g_signal_handlers_disconnect_by_func (image,
gimp_drawable_fs_image_changed, gimp_drawable_fs_affect_changed,
drawable);
g_signal_handlers_disconnect_by_func (image,
gimp_drawable_fs_mask_changed,
drawable); drawable);
gimp_drawable_remove_filter (drawable, drawable->private->fs_filter); gimp_drawable_remove_filter (drawable, drawable->private->fs_filter);
@ -1061,10 +1103,12 @@ gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
g_object_unref (drawable->private->fs_filter); g_object_unref (drawable->private->fs_filter);
drawable->private->fs_filter = NULL; drawable->private->fs_filter = NULL;
drawable->private->fs_crop_node = NULL; drawable->private->fs_crop_node = NULL;
drawable->private->fs_offset_node = NULL; drawable->private->fs_offset_node = NULL;
drawable->private->fs_mode_node = NULL; drawable->private->fs_mask_node = NULL;
drawable->private->fs_affect_node = NULL; drawable->private->fs_mask_offset_node = NULL;
drawable->private->fs_mode_node = NULL;
drawable->private->fs_affect_node = NULL;
} }
} }
} }
@ -1085,9 +1129,23 @@ gimp_drawable_fs_notify (GimpLayer *fs,
} }
static void static void
gimp_drawable_fs_image_changed (GimpImage *image, gimp_drawable_fs_affect_changed (GimpImage *image,
GimpChannelType channel, GimpChannelType channel,
GimpDrawable *drawable) GimpDrawable *drawable)
{
GimpLayer *fs = gimp_drawable_get_floating_sel (drawable);
gimp_drawable_sync_fs_filter (drawable, FALSE);
gimp_drawable_update (GIMP_DRAWABLE (fs),
0, 0,
gimp_item_get_width (GIMP_ITEM (fs)),
gimp_item_get_height (GIMP_ITEM (fs)));
}
static void
gimp_drawable_fs_mask_changed (GimpImage *image,
GimpDrawable *drawable)
{ {
GimpLayer *fs = gimp_drawable_get_floating_sel (drawable); GimpLayer *fs = gimp_drawable_get_floating_sel (drawable);