don't modify the rectangle while moving, and stick to edges when going out

2005-09-13  Karine Delvare  <kdelvare@nerim.net>

  * app/tools/gimprectangletool.c: don't modify the rectangle while
  moving, and stick to edges when going out of image boundaries.
This commit is contained in:
Karine Delvare 2005-09-13 19:07:17 +00:00 committed by Karine Delvare
parent f3d9a51e18
commit 9c3bc6f64b
2 changed files with 55 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2005-09-13 Karine Delvare <kdelvare@nerim.net>
* app/tools/gimprectangletool.c: don't modify the rectangle while
moving, and stick to edges when going out of image boundaries.
2005-09-13 Sven Neumann <sven@gimp.org>
* app/actions/edit-actions.c: use "Undo History" instead of "Undo

View File

@ -156,26 +156,26 @@ gimp_rectangle_tool_iface_base_init (GimpRectangleToolInterface *tool_iface)
g_object_interface_install_property (tool_iface,
g_param_spec_int ("startx",
NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
-GIMP_MAX_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE,
0,
G_PARAM_READWRITE));
g_object_interface_install_property (tool_iface,
g_param_spec_int ("starty",
NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
-GIMP_MAX_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE,
0,
G_PARAM_READWRITE));
g_object_interface_install_property (tool_iface,
g_param_spec_int ("lastx",
NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
-GIMP_MAX_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE,
0,
G_PARAM_READWRITE));
g_object_interface_install_property (tool_iface,
g_param_spec_int ("lasty",
NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
-GIMP_MAX_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE,
0,
G_PARAM_READWRITE));
@ -1453,7 +1453,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
case RECT_RESIZING_UPPER_LEFT:
case RECT_RESIZING_LOWER_LEFT:
case RECT_RESIZING_LEFT:
x1 = rx1 + inc_x;
if (x1 < 0 && x1 + inc_x < 0)
x1 = 0;
else
x1 = rx1 + inc_x;
if (fixed_width)
{
x2 = x1 + width;
@ -1494,7 +1497,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
case RECT_RESIZING_UPPER_RIGHT:
case RECT_RESIZING_LOWER_RIGHT:
case RECT_RESIZING_RIGHT:
x2 = rx2 + inc_x;
if (x2 > max_x && x2 + inc_x > max_x)
x2 = max_x;
else
x2 = rx2 + inc_x;
if (fixed_width)
{
x1 = x2 - width;
@ -1540,8 +1546,20 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break;
case RECT_MOVING:
if (rx1 + inc_x < 0 ||
rx2 + inc_x > max_x)
// are we getting out of the image?
if (rx1 + inc_x < 0)
{
x1 = 0;
x2 = rx2 - rx1;
}
else if (rx2 + inc_x > max_x)
{
x1 = rx1 + max_x - rx2;
x2 = max_x;
}
// are we staying out of the image?
else if ((x1 < 0 && x1 + inc_x < 0) ||
(x2 > max_x && x2 + inc_x > max_x))
{
x1 = rx1;
x2 = rx2;
@ -1551,6 +1569,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
x1 = rx1 + inc_x;
x2 = rx2 + inc_x;
}
g_object_set (rectangle, "startx", curx, NULL);
break;
}
@ -1567,7 +1586,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
case RECT_RESIZING_UPPER_LEFT:
case RECT_RESIZING_UPPER_RIGHT:
case RECT_RESIZING_TOP:
y1 = ry1 + inc_y;
if (y1 < 0 && y1 + inc_y < 0)
y1 = 0;
else
y1 = ry1 + inc_y;
if (fixed_height)
{
y2 = y1 + height;
@ -1608,7 +1630,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
case RECT_RESIZING_LOWER_LEFT:
case RECT_RESIZING_LOWER_RIGHT:
case RECT_RESIZING_BOTTOM:
y2 = ry2 + inc_y;
if (y2 > max_y && y2 + inc_y > max_y)
y2 = max_y;
else
y2 = ry2 + inc_y;
if (fixed_height)
{
y1 = y2 - height;
@ -1654,8 +1679,20 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break;
case RECT_MOVING:
if (ry1 + inc_y < 0 ||
ry2 + inc_y > max_y)
// are we getting out of the image?
if (ry1 + inc_y < 0)
{
y1 = 0;
y2 = ry2 - ry1;
}
else if (ry2 + inc_y > max_y)
{
y1 = ry1 + max_y - ry2;
y2 = max_y;
}
// are we staying out of the image?
else if ((y1 < 0 && y1 + inc_y < 0) ||
(y2 > max_y && y2 + inc_y > max_y))
{
y1 = ry1;
y2 = ry2;
@ -1665,6 +1702,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
y1 = ry1 + inc_y;
y2 = ry2 + inc_y;
}
g_object_set (rectangle, "starty", cury, NULL);
break;
}