make a similar fix as in my last commit for snapping the guides.

2004-02-13  Simon Budig  <simon@gimp.org>

	* app/core/gimpimage-guides.[ch]: make a similar fix as in my
	last commit for snapping the guides.

	* app/tools/gimpmovetool.c: use the fixed version.
This commit is contained in:
Simon Budig 2004-02-13 14:04:41 +00:00 committed by Simon Budig
parent ae81af14f4
commit ce5e592e23
4 changed files with 38 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2004-02-13 Simon Budig <simon@gimp.org>
* app/core/gimpimage-guides.[ch]: make a similar fix as in my
last commit for snapping the guides.
* app/tools/gimpmovetool.c: use the fixed version.
2004-02-13 Simon Budig <simon@gimp.org>
* app/core/gimpimage-snap.[ch]: make the snapping width a

View File

@ -30,9 +30,6 @@
#include "gimp-intl.h"
#define GUIDE_EPSILON 5
/* public functions */
GimpGuide *
@ -177,7 +174,9 @@ gimp_image_move_guide (GimpImage *gimage,
GimpGuide *
gimp_image_find_guide (GimpImage *gimage,
gdouble x,
gdouble y)
gdouble y,
gdouble epsilon_x,
gdouble epsilon_y)
{
GList *list;
GimpGuide *guide;
@ -186,6 +185,7 @@ gimp_image_find_guide (GimpImage *gimage,
gdouble mindist = G_MAXDOUBLE;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (epsilon_x > 0 && epsilon_y > 0, NULL);
if (x < 0 || x >= gimage->width ||
y < 0 || y >= gimage->height)
@ -204,21 +204,27 @@ gimp_image_find_guide (GimpImage *gimage,
{
case GIMP_ORIENTATION_HORIZONTAL:
dist = ABS (guide->position - y);
if (dist < MIN (epsilon_y, mindist))
{
mindist = dist;
ret = guide;
}
break;
/* mindist always is in vertical resolution to make it comparable */
case GIMP_ORIENTATION_VERTICAL:
dist = ABS (guide->position - x);
if (dist < MIN (epsilon_x, mindist / epsilon_y * epsilon_x))
{
mindist = dist * epsilon_y / epsilon_x;
ret = guide;
}
break;
default:
continue;
}
if (dist < MIN (GUIDE_EPSILON, mindist))
{
mindist = dist;
ret = guide;
}
}
return ret;

View File

@ -1,5 +1,5 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -52,7 +52,9 @@ void gimp_image_move_guide (GimpImage *gimage,
GimpGuide * gimp_image_find_guide (GimpImage *gimage,
gdouble x,
gdouble y);
gdouble y,
gdouble epsilon_x,
gdouble epsilon_y);
#endif /* __GIMP_IMAGE_GUIDES_H__ */

View File

@ -51,6 +51,9 @@
#include "gimp-intl.h"
#define SNAP_WIDTH 5.0
/* local function prototypes */
static void gimp_move_tool_class_init (GimpMoveToolClass *klass);
@ -292,7 +295,9 @@ gimp_move_tool_button_press (GimpTool *tool,
else
{
if (gimp_display_shell_get_show_guides (shell) &&
(guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y)))
(guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y,
FUNSCALEX (shell, SNAP_WIDTH),
FUNSCALEY (shell, SNAP_WIDTH))))
{
move->guide = guide;
move->moving_guide = TRUE;
@ -564,7 +569,9 @@ gimp_move_tool_oper_update (GimpTool *tool,
gimp_display_shell_get_show_guides (shell) &&
shell->proximity)
{
guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y);
guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y,
FUNSCALEX (shell, SNAP_WIDTH),
FUNSCALEY (shell, SNAP_WIDTH));
}
if (move->guide && move->guide != guide)
@ -638,7 +645,9 @@ gimp_move_tool_cursor_update (GimpTool *tool,
GimpLayer *layer;
if (gimp_display_shell_get_show_guides (shell) &&
(guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y)))
(guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y,
FUNSCALEX (shell, SNAP_WIDTH),
FUNSCALEY (shell, SNAP_WIDTH))))
{
cursor = GDK_HAND2;
tool_cursor = GIMP_HAND_TOOL_CURSOR;