Commit 477b4436 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

based on a patch from Joao S. O. Bueno: Ensure that the pasted layer is

2004-09-17  Sven Neumann  <sven@gimp.org>

	* app/core/gimp-edit.c (gimp_edit_paste): based on a patch from
	Joao S. O. Bueno: Ensure that the pasted layer is always within
	the image, if it fits and aligned at top left if it doesn't.
	Fixes bug #142944.
parent d051ce4e
2004-09-17 Sven Neumann <sven@gimp.org>
* app/core/gimp-edit.c (gimp_edit_paste): based on a patch from
Joao S. O. Bueno: Ensure that the pasted layer is always within
the image, if it fits and aligned at top left if it doesn't.
Fixes bug #142944.
2004-09-16 Sven Neumann <sven@gimp.org>
* INSTALL: updated.
......
......@@ -101,6 +101,10 @@ gimp_edit_paste (GimpImage *gimage,
GimpImageType type;
gint center_x;
gint center_y;
gint offset_x;
gint offset_y;
gint width;
gint height;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), NULL);
......@@ -177,8 +181,22 @@ gimp_edit_paste (GimpImage *gimage,
center_y = gimage->height / 2;
}
GIMP_ITEM (layer)->offset_x = center_x - (GIMP_ITEM (layer)->width / 2);
GIMP_ITEM (layer)->offset_y = center_y - (GIMP_ITEM (layer)->height / 2);
width = gimp_item_width (GIMP_ITEM (layer));
height = gimp_item_height (GIMP_ITEM (layer));
offset_x = center_x - width / 2;
offset_y = center_y - height / 2;
/* Ensure that the pasted layer is always within the image, if it
* fits and aligned at top left if it doesn't. (See bug #142944).
*/
offset_x = MIN (offset_x, gimage->width - width);
offset_y = MIN (offset_y, gimage->height - height);
offset_x = MAX (offset_x, 0);
offset_y = MAX (offset_y, 0);
GIMP_ITEM (layer)->offset_x = offset_x;
GIMP_ITEM (layer)->offset_y = offset_y;
/* If there is a selection mask clear it--
* this might not always be desired, but in general,
......
Supports Markdown
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