app: fix conditions for guide and sample point moving/removing

Simply check the transfomred coords against the canvas extents and the
untransformed against the image contents instead of using
untransform_viewport(). The code is easier to read now, and
untransform_viewport() is still broken and can't really be implemented
properly when the canvas is rotated.
This commit is contained in:
Michael Natterer 2013-04-25 09:30:46 +02:00
parent 36853815f9
commit 62c5a737fd
2 changed files with 31 additions and 31 deletions

View File

@ -255,7 +255,6 @@ gimp_color_tool_button_release (GimpTool *tool,
{
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
GimpDisplayShell *shell = gimp_display_get_shell (display);
GimpImage *image = gimp_display_get_image (display);
/* Chain up to halt the tool */
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state,
@ -266,7 +265,9 @@ gimp_color_tool_button_release (GimpTool *tool,
if (color_tool->moving_sample_point)
{
gint x, y, width, height;
GimpImage *image = gimp_display_get_image (display);
gint width = gimp_image_get_width (image);
gint height = gimp_image_get_height (image);
gimp_tool_pop_status (tool, display);
@ -283,12 +284,12 @@ gimp_color_tool_button_release (GimpTool *tool,
return;
}
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
if ((color_tool->sample_point_x < x ||
color_tool->sample_point_x > (x + width - 1) ||
color_tool->sample_point_y < y ||
color_tool->sample_point_y > (y + height - 1)))
if (color_tool->sample_point_x == SAMPLE_POINT_POSITION_INVALID ||
color_tool->sample_point_x < 0 ||
color_tool->sample_point_x >= width ||
color_tool->sample_point_y == SAMPLE_POINT_POSITION_INVALID ||
color_tool->sample_point_y < 0 ||
color_tool->sample_point_y >= height)
{
if (color_tool->sample_point)
{
@ -367,18 +368,17 @@ gimp_color_tool_motion (GimpTool *tool,
}
else
{
gint x, y, width, height;
GimpImage *image = gimp_display_get_image (display);
gint width = gimp_image_get_width (image);
gint height = gimp_image_get_height (image);
color_tool->sample_point_x = floor (coords->x);
color_tool->sample_point_y = floor (coords->y);
gimp_display_shell_untransform_viewport (shell, &x, &y,
&width, &height);
if ((color_tool->sample_point_x < x ||
color_tool->sample_point_x > (x + width - 1) ||
color_tool->sample_point_y < y ||
color_tool->sample_point_y > (y + height - 1)))
if (color_tool->sample_point_x < 0 ||
color_tool->sample_point_x >= width ||
color_tool->sample_point_y < 0 ||
color_tool->sample_point_y >= height)
{
delete_point = TRUE;
}

View File

@ -409,7 +409,8 @@ gimp_move_tool_button_release (GimpTool *tool,
if (move->moving_guide)
{
gboolean delete_guide = FALSE;
gint x, y, width, height;
gint width = gimp_image_get_width (image);
gint height = gimp_image_get_height (image);
gimp_tool_pop_status (tool, display);
@ -429,19 +430,19 @@ gimp_move_tool_button_release (GimpTool *tool,
return;
}
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
switch (move->guide_orientation)
{
case GIMP_ORIENTATION_HORIZONTAL:
if ((move->guide_position < y) ||
(move->guide_position > (y + height)))
if (move->guide_position == GUIDE_POSITION_INVALID ||
move->guide_position < 0 ||
move->guide_position >= height)
delete_guide = TRUE;
break;
case GIMP_ORIENTATION_VERTICAL:
if ((move->guide_position < x) ||
(move->guide_position > (x + width)))
if (move->guide_position == GUIDE_POSITION_INVALID ||
move->guide_position < 0 ||
move->guide_position >= width)
delete_guide = TRUE;
break;
@ -566,27 +567,26 @@ gimp_move_tool_motion (GimpTool *tool,
}
else
{
gint x, y, width, height;
GimpImage *image = gimp_display_get_image (display);
gint width = gimp_image_get_width (image);
gint height = gimp_image_get_height (image);
if (move->guide_orientation == GIMP_ORIENTATION_HORIZONTAL)
move->guide_position = RINT (coords->y);
else
move->guide_position = RINT (coords->x);
gimp_display_shell_untransform_viewport (shell, &x, &y,
&width, &height);
switch (move->guide_orientation)
{
case GIMP_ORIENTATION_HORIZONTAL:
if ((move->guide_position < y) ||
(move->guide_position > (y + height)))
if (move->guide_position < 0 ||
move->guide_position >= height)
delete_guide = TRUE;
break;
case GIMP_ORIENTATION_VERTICAL:
if ((move->guide_position < x) ||
(move->guide_position > (x + width)))
if (move->guide_position < 0 ||
move->guide_position >= width)
delete_guide = TRUE;
break;