this time cursor_update feedback is _really_ correct: for closed curves,
2000-03-03 Michael Natterer <mitch@gimp.org> * app/iscissors.c: this time cursor_update feedback is _really_ correct: for closed curves, show the "point" cursor if a mouse click will modify the curve and the "bad" cursor if a mouse click will do nothing. Seems it was not too hard to understand how it works... * plug-ins/common/uniteditor.c: for consistency, did a s/"Delete","Undelete"/"Don't Save","Save"/.
This commit is contained in:

committed by
Michael Natterer

parent
83e8cf3609
commit
f4917054a9
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2000-03-03 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/iscissors.c: this time cursor_update feedback is _really_
|
||||||
|
correct: for closed curves, show the "point" cursor if a mouse
|
||||||
|
click will modify the curve and the "bad" cursor if a mouse click
|
||||||
|
will do nothing. Seems it was not too hard to understand how it
|
||||||
|
works...
|
||||||
|
|
||||||
|
* plug-ins/common/uniteditor.c: for consistency, did a
|
||||||
|
s/"Delete","Undelete"/"Don't Save","Save"/.
|
||||||
|
|
||||||
Thu Mar 2 23:27:59 CET 2000 Marc Lehmann <pcg@goof.com>
|
Thu Mar 2 23:27:59 CET 2000 Marc Lehmann <pcg@goof.com>
|
||||||
|
|
||||||
* configure.in: Fix $dirprefix to $topdir in perl part.
|
* configure.in: Fix $dirprefix to $topdir in perl part.
|
||||||
|
129
app/iscissors.c
129
app/iscissors.c
@ -298,8 +298,16 @@ static void iscissors_draw_curve (GDisplay *gdisp,
|
|||||||
ICurve *curve);
|
ICurve *curve);
|
||||||
static void iscissors_free_icurves (GSList *list);
|
static void iscissors_free_icurves (GSList *list);
|
||||||
static void iscissors_free_buffers (Iscissors *iscissors);
|
static void iscissors_free_buffers (Iscissors *iscissors);
|
||||||
static gint clicked_on_vertex (Tool *tool);
|
|
||||||
static gint clicked_on_curve (Tool *tool);
|
static gint mouse_over_vertex (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
|
static gboolean clicked_on_vertex (Tool *tool);
|
||||||
|
static GSList * mouse_over_curve (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
|
static gboolean clicked_on_curve (Tool *tool);
|
||||||
|
|
||||||
static void precalculate_arrays (void);
|
static void precalculate_arrays (void);
|
||||||
static GPtrArray * plot_pixels (Iscissors *iscissors,
|
static GPtrArray * plot_pixels (Iscissors *iscissors,
|
||||||
TempBuf *dp_buf,
|
TempBuf *dp_buf,
|
||||||
@ -899,7 +907,12 @@ iscissors_oper_update (Tool *tool,
|
|||||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
||||||
&x, &y, FALSE, FALSE);
|
&x, &y, FALSE, FALSE);
|
||||||
|
|
||||||
if (iscissors->connected && iscissors->mask &&
|
if (mouse_over_vertex (iscissors, x, y) ||
|
||||||
|
mouse_over_curve (iscissors, x, y))
|
||||||
|
{
|
||||||
|
iscissors->op = SELECTION_MOVE_MASK; /* abused */
|
||||||
|
}
|
||||||
|
else if (iscissors->connected && iscissors->mask &&
|
||||||
channel_value (iscissors->mask, x, y))
|
channel_value (iscissors->mask, x, y))
|
||||||
{
|
{
|
||||||
if (mevent->state & GDK_SHIFT_MASK &&
|
if (mevent->state & GDK_SHIFT_MASK &&
|
||||||
@ -920,6 +933,10 @@ iscissors_oper_update (Tool *tool,
|
|||||||
iscissors->op = SELECTION_REPLACE;
|
iscissors->op = SELECTION_REPLACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (iscissors->connected && iscissors->mask)
|
||||||
|
{
|
||||||
|
iscissors->op = SELECTION_MOVE; /* abused */
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iscissors->op = -1;
|
iscissors->op = -1;
|
||||||
@ -993,6 +1010,12 @@ iscissors_cursor_update (Tool *tool,
|
|||||||
case SELECTION_INTERSECT:
|
case SELECTION_INTERSECT:
|
||||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_INTERSECT_CURSOR);
|
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_INTERSECT_CURSOR);
|
||||||
break;
|
break;
|
||||||
|
case SELECTION_MOVE_MASK: /* abused */
|
||||||
|
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_POINT_CURSOR);
|
||||||
|
break;
|
||||||
|
case SELECTION_MOVE: /* abused */
|
||||||
|
gdisplay_install_tool_cursor (gdisp, GIMP_BAD_CURSOR);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_CURSOR);
|
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_CURSOR);
|
||||||
break;
|
break;
|
||||||
@ -1150,15 +1173,14 @@ iscissors_free_buffers (Iscissors *iscissors)
|
|||||||
|
|
||||||
/* XXX need some scan-conversion routines from somewhere. maybe. ? */
|
/* XXX need some scan-conversion routines from somewhere. maybe. ? */
|
||||||
|
|
||||||
static gboolean
|
static gint
|
||||||
clicked_on_vertex (Tool *tool)
|
mouse_over_vertex (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y)
|
||||||
{
|
{
|
||||||
Iscissors * iscissors;
|
|
||||||
GSList *list;
|
GSList *list;
|
||||||
ICurve *curve;
|
ICurve *curve;
|
||||||
int curves_found = 0;
|
gint curves_found = 0;
|
||||||
|
|
||||||
iscissors = (Iscissors *) tool->private;
|
|
||||||
|
|
||||||
/* traverse through the list, returning non-zero if the current cursor
|
/* traverse through the list, returning non-zero if the current cursor
|
||||||
* position is on an existing curve vertex. Set the curve1 and curve2
|
* position is on an existing curve vertex. Set the curve1 and curve2
|
||||||
@ -1173,32 +1195,46 @@ clicked_on_vertex (Tool *tool)
|
|||||||
{
|
{
|
||||||
curve = (ICurve *) list->data;
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
if (abs (curve->x1 - iscissors->x) < POINT_HALFWIDTH &&
|
if (abs (curve->x1 - x) < POINT_HALFWIDTH &&
|
||||||
abs (curve->y1 - iscissors->y) < POINT_HALFWIDTH)
|
abs (curve->y1 - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
iscissors->curve1 = curve;
|
iscissors->curve1 = curve;
|
||||||
if (curves_found++)
|
if (curves_found++)
|
||||||
return TRUE;
|
return curves_found;
|
||||||
}
|
}
|
||||||
else if (abs (curve->x2 - iscissors->x) < POINT_HALFWIDTH &&
|
else if (abs (curve->x2 - x) < POINT_HALFWIDTH &&
|
||||||
abs (curve->y2 - iscissors->y) < POINT_HALFWIDTH)
|
abs (curve->y2 - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
iscissors->curve2 = curve;
|
iscissors->curve2 = curve;
|
||||||
if (curves_found++)
|
if (curves_found++)
|
||||||
return TRUE;
|
return curves_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = g_slist_next (list);
|
list = g_slist_next (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return curves_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clicked_on_vertex (Tool *tool)
|
||||||
|
{
|
||||||
|
Iscissors *iscissors;
|
||||||
|
gint curves_found = 0;
|
||||||
|
|
||||||
|
iscissors = (Iscissors *) tool->private;
|
||||||
|
|
||||||
|
curves_found = mouse_over_vertex (iscissors, iscissors->x, iscissors->y);
|
||||||
|
|
||||||
|
if (curves_found > 1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
/* if only one curve was found, the curves are unconnected, and
|
/* if only one curve was found, the curves are unconnected, and
|
||||||
* the user only wants to move either the first or last point
|
* the user only wants to move either the first or last point
|
||||||
* disallow this for now.
|
* disallow this for now.
|
||||||
*/
|
*/
|
||||||
if (curves_found == 1)
|
if (curves_found == 1)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
/* no vertices were found at the cursor click point. Now check whether
|
/* no vertices were found at the cursor click point. Now check whether
|
||||||
* the click occured on a curve. If so, create a new vertex there and
|
* the click occured on a curve. If so, create a new vertex there and
|
||||||
@ -1208,26 +1244,23 @@ clicked_on_vertex (Tool *tool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static GSList *
|
||||||
clicked_on_curve (Tool *tool)
|
mouse_over_curve (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y)
|
||||||
{
|
{
|
||||||
Iscissors *iscissors;
|
GSList *list;
|
||||||
GSList *list, *new_link;
|
|
||||||
gpointer *pt;
|
gpointer *pt;
|
||||||
gint len;
|
gint len;
|
||||||
ICurve *curve, *new_curve;
|
ICurve *curve;
|
||||||
guint32 coords;
|
guint32 coords;
|
||||||
gint tx, ty;
|
gint tx, ty;
|
||||||
|
|
||||||
iscissors = (Iscissors *) tool->private;
|
/* traverse through the list, returning the curve segment's list element
|
||||||
|
* if the current cursor position is on a curve...
|
||||||
/* traverse through the list, returning non-zero if the current cursor
|
|
||||||
* position is on a curve... If this occurs, replace the curve with two
|
|
||||||
* new curves, separated by the new vertex.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
list = iscissors->curves;
|
for (list = iscissors->curves; list; list = g_slist_next (list))
|
||||||
while (list)
|
|
||||||
{
|
{
|
||||||
curve = (ICurve *) list->data;
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
@ -1241,15 +1274,43 @@ clicked_on_curve (Tool *tool)
|
|||||||
ty = coords >> 16;
|
ty = coords >> 16;
|
||||||
|
|
||||||
/* Is the specified point close enough to the curve? */
|
/* Is the specified point close enough to the curve? */
|
||||||
if (abs (tx - iscissors->x) < POINT_HALFWIDTH &&
|
if (abs (tx - x) < POINT_HALFWIDTH &&
|
||||||
abs (ty - iscissors->y) < POINT_HALFWIDTH)
|
abs (ty - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clicked_on_curve (Tool *tool)
|
||||||
|
{
|
||||||
|
Iscissors *iscissors;
|
||||||
|
GSList *list, *new_link;
|
||||||
|
ICurve *curve, *new_curve;
|
||||||
|
|
||||||
|
iscissors = (Iscissors *) tool->private;
|
||||||
|
|
||||||
|
/* traverse through the list, getting back the curve segment's list
|
||||||
|
* element if the current cursor position is on a curve...
|
||||||
|
* If this occurs, replace the curve with two new curves,
|
||||||
|
* separated by a new vertex.
|
||||||
|
*/
|
||||||
|
list = mouse_over_curve (iscissors, iscissors->x, iscissors->y);
|
||||||
|
|
||||||
|
if (list)
|
||||||
|
{
|
||||||
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
/* Since we're modifying the curve, undraw the existing one */
|
/* Since we're modifying the curve, undraw the existing one */
|
||||||
iscissors->draw = DRAW_CURVE;
|
iscissors->draw = DRAW_CURVE;
|
||||||
draw_core_pause (iscissors->core, tool);
|
draw_core_pause (iscissors->core, tool);
|
||||||
|
|
||||||
/* Create the new curve */
|
/* Create the new curve */
|
||||||
new_curve = g_malloc (sizeof (ICurve));
|
new_curve = g_new (ICurve, 1);
|
||||||
|
|
||||||
new_curve->x2 = curve->x2;
|
new_curve->x2 = curve->x2;
|
||||||
new_curve->y2 = curve->y2;
|
new_curve->y2 = curve->y2;
|
||||||
@ -1273,10 +1334,6 @@ clicked_on_curve (Tool *tool)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
list = g_slist_next (list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -298,8 +298,16 @@ static void iscissors_draw_curve (GDisplay *gdisp,
|
|||||||
ICurve *curve);
|
ICurve *curve);
|
||||||
static void iscissors_free_icurves (GSList *list);
|
static void iscissors_free_icurves (GSList *list);
|
||||||
static void iscissors_free_buffers (Iscissors *iscissors);
|
static void iscissors_free_buffers (Iscissors *iscissors);
|
||||||
static gint clicked_on_vertex (Tool *tool);
|
|
||||||
static gint clicked_on_curve (Tool *tool);
|
static gint mouse_over_vertex (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
|
static gboolean clicked_on_vertex (Tool *tool);
|
||||||
|
static GSList * mouse_over_curve (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
|
static gboolean clicked_on_curve (Tool *tool);
|
||||||
|
|
||||||
static void precalculate_arrays (void);
|
static void precalculate_arrays (void);
|
||||||
static GPtrArray * plot_pixels (Iscissors *iscissors,
|
static GPtrArray * plot_pixels (Iscissors *iscissors,
|
||||||
TempBuf *dp_buf,
|
TempBuf *dp_buf,
|
||||||
@ -899,7 +907,12 @@ iscissors_oper_update (Tool *tool,
|
|||||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
||||||
&x, &y, FALSE, FALSE);
|
&x, &y, FALSE, FALSE);
|
||||||
|
|
||||||
if (iscissors->connected && iscissors->mask &&
|
if (mouse_over_vertex (iscissors, x, y) ||
|
||||||
|
mouse_over_curve (iscissors, x, y))
|
||||||
|
{
|
||||||
|
iscissors->op = SELECTION_MOVE_MASK; /* abused */
|
||||||
|
}
|
||||||
|
else if (iscissors->connected && iscissors->mask &&
|
||||||
channel_value (iscissors->mask, x, y))
|
channel_value (iscissors->mask, x, y))
|
||||||
{
|
{
|
||||||
if (mevent->state & GDK_SHIFT_MASK &&
|
if (mevent->state & GDK_SHIFT_MASK &&
|
||||||
@ -920,6 +933,10 @@ iscissors_oper_update (Tool *tool,
|
|||||||
iscissors->op = SELECTION_REPLACE;
|
iscissors->op = SELECTION_REPLACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (iscissors->connected && iscissors->mask)
|
||||||
|
{
|
||||||
|
iscissors->op = SELECTION_MOVE; /* abused */
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iscissors->op = -1;
|
iscissors->op = -1;
|
||||||
@ -993,6 +1010,12 @@ iscissors_cursor_update (Tool *tool,
|
|||||||
case SELECTION_INTERSECT:
|
case SELECTION_INTERSECT:
|
||||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_INTERSECT_CURSOR);
|
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_INTERSECT_CURSOR);
|
||||||
break;
|
break;
|
||||||
|
case SELECTION_MOVE_MASK: /* abused */
|
||||||
|
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_POINT_CURSOR);
|
||||||
|
break;
|
||||||
|
case SELECTION_MOVE: /* abused */
|
||||||
|
gdisplay_install_tool_cursor (gdisp, GIMP_BAD_CURSOR);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_CURSOR);
|
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_CURSOR);
|
||||||
break;
|
break;
|
||||||
@ -1150,15 +1173,14 @@ iscissors_free_buffers (Iscissors *iscissors)
|
|||||||
|
|
||||||
/* XXX need some scan-conversion routines from somewhere. maybe. ? */
|
/* XXX need some scan-conversion routines from somewhere. maybe. ? */
|
||||||
|
|
||||||
static gboolean
|
static gint
|
||||||
clicked_on_vertex (Tool *tool)
|
mouse_over_vertex (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y)
|
||||||
{
|
{
|
||||||
Iscissors * iscissors;
|
|
||||||
GSList *list;
|
GSList *list;
|
||||||
ICurve *curve;
|
ICurve *curve;
|
||||||
int curves_found = 0;
|
gint curves_found = 0;
|
||||||
|
|
||||||
iscissors = (Iscissors *) tool->private;
|
|
||||||
|
|
||||||
/* traverse through the list, returning non-zero if the current cursor
|
/* traverse through the list, returning non-zero if the current cursor
|
||||||
* position is on an existing curve vertex. Set the curve1 and curve2
|
* position is on an existing curve vertex. Set the curve1 and curve2
|
||||||
@ -1173,32 +1195,46 @@ clicked_on_vertex (Tool *tool)
|
|||||||
{
|
{
|
||||||
curve = (ICurve *) list->data;
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
if (abs (curve->x1 - iscissors->x) < POINT_HALFWIDTH &&
|
if (abs (curve->x1 - x) < POINT_HALFWIDTH &&
|
||||||
abs (curve->y1 - iscissors->y) < POINT_HALFWIDTH)
|
abs (curve->y1 - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
iscissors->curve1 = curve;
|
iscissors->curve1 = curve;
|
||||||
if (curves_found++)
|
if (curves_found++)
|
||||||
return TRUE;
|
return curves_found;
|
||||||
}
|
}
|
||||||
else if (abs (curve->x2 - iscissors->x) < POINT_HALFWIDTH &&
|
else if (abs (curve->x2 - x) < POINT_HALFWIDTH &&
|
||||||
abs (curve->y2 - iscissors->y) < POINT_HALFWIDTH)
|
abs (curve->y2 - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
iscissors->curve2 = curve;
|
iscissors->curve2 = curve;
|
||||||
if (curves_found++)
|
if (curves_found++)
|
||||||
return TRUE;
|
return curves_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = g_slist_next (list);
|
list = g_slist_next (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return curves_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clicked_on_vertex (Tool *tool)
|
||||||
|
{
|
||||||
|
Iscissors *iscissors;
|
||||||
|
gint curves_found = 0;
|
||||||
|
|
||||||
|
iscissors = (Iscissors *) tool->private;
|
||||||
|
|
||||||
|
curves_found = mouse_over_vertex (iscissors, iscissors->x, iscissors->y);
|
||||||
|
|
||||||
|
if (curves_found > 1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
/* if only one curve was found, the curves are unconnected, and
|
/* if only one curve was found, the curves are unconnected, and
|
||||||
* the user only wants to move either the first or last point
|
* the user only wants to move either the first or last point
|
||||||
* disallow this for now.
|
* disallow this for now.
|
||||||
*/
|
*/
|
||||||
if (curves_found == 1)
|
if (curves_found == 1)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
/* no vertices were found at the cursor click point. Now check whether
|
/* no vertices were found at the cursor click point. Now check whether
|
||||||
* the click occured on a curve. If so, create a new vertex there and
|
* the click occured on a curve. If so, create a new vertex there and
|
||||||
@ -1208,26 +1244,23 @@ clicked_on_vertex (Tool *tool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static GSList *
|
||||||
clicked_on_curve (Tool *tool)
|
mouse_over_curve (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y)
|
||||||
{
|
{
|
||||||
Iscissors *iscissors;
|
GSList *list;
|
||||||
GSList *list, *new_link;
|
|
||||||
gpointer *pt;
|
gpointer *pt;
|
||||||
gint len;
|
gint len;
|
||||||
ICurve *curve, *new_curve;
|
ICurve *curve;
|
||||||
guint32 coords;
|
guint32 coords;
|
||||||
gint tx, ty;
|
gint tx, ty;
|
||||||
|
|
||||||
iscissors = (Iscissors *) tool->private;
|
/* traverse through the list, returning the curve segment's list element
|
||||||
|
* if the current cursor position is on a curve...
|
||||||
/* traverse through the list, returning non-zero if the current cursor
|
|
||||||
* position is on a curve... If this occurs, replace the curve with two
|
|
||||||
* new curves, separated by the new vertex.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
list = iscissors->curves;
|
for (list = iscissors->curves; list; list = g_slist_next (list))
|
||||||
while (list)
|
|
||||||
{
|
{
|
||||||
curve = (ICurve *) list->data;
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
@ -1241,15 +1274,43 @@ clicked_on_curve (Tool *tool)
|
|||||||
ty = coords >> 16;
|
ty = coords >> 16;
|
||||||
|
|
||||||
/* Is the specified point close enough to the curve? */
|
/* Is the specified point close enough to the curve? */
|
||||||
if (abs (tx - iscissors->x) < POINT_HALFWIDTH &&
|
if (abs (tx - x) < POINT_HALFWIDTH &&
|
||||||
abs (ty - iscissors->y) < POINT_HALFWIDTH)
|
abs (ty - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clicked_on_curve (Tool *tool)
|
||||||
|
{
|
||||||
|
Iscissors *iscissors;
|
||||||
|
GSList *list, *new_link;
|
||||||
|
ICurve *curve, *new_curve;
|
||||||
|
|
||||||
|
iscissors = (Iscissors *) tool->private;
|
||||||
|
|
||||||
|
/* traverse through the list, getting back the curve segment's list
|
||||||
|
* element if the current cursor position is on a curve...
|
||||||
|
* If this occurs, replace the curve with two new curves,
|
||||||
|
* separated by a new vertex.
|
||||||
|
*/
|
||||||
|
list = mouse_over_curve (iscissors, iscissors->x, iscissors->y);
|
||||||
|
|
||||||
|
if (list)
|
||||||
|
{
|
||||||
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
/* Since we're modifying the curve, undraw the existing one */
|
/* Since we're modifying the curve, undraw the existing one */
|
||||||
iscissors->draw = DRAW_CURVE;
|
iscissors->draw = DRAW_CURVE;
|
||||||
draw_core_pause (iscissors->core, tool);
|
draw_core_pause (iscissors->core, tool);
|
||||||
|
|
||||||
/* Create the new curve */
|
/* Create the new curve */
|
||||||
new_curve = g_malloc (sizeof (ICurve));
|
new_curve = g_new (ICurve, 1);
|
||||||
|
|
||||||
new_curve->x2 = curve->x2;
|
new_curve->x2 = curve->x2;
|
||||||
new_curve->y2 = curve->y2;
|
new_curve->y2 = curve->y2;
|
||||||
@ -1273,10 +1334,6 @@ clicked_on_curve (Tool *tool)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
list = g_slist_next (list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -298,8 +298,16 @@ static void iscissors_draw_curve (GDisplay *gdisp,
|
|||||||
ICurve *curve);
|
ICurve *curve);
|
||||||
static void iscissors_free_icurves (GSList *list);
|
static void iscissors_free_icurves (GSList *list);
|
||||||
static void iscissors_free_buffers (Iscissors *iscissors);
|
static void iscissors_free_buffers (Iscissors *iscissors);
|
||||||
static gint clicked_on_vertex (Tool *tool);
|
|
||||||
static gint clicked_on_curve (Tool *tool);
|
static gint mouse_over_vertex (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
|
static gboolean clicked_on_vertex (Tool *tool);
|
||||||
|
static GSList * mouse_over_curve (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
|
static gboolean clicked_on_curve (Tool *tool);
|
||||||
|
|
||||||
static void precalculate_arrays (void);
|
static void precalculate_arrays (void);
|
||||||
static GPtrArray * plot_pixels (Iscissors *iscissors,
|
static GPtrArray * plot_pixels (Iscissors *iscissors,
|
||||||
TempBuf *dp_buf,
|
TempBuf *dp_buf,
|
||||||
@ -899,7 +907,12 @@ iscissors_oper_update (Tool *tool,
|
|||||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
||||||
&x, &y, FALSE, FALSE);
|
&x, &y, FALSE, FALSE);
|
||||||
|
|
||||||
if (iscissors->connected && iscissors->mask &&
|
if (mouse_over_vertex (iscissors, x, y) ||
|
||||||
|
mouse_over_curve (iscissors, x, y))
|
||||||
|
{
|
||||||
|
iscissors->op = SELECTION_MOVE_MASK; /* abused */
|
||||||
|
}
|
||||||
|
else if (iscissors->connected && iscissors->mask &&
|
||||||
channel_value (iscissors->mask, x, y))
|
channel_value (iscissors->mask, x, y))
|
||||||
{
|
{
|
||||||
if (mevent->state & GDK_SHIFT_MASK &&
|
if (mevent->state & GDK_SHIFT_MASK &&
|
||||||
@ -920,6 +933,10 @@ iscissors_oper_update (Tool *tool,
|
|||||||
iscissors->op = SELECTION_REPLACE;
|
iscissors->op = SELECTION_REPLACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (iscissors->connected && iscissors->mask)
|
||||||
|
{
|
||||||
|
iscissors->op = SELECTION_MOVE; /* abused */
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iscissors->op = -1;
|
iscissors->op = -1;
|
||||||
@ -993,6 +1010,12 @@ iscissors_cursor_update (Tool *tool,
|
|||||||
case SELECTION_INTERSECT:
|
case SELECTION_INTERSECT:
|
||||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_INTERSECT_CURSOR);
|
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_INTERSECT_CURSOR);
|
||||||
break;
|
break;
|
||||||
|
case SELECTION_MOVE_MASK: /* abused */
|
||||||
|
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_POINT_CURSOR);
|
||||||
|
break;
|
||||||
|
case SELECTION_MOVE: /* abused */
|
||||||
|
gdisplay_install_tool_cursor (gdisp, GIMP_BAD_CURSOR);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_CURSOR);
|
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_CURSOR);
|
||||||
break;
|
break;
|
||||||
@ -1150,15 +1173,14 @@ iscissors_free_buffers (Iscissors *iscissors)
|
|||||||
|
|
||||||
/* XXX need some scan-conversion routines from somewhere. maybe. ? */
|
/* XXX need some scan-conversion routines from somewhere. maybe. ? */
|
||||||
|
|
||||||
static gboolean
|
static gint
|
||||||
clicked_on_vertex (Tool *tool)
|
mouse_over_vertex (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y)
|
||||||
{
|
{
|
||||||
Iscissors * iscissors;
|
|
||||||
GSList *list;
|
GSList *list;
|
||||||
ICurve *curve;
|
ICurve *curve;
|
||||||
int curves_found = 0;
|
gint curves_found = 0;
|
||||||
|
|
||||||
iscissors = (Iscissors *) tool->private;
|
|
||||||
|
|
||||||
/* traverse through the list, returning non-zero if the current cursor
|
/* traverse through the list, returning non-zero if the current cursor
|
||||||
* position is on an existing curve vertex. Set the curve1 and curve2
|
* position is on an existing curve vertex. Set the curve1 and curve2
|
||||||
@ -1173,32 +1195,46 @@ clicked_on_vertex (Tool *tool)
|
|||||||
{
|
{
|
||||||
curve = (ICurve *) list->data;
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
if (abs (curve->x1 - iscissors->x) < POINT_HALFWIDTH &&
|
if (abs (curve->x1 - x) < POINT_HALFWIDTH &&
|
||||||
abs (curve->y1 - iscissors->y) < POINT_HALFWIDTH)
|
abs (curve->y1 - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
iscissors->curve1 = curve;
|
iscissors->curve1 = curve;
|
||||||
if (curves_found++)
|
if (curves_found++)
|
||||||
return TRUE;
|
return curves_found;
|
||||||
}
|
}
|
||||||
else if (abs (curve->x2 - iscissors->x) < POINT_HALFWIDTH &&
|
else if (abs (curve->x2 - x) < POINT_HALFWIDTH &&
|
||||||
abs (curve->y2 - iscissors->y) < POINT_HALFWIDTH)
|
abs (curve->y2 - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
iscissors->curve2 = curve;
|
iscissors->curve2 = curve;
|
||||||
if (curves_found++)
|
if (curves_found++)
|
||||||
return TRUE;
|
return curves_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = g_slist_next (list);
|
list = g_slist_next (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return curves_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clicked_on_vertex (Tool *tool)
|
||||||
|
{
|
||||||
|
Iscissors *iscissors;
|
||||||
|
gint curves_found = 0;
|
||||||
|
|
||||||
|
iscissors = (Iscissors *) tool->private;
|
||||||
|
|
||||||
|
curves_found = mouse_over_vertex (iscissors, iscissors->x, iscissors->y);
|
||||||
|
|
||||||
|
if (curves_found > 1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
/* if only one curve was found, the curves are unconnected, and
|
/* if only one curve was found, the curves are unconnected, and
|
||||||
* the user only wants to move either the first or last point
|
* the user only wants to move either the first or last point
|
||||||
* disallow this for now.
|
* disallow this for now.
|
||||||
*/
|
*/
|
||||||
if (curves_found == 1)
|
if (curves_found == 1)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
/* no vertices were found at the cursor click point. Now check whether
|
/* no vertices were found at the cursor click point. Now check whether
|
||||||
* the click occured on a curve. If so, create a new vertex there and
|
* the click occured on a curve. If so, create a new vertex there and
|
||||||
@ -1208,26 +1244,23 @@ clicked_on_vertex (Tool *tool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static GSList *
|
||||||
clicked_on_curve (Tool *tool)
|
mouse_over_curve (Iscissors *iscissors,
|
||||||
|
gint x,
|
||||||
|
gint y)
|
||||||
{
|
{
|
||||||
Iscissors *iscissors;
|
GSList *list;
|
||||||
GSList *list, *new_link;
|
|
||||||
gpointer *pt;
|
gpointer *pt;
|
||||||
gint len;
|
gint len;
|
||||||
ICurve *curve, *new_curve;
|
ICurve *curve;
|
||||||
guint32 coords;
|
guint32 coords;
|
||||||
gint tx, ty;
|
gint tx, ty;
|
||||||
|
|
||||||
iscissors = (Iscissors *) tool->private;
|
/* traverse through the list, returning the curve segment's list element
|
||||||
|
* if the current cursor position is on a curve...
|
||||||
/* traverse through the list, returning non-zero if the current cursor
|
|
||||||
* position is on a curve... If this occurs, replace the curve with two
|
|
||||||
* new curves, separated by the new vertex.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
list = iscissors->curves;
|
for (list = iscissors->curves; list; list = g_slist_next (list))
|
||||||
while (list)
|
|
||||||
{
|
{
|
||||||
curve = (ICurve *) list->data;
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
@ -1241,15 +1274,43 @@ clicked_on_curve (Tool *tool)
|
|||||||
ty = coords >> 16;
|
ty = coords >> 16;
|
||||||
|
|
||||||
/* Is the specified point close enough to the curve? */
|
/* Is the specified point close enough to the curve? */
|
||||||
if (abs (tx - iscissors->x) < POINT_HALFWIDTH &&
|
if (abs (tx - x) < POINT_HALFWIDTH &&
|
||||||
abs (ty - iscissors->y) < POINT_HALFWIDTH)
|
abs (ty - y) < POINT_HALFWIDTH)
|
||||||
{
|
{
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clicked_on_curve (Tool *tool)
|
||||||
|
{
|
||||||
|
Iscissors *iscissors;
|
||||||
|
GSList *list, *new_link;
|
||||||
|
ICurve *curve, *new_curve;
|
||||||
|
|
||||||
|
iscissors = (Iscissors *) tool->private;
|
||||||
|
|
||||||
|
/* traverse through the list, getting back the curve segment's list
|
||||||
|
* element if the current cursor position is on a curve...
|
||||||
|
* If this occurs, replace the curve with two new curves,
|
||||||
|
* separated by a new vertex.
|
||||||
|
*/
|
||||||
|
list = mouse_over_curve (iscissors, iscissors->x, iscissors->y);
|
||||||
|
|
||||||
|
if (list)
|
||||||
|
{
|
||||||
|
curve = (ICurve *) list->data;
|
||||||
|
|
||||||
/* Since we're modifying the curve, undraw the existing one */
|
/* Since we're modifying the curve, undraw the existing one */
|
||||||
iscissors->draw = DRAW_CURVE;
|
iscissors->draw = DRAW_CURVE;
|
||||||
draw_core_pause (iscissors->core, tool);
|
draw_core_pause (iscissors->core, tool);
|
||||||
|
|
||||||
/* Create the new curve */
|
/* Create the new curve */
|
||||||
new_curve = g_malloc (sizeof (ICurve));
|
new_curve = g_new (ICurve, 1);
|
||||||
|
|
||||||
new_curve->x2 = curve->x2;
|
new_curve->x2 = curve->x2;
|
||||||
new_curve->y2 = curve->y2;
|
new_curve->y2 = curve->y2;
|
||||||
@ -1273,10 +1334,6 @@ clicked_on_curve (Tool *tool)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
list = g_slist_next (list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,7 @@ unit_editor_dialog (void)
|
|||||||
gimp_help_set_help_data (button, _("Create a new unit with the currently "
|
gimp_help_set_help_data (button, _("Create a new unit with the currently "
|
||||||
"seleted unit as template."), NULL);
|
"seleted unit as template."), NULL);
|
||||||
|
|
||||||
button = gimp_pixmap_button_new (no_xpm, _("Delete Unit"));
|
button = gimp_pixmap_button_new (no_xpm, _("Don't Save Unit"));
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||||
GTK_SIGNAL_FUNC (delete_callback),
|
GTK_SIGNAL_FUNC (delete_callback),
|
||||||
@ -601,7 +601,7 @@ unit_editor_dialog (void)
|
|||||||
|
|
||||||
delete_button = button;
|
delete_button = button;
|
||||||
|
|
||||||
button = gimp_pixmap_button_new (yes_xpm, _("Undelete Unit"));
|
button = gimp_pixmap_button_new (yes_xpm, _("Save Unit"));
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||||
GTK_SIGNAL_FUNC (undelete_callback),
|
GTK_SIGNAL_FUNC (undelete_callback),
|
||||||
|
Reference in New Issue
Block a user