Commit 0cd174e1 authored by Karine Delvare's avatar Karine Delvare Committed by Karine Delvare

stay within image boundaries.

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

  * app/tools/gimprectangletool.c: stay within image boundaries.
parent dc5bfc3f
2005-09-04 Karine Delvare <kdelvare@nerim.net>
* app/tools/gimprectangletool.c: stay within image boundaries.
2005-09-04 Michael Natterer <mitch@gimp.org> 2005-09-04 Michael Natterer <mitch@gimp.org>
Cleaned up and fixed the order in which default tool options and Cleaned up and fixed the order in which default tool options and
......
...@@ -1444,6 +1444,10 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1444,6 +1444,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
switch (function) switch (function)
{ {
case RECT_CREATING: case RECT_CREATING:
if (x1 < 0)
x1 = 0;
if (x2 > max_x)
x2 = max_x;
break; break;
case RECT_RESIZING_UPPER_LEFT: case RECT_RESIZING_UPPER_LEFT:
...@@ -1481,6 +1485,8 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1481,6 +1485,8 @@ gimp_rectangle_tool_motion (GimpTool *tool,
else else
{ {
x2 = MAX (x1, rx2); x2 = MAX (x1, rx2);
if (x1 < 0)
x1 = 0;
} }
g_object_set (rectangle, "startx", curx, NULL); g_object_set (rectangle, "startx", curx, NULL);
break; break;
...@@ -1520,6 +1526,8 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1520,6 +1526,8 @@ gimp_rectangle_tool_motion (GimpTool *tool,
else else
{ {
x1 = MIN (rx1, x2); x1 = MIN (rx1, x2);
if (x2 > max_x)
x2 = max_x;
} }
g_object_set (rectangle, "startx", curx, NULL); g_object_set (rectangle, "startx", curx, NULL);
break; break;
...@@ -1532,9 +1540,8 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1532,9 +1540,8 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break; break;
case RECT_MOVING: case RECT_MOVING:
if (fixed_width && if (rx1 + inc_x < 0 ||
(rx1 + inc_x < 0 || rx2 + inc_x > max_x)
rx2 + inc_x > max_x))
{ {
x1 = rx1; x1 = rx1;
x2 = rx2; x2 = rx2;
...@@ -1551,6 +1558,10 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1551,6 +1558,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
switch (function) switch (function)
{ {
case RECT_CREATING: case RECT_CREATING:
if (y1 < 0)
y1 = 0;
if (y2 > max_y)
y2 = max_y;
break; break;
case RECT_RESIZING_UPPER_LEFT: case RECT_RESIZING_UPPER_LEFT:
...@@ -1588,6 +1599,8 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1588,6 +1599,8 @@ gimp_rectangle_tool_motion (GimpTool *tool,
else else
{ {
y2 = MAX (y1, ry2); y2 = MAX (y1, ry2);
if (y1 < 0)
y1 = 0;
} }
g_object_set (rectangle, "starty", cury, NULL); g_object_set (rectangle, "starty", cury, NULL);
break; break;
...@@ -1627,6 +1640,8 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1627,6 +1640,8 @@ gimp_rectangle_tool_motion (GimpTool *tool,
else else
{ {
y1 = MIN (ry1, y2); y1 = MIN (ry1, y2);
if (y2 > max_y)
y2 = max_y;
} }
g_object_set (rectangle, "starty", cury, NULL); g_object_set (rectangle, "starty", cury, NULL);
break; break;
...@@ -1639,9 +1654,8 @@ gimp_rectangle_tool_motion (GimpTool *tool, ...@@ -1639,9 +1654,8 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break; break;
case RECT_MOVING: case RECT_MOVING:
if (fixed_height && if (ry1 + inc_y < 0 ||
(ry1 + inc_y < 0 || ry2 + inc_y > max_y)
ry2 + inc_y > max_y))
{ {
y1 = ry1; y1 = ry1;
y2 = ry2; y2 = ry2;
......
Markdown is supported
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