Skip to content

Commit

Permalink
core: Copy NDE filters in layer group children
Browse files Browse the repository at this point in the history
This allows us to retain any filters that a
layer group's children might have when
copied or exported. They were previously
lost when the group layer was duplicated.
Note that an OR condition was added to
GimpDrawableFilter creation, to allow
one to be created if the layer was 
attached to a parent layer rather than the
image.
  • Loading branch information
cmyk-student committed Apr 28, 2024
1 parent 97671db commit 8d43ba6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/core/gimpdrawablefilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ gimp_drawable_filter_new (GimpDrawable *drawable,
GeglNode *node;

g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)) ||
gimp_viewable_get_parent (GIMP_VIEWABLE (drawable)), NULL);
g_return_val_if_fail (GEGL_IS_NODE (operation), NULL);
g_return_val_if_fail (gegl_node_has_pad (operation, "output"), NULL);

Expand Down Expand Up @@ -766,7 +767,8 @@ gimp_drawable_filter_apply (GimpDrawableFilter *filter,
const GeglRectangle *area)
{
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (filter->drawable)));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (filter->drawable)) ||
gimp_viewable_get_parent (GIMP_VIEWABLE (filter->drawable)));

gimp_drawable_filter_add_filter (filter);

Expand All @@ -789,7 +791,8 @@ gimp_drawable_filter_commit (GimpDrawableFilter *filter,
gboolean success = TRUE;

g_return_val_if_fail (GIMP_IS_DRAWABLE_FILTER (filter), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (filter->drawable)),
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (filter->drawable)) ||
gimp_viewable_get_parent (GIMP_VIEWABLE (filter->drawable)),
FALSE);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);

Expand Down
29 changes: 29 additions & 0 deletions app/core/gimpgrouplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,35 @@ gimp_group_layer_duplicate (GimpItem *item,
gimp_container_insert (new_private->children,
GIMP_OBJECT (new_child),
position++);

/* Copy any attached layer effects */
if (gimp_drawable_has_filters (GIMP_DRAWABLE (child)))
{
GList *filter_list;
GimpContainer *filters;

filters = gimp_drawable_get_filters (GIMP_DRAWABLE (child));

for (filter_list = GIMP_LIST (filters)->queue->tail; filter_list;
filter_list = g_list_previous (filter_list))
{
if (GIMP_IS_DRAWABLE_FILTER (filter_list->data))
{
GimpDrawableFilter *old_filter = filter_list->data;
GimpDrawableFilter *filter;

filter =
gimp_drawable_filter_duplicate (GIMP_DRAWABLE (new_child),
old_filter);

gimp_drawable_filter_apply (filter, NULL);
gimp_drawable_filter_commit (filter, TRUE, NULL, FALSE);

gimp_drawable_filter_layer_mask_freeze (filter);
g_object_unref (filter);
}
}
}
}

/* force the projection to reallocate itself */
Expand Down
2 changes: 1 addition & 1 deletion app/core/gimpimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -3340,7 +3340,7 @@ gimp_image_mask_changed (GimpImage *image)
}

/**
* gimp_item_mask_intersect:
* gimp_image_mask_intersect:
* @image: the #GimpImage
* @items: a list of #GimpItem
* @x: (out) (optional): return location for x
Expand Down
4 changes: 3 additions & 1 deletion app/core/gimpitem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,9 @@ gimp_item_mask_intersect (GimpItem *item,
gboolean retval;

g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
g_return_val_if_fail (gimp_item_is_attached (item) ||
gimp_viewable_get_parent (GIMP_VIEWABLE (item)),
FALSE);

image = gimp_item_get_image (item);
selection = gimp_image_get_mask (image);
Expand Down

0 comments on commit 8d43ba6

Please sign in to comment.