[gimp] app: special case empty layer groups in gimp_edit_get_paste_offset()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: special case empty layer groups in gimp_edit_get_paste_offset()
- Date: Wed, 21 Sep 2016 07:24:45 +0000 (UTC)
commit f677e156af4f51f5ac0148a9eb4634daac98fa86
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 21 09:22:30 2016 +0200
app: special case empty layer groups in gimp_edit_get_paste_offset()
They have a size of 1x1, treat them a image-sized when pasting layers
on top of them.
(my commit below was also about gimp_edit_get_paste_offset(), not
about gimp_edit_paste() as the log claims)
app/core/gimp-edit.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 9072c51..bd139a9 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -227,19 +227,35 @@ gimp_edit_get_paste_offset (GimpImage *image,
{
/* if pasting to a drawable */
- gint off_x, off_y;
- gint target_x, target_y;
- gint target_width, target_height;
- gint paste_x, paste_y;
- gint paste_width, paste_height;
- gboolean have_mask;
+ GimpContainer *children;
+ gint off_x, off_y;
+ gint target_x, target_y;
+ gint target_width, target_height;
+ gint paste_x, paste_y;
+ gint paste_width, paste_height;
+ gboolean have_mask;
have_mask = ! gimp_channel_is_empty (gimp_image_get_mask (image));
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
- gimp_item_mask_intersect (GIMP_ITEM (drawable),
- &target_x, &target_y,
- &target_width, &target_height);
+
+ children = gimp_viewable_get_children (GIMP_VIEWABLE (drawable));
+
+ if (children && gimp_container_get_n_children (children) == 0)
+ {
+ /* treat empty layer groups as image-sized, use the selection
+ * as target
+ */
+ gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
+ &target_x, &target_y,
+ &target_width, &target_height);
+ }
+ else
+ {
+ gimp_item_mask_intersect (GIMP_ITEM (drawable),
+ &target_x, &target_y,
+ &target_width, &target_height);
+ }
if (! have_mask && /* if we have no mask */
viewport_width > 0 && /* and we have a viewport */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]