Commit 8fb9f794 authored by BST 1999 Andy Thomas's avatar BST 1999 Andy Thomas Committed by Andy Thomas

app/bezier_select.c app/bezier_selectP.h app/paths_dialog.c

Wed May 26 21:14:15 BST 1999 Andy Thomas <alt@gimp.org>

	* app/bezier_select.c
	* app/bezier_selectP.h
	* app/paths_dialog.c
	* app/rotate_tool.c
	* app/scale_tool.c
	* app/transform_core.c
	* app/transform_core.h
	* app/transform_tool.c
	* app/transform_tool.h

	Add option to show currently selected path to be displayed
	during the transform tool operations. (Note if > 1 path locked
	only the last selected path will be shown).

	Reduced flashing of control points during update drawing of paths.

	Fixed problem in transform tool rotate/scale when changing
	layer (used to get many gdk assert failures about "gc != NULL")
parent 65e5597a
Wed May 26 21:14:15 BST 1999 Andy Thomas <alt@gimp.org>
* app/bezier_select.c
* app/bezier_selectP.h
* app/paths_dialog.c
* app/rotate_tool.c
* app/scale_tool.c
* app/transform_core.c
* app/transform_core.h
* app/transform_tool.c
* app/transform_tool.h
Add option to show currently selected path to be displayed
during the transform tool operations. (Note if > 1 path locked
only the last selected path will be shown).
Reduced flashing of control points during update drawing of paths.
Fixed problem in transform tool rotate/scale when changing
layer (used to get many gdk assert failures about "gc != NULL")
Tue May 25 20:02:42 1999 ape@lrdpf.spacetec.no (Asbjorn Pettersen)
* plug-ins/gdyntext/gdyntext_ui.c: Add include <sys/types.h> for OS/2
......
......@@ -163,7 +163,7 @@ static void bezier_select_draw (Tool *);
static void bezier_offset_point (BezierPoint *, int, int);
static int bezier_check_point (BezierPoint *, int, int, int);
static void bezier_draw_handles (BezierSelect *);
static void bezier_draw_handles (BezierSelect *, gint);
static void bezier_draw_current (BezierSelect *);
static void bezier_draw_point (BezierSelect *, BezierPoint *, int);
static void bezier_draw_line (BezierSelect *, BezierPoint *, BezierPoint *);
......@@ -626,7 +626,12 @@ bezier_edit_point_on_curve(int x,
if (ModeEdit== EXTEND_REMOVE)
{
if (point_counts <= 7)
if(bevent->state & GDK_SHIFT_MASK)
{
delete_whole_curve(bezier_sel,start_pt);
}
else if (point_counts <= 7)
{
/* If we've got less then 7 points ie: 2 anchors points 4 controls
Then the curve is minimal closed curve.
......@@ -637,11 +642,6 @@ bezier_edit_point_on_curve(int x,
*/
return(0);
}
if(bevent->state & GDK_SHIFT_MASK)
{
delete_whole_curve(bezier_sel,start_pt);
}
else if(!finded->prev || !finded->prev->prev)
{
/* This is the first point on the curve */
......@@ -911,8 +911,8 @@ bezier_select_button_press (Tool *tool,
if(ModeEdit == EXTEND_REMOVE)
{
if(bezier_sel->num_points < 6)
return;
/* if(bezier_sel->num_points < 6) */
/* return; */
/* erase the handles */
bezier_sel->draw = BEZIER_DRAW_ALL;
......@@ -985,8 +985,10 @@ bezier_select_button_press (Tool *tool,
}
else
{
bezier_sel->draw = BEZIER_DRAW_HANDLES;
draw_core_pause (bezier_sel->core, tool);
if(bezier_sel->cur_anchor)
bezier_sel->cur_anchor->pointflags = 1;
bezier_sel->draw = BEZIER_DRAW_HANDLES;
draw_core_pause (bezier_sel->core, tool);
bezier_add_point (bezier_sel, BEZIER_CONTROL, (gdouble)x, (gdouble)y);
bezier_add_point (bezier_sel, BEZIER_ANCHOR, (gdouble)x, (gdouble)y);
......@@ -1084,6 +1086,58 @@ bezier_select_button_release (Tool *tool,
paths_newpoint_current(bezier_sel,gdisp);
}
static void
bez_copy_points(BezierSelect *tobez,
BezierSelect *frombez)
{
BezierPoint *pts;
gint i;
BezierPoint *bpnt = NULL;
int need_move = 0;
pts = (BezierPoint *) frombez->points;
for (i=0; i< frombez->num_points; i++)
{
if(need_move)
{
bezier_add_point( tobez, BEZIER_MOVE, pts->x, pts->y);
need_move = 0;
}
else
bezier_add_point( tobez, pts->type, pts->x, pts->y);
if(pts == frombez->cur_anchor)
tobez->cur_anchor = tobez->last_point;
else if(pts == frombez->cur_control)
tobez->cur_control = tobez->last_point;
if(bpnt == NULL)
bpnt = tobez->last_point;
if(pts->next_curve)
{
/* printf("bezier_paste_bezierselect_to_current:: Close last curve off \n"); */
tobez->last_point->next = bpnt;
bpnt->prev = tobez->last_point;
bpnt = NULL;
need_move = 1;
pts = pts->next_curve;
}
else
{
pts = pts->next;
}
}
if ( frombez->closed )
{
tobez->last_point->next = bpnt;
bpnt->prev = tobez->last_point;
tobez->closed = 1;
}
}
static void
bezier_select_motion (Tool *tool,
GdkEventMotion *mevent,
......@@ -1117,7 +1171,8 @@ bezier_select_motion (Tool *tool,
bezier_sel->draw = BEZIER_DRAW_CURRENT | BEZIER_DRAW_HANDLES;
}
draw_core_pause (bezier_sel->core, tool);
draw_core_pause (bezier_sel->core, tool);
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0);
......@@ -1569,19 +1624,15 @@ bezier_select_control (Tool *tool,
}
}
static void
bezier_select_draw (Tool *tool)
void
bezier_draw(GDisplay * gdisp,BezierSelect * bezier_sel)
{
GDisplay * gdisp;
BezierSelect * bezier_sel;
BezierPoint * points;
int num_points;
int draw_curve;
int draw_handles;
int draw_current;
gdisp = tool->gdisp_ptr;
bezier_sel = tool->private;
if (!bezier_sel->draw)
return;
......@@ -1609,14 +1660,34 @@ bezier_select_draw (Tool *tool)
}
if (draw_curve)
bezier_draw_curve (bezier_sel,bezier_draw_segment_points,SCREEN_COORDS,NULL);
if (draw_handles)
bezier_draw_handles (bezier_sel);
if (draw_current)
bezier_draw_current (bezier_sel);
{
bezier_draw_curve (bezier_sel,bezier_draw_segment_points,SCREEN_COORDS,NULL);
bezier_draw_handles (bezier_sel,1);
}
else if (draw_current)
{
bezier_draw_current (bezier_sel);
bezier_draw_handles (bezier_sel,0);
}
else if (draw_handles)
bezier_draw_handles (bezier_sel,0);
}
static void
bezier_select_draw (Tool *tool)
{
GDisplay * gdisp;
BezierSelect * bezier_sel;
gdisp = tool->gdisp_ptr;
bezier_sel = tool->private;
bezier_draw(gdisp,bezier_sel);
}
void
bezier_add_point (BezierSelect *bezier_sel,
int type,
......@@ -1711,7 +1782,7 @@ bezier_check_point (BezierPoint *pt,
static void
bezier_draw_handles (BezierSelect *bezier_sel)
bezier_draw_handles (BezierSelect *bezier_sel,gint doAll)
{
BezierPoint * points;
int num_points;
......@@ -1738,7 +1809,11 @@ bezier_draw_handles (BezierSelect *bezier_sel)
else
{
/* printf("bezier_draw_handles:: not found cur_anchor %p\n",points); */
bezier_draw_point (bezier_sel, points, 1);
if(doAll || points->pointflags == 1)
{
bezier_draw_point (bezier_sel, points, 1);
points->pointflags = 0;
}
}
if(points)
......
......@@ -46,6 +46,9 @@ struct _bezier_point
BezierPoint *next; /* next point on curve */
BezierPoint *prev; /* prev point on curve */
BezierPoint *next_curve; /* Next curve segment */
gint pointflags; /* Status of point 0 = not selected
* 1 = selected
*/
};
typedef struct _bezier_select BezierSelect;
......@@ -85,5 +88,6 @@ void bezier_select_mode (gint);
void bezier_stroke (BezierSelect *, GDisplay *, int, int);
void bezier_to_selection (BezierSelect *, GDisplay *);
gint bezier_distance_along (BezierSelect *, gint, gdouble,gint *,gint *,gdouble *);
void bezier_draw (GDisplay *,BezierSelect *);
#endif /* __BEZIER_SELECTP_H__ */
......@@ -2473,6 +2473,59 @@ paths_transform_current_path(GimpImage *gimage,
}
}
void
paths_draw_current(GDisplay * gdisp,
DrawCore *core,
GimpMatrix transform)
{
PATHIMAGELISTP plp;
PATHP bzp;
BezierSelect * bezier_sel;
PATHP p_copy;
GSList * points_list;
/* Get bzpath structure */
plp = (PATHIMAGELISTP)gimp_image_get_paths(gdisp->gimage);
if(!plp)
return;
bzp = (PATHP)g_slist_nth_data(plp->bz_paths,plp->last_selected_row);
/* This image path is locked */
if(bzp->locked)
{
p_copy = path_copy(NULL,bzp); /* NULL means dont want new tattoo */
points_list = p_copy->path_details;
while (points_list)
{
gdouble newx,newy;
PATHPOINTP ppoint = points_list->data;
/* printf("[x,y] = [%g,%g]\n",ppoint->x, ppoint->y); */
gimp_matrix_transform_point (transform,
ppoint->x,
ppoint->y,
&newx,&newy);
/* printf("->[x,y] = [%g,%g]\n", newx, newy); */
ppoint->x = newx;
ppoint->y = newy;
points_list = points_list->next;
}
bezier_sel = path_to_beziersel(p_copy);
bezier_sel->core = core; /* A bit hacky */
bezier_draw(gdisp,bezier_sel);
beziersel_free(bezier_sel);
path_free(p_copy,NULL);
}
}
/*************************************/
/* PDB function aids */
/*************************************/
......
......@@ -2473,6 +2473,59 @@ paths_transform_current_path(GimpImage *gimage,
}
}
void
paths_draw_current(GDisplay * gdisp,
DrawCore *core,
GimpMatrix transform)
{
PATHIMAGELISTP plp;
PATHP bzp;
BezierSelect * bezier_sel;
PATHP p_copy;
GSList * points_list;
/* Get bzpath structure */
plp = (PATHIMAGELISTP)gimp_image_get_paths(gdisp->gimage);
if(!plp)
return;
bzp = (PATHP)g_slist_nth_data(plp->bz_paths,plp->last_selected_row);
/* This image path is locked */
if(bzp->locked)
{
p_copy = path_copy(NULL,bzp); /* NULL means dont want new tattoo */
points_list = p_copy->path_details;
while (points_list)
{
gdouble newx,newy;
PATHPOINTP ppoint = points_list->data;
/* printf("[x,y] = [%g,%g]\n",ppoint->x, ppoint->y); */
gimp_matrix_transform_point (transform,
ppoint->x,
ppoint->y,
&newx,&newy);
/* printf("->[x,y] = [%g,%g]\n", newx, newy); */
ppoint->x = newx;
ppoint->y = newy;
points_list = points_list->next;
}
bezier_sel = path_to_beziersel(p_copy);
bezier_sel->core = core; /* A bit hacky */
bezier_draw(gdisp,bezier_sel);
beziersel_free(bezier_sel);
path_free(p_copy,NULL);
}
}
/*************************************/
/* PDB function aids */
/*************************************/
......
......@@ -246,10 +246,12 @@ rotate_angle_changed (GtkWidget *w,
if (value != transform_core->trans_info[ANGLE])
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->trans_info[ANGLE] = value;
rotate_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......@@ -277,11 +279,13 @@ rotate_center_changed (GtkWidget *w,
if ((cx != transform_core->cx) ||
(cy != transform_core->cy))
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->cx = cx;
transform_core->cy = cy;
rotate_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......
......@@ -277,13 +277,15 @@ scale_size_changed (GtkWidget *w,
(height != (transform_core->trans_info[Y1] -
transform_core->trans_info[Y0])))
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->trans_info[X1] =
transform_core->trans_info[X0] + width;
transform_core->trans_info[Y1] =
transform_core->trans_info[Y0] + height;
scale_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......
......@@ -163,7 +163,7 @@ static void bezier_select_draw (Tool *);
static void bezier_offset_point (BezierPoint *, int, int);
static int bezier_check_point (BezierPoint *, int, int, int);
static void bezier_draw_handles (BezierSelect *);
static void bezier_draw_handles (BezierSelect *, gint);
static void bezier_draw_current (BezierSelect *);
static void bezier_draw_point (BezierSelect *, BezierPoint *, int);
static void bezier_draw_line (BezierSelect *, BezierPoint *, BezierPoint *);
......@@ -626,7 +626,12 @@ bezier_edit_point_on_curve(int x,
if (ModeEdit== EXTEND_REMOVE)
{
if (point_counts <= 7)
if(bevent->state & GDK_SHIFT_MASK)
{
delete_whole_curve(bezier_sel,start_pt);
}
else if (point_counts <= 7)
{
/* If we've got less then 7 points ie: 2 anchors points 4 controls
Then the curve is minimal closed curve.
......@@ -637,11 +642,6 @@ bezier_edit_point_on_curve(int x,
*/
return(0);
}
if(bevent->state & GDK_SHIFT_MASK)
{
delete_whole_curve(bezier_sel,start_pt);
}
else if(!finded->prev || !finded->prev->prev)
{
/* This is the first point on the curve */
......@@ -911,8 +911,8 @@ bezier_select_button_press (Tool *tool,
if(ModeEdit == EXTEND_REMOVE)
{
if(bezier_sel->num_points < 6)
return;
/* if(bezier_sel->num_points < 6) */
/* return; */
/* erase the handles */
bezier_sel->draw = BEZIER_DRAW_ALL;
......@@ -985,8 +985,10 @@ bezier_select_button_press (Tool *tool,
}
else
{
bezier_sel->draw = BEZIER_DRAW_HANDLES;
draw_core_pause (bezier_sel->core, tool);
if(bezier_sel->cur_anchor)
bezier_sel->cur_anchor->pointflags = 1;
bezier_sel->draw = BEZIER_DRAW_HANDLES;
draw_core_pause (bezier_sel->core, tool);
bezier_add_point (bezier_sel, BEZIER_CONTROL, (gdouble)x, (gdouble)y);
bezier_add_point (bezier_sel, BEZIER_ANCHOR, (gdouble)x, (gdouble)y);
......@@ -1084,6 +1086,58 @@ bezier_select_button_release (Tool *tool,
paths_newpoint_current(bezier_sel,gdisp);
}
static void
bez_copy_points(BezierSelect *tobez,
BezierSelect *frombez)
{
BezierPoint *pts;
gint i;
BezierPoint *bpnt = NULL;
int need_move = 0;
pts = (BezierPoint *) frombez->points;
for (i=0; i< frombez->num_points; i++)
{
if(need_move)
{
bezier_add_point( tobez, BEZIER_MOVE, pts->x, pts->y);
need_move = 0;
}
else
bezier_add_point( tobez, pts->type, pts->x, pts->y);
if(pts == frombez->cur_anchor)
tobez->cur_anchor = tobez->last_point;
else if(pts == frombez->cur_control)
tobez->cur_control = tobez->last_point;
if(bpnt == NULL)
bpnt = tobez->last_point;
if(pts->next_curve)
{
/* printf("bezier_paste_bezierselect_to_current:: Close last curve off \n"); */
tobez->last_point->next = bpnt;
bpnt->prev = tobez->last_point;
bpnt = NULL;
need_move = 1;
pts = pts->next_curve;
}
else
{
pts = pts->next;
}
}
if ( frombez->closed )
{
tobez->last_point->next = bpnt;
bpnt->prev = tobez->last_point;
tobez->closed = 1;
}
}
static void
bezier_select_motion (Tool *tool,
GdkEventMotion *mevent,
......@@ -1117,7 +1171,8 @@ bezier_select_motion (Tool *tool,
bezier_sel->draw = BEZIER_DRAW_CURRENT | BEZIER_DRAW_HANDLES;
}
draw_core_pause (bezier_sel->core, tool);
draw_core_pause (bezier_sel->core, tool);
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0);
......@@ -1569,19 +1624,15 @@ bezier_select_control (Tool *tool,
}
}
static void
bezier_select_draw (Tool *tool)
void
bezier_draw(GDisplay * gdisp,BezierSelect * bezier_sel)
{
GDisplay * gdisp;
BezierSelect * bezier_sel;
BezierPoint * points;
int num_points;
int draw_curve;
int draw_handles;
int draw_current;
gdisp = tool->gdisp_ptr;
bezier_sel = tool->private;
if (!bezier_sel->draw)
return;
......@@ -1609,14 +1660,34 @@ bezier_select_draw (Tool *tool)
}
if (draw_curve)
bezier_draw_curve (bezier_sel,bezier_draw_segment_points,SCREEN_COORDS,NULL);
if (draw_handles)
bezier_draw_handles (bezier_sel);
if (draw_current)
bezier_draw_current (bezier_sel);
{
bezier_draw_curve (bezier_sel,bezier_draw_segment_points,SCREEN_COORDS,NULL);
bezier_draw_handles (bezier_sel,1);
}
else if (draw_current)
{
bezier_draw_current (bezier_sel);
bezier_draw_handles (bezier_sel,0);
}
else if (draw_handles)
bezier_draw_handles (bezier_sel,0);
}
static void
bezier_select_draw (Tool *tool)
{
GDisplay * gdisp;
BezierSelect * bezier_sel;
gdisp = tool->gdisp_ptr;
bezier_sel = tool->private;
bezier_draw(gdisp,bezier_sel);
}
void
bezier_add_point (BezierSelect *bezier_sel,
int type,
......@@ -1711,7 +1782,7 @@ bezier_check_point (BezierPoint *pt,
static void
bezier_draw_handles (BezierSelect *bezier_sel)
bezier_draw_handles (BezierSelect *bezier_sel,gint doAll)
{
BezierPoint * points;
int num_points;
......@@ -1738,7 +1809,11 @@ bezier_draw_handles (BezierSelect *bezier_sel)
else
{
/* printf("bezier_draw_handles:: not found cur_anchor %p\n",points); */
bezier_draw_point (bezier_sel, points, 1);
if(doAll || points->pointflags == 1)
{
bezier_draw_point (bezier_sel, points, 1);
points->pointflags = 0;
}
}
if(points)
......
......@@ -46,6 +46,9 @@ struct _bezier_point
BezierPoint *next; /* next point on curve */
BezierPoint *prev; /* prev point on curve */
BezierPoint *next_curve; /* Next curve segment */
gint pointflags; /* Status of point 0 = not selected
* 1 = selected
*/
};
typedef struct _bezier_select BezierSelect;
......@@ -85,5 +88,6 @@ void bezier_select_mode (gint);
void bezier_stroke (BezierSelect *, GDisplay *, int, int);
void bezier_to_selection (BezierSelect *, GDisplay *);
gint bezier_distance_along (BezierSelect *, gint, gdouble,gint *,gint *,gdouble *);
void bezier_draw (GDisplay *,BezierSelect *);
#endif /* __BEZIER_SELECTP_H__ */
......@@ -246,10 +246,12 @@ rotate_angle_changed (GtkWidget *w,
if (value != transform_core->trans_info[ANGLE])
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->trans_info[ANGLE] = value;
rotate_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......@@ -277,11 +279,13 @@ rotate_center_changed (GtkWidget *w,
if ((cx != transform_core->cx) ||
(cy != transform_core->cy))
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->cx = cx;
transform_core->cy = cy;
rotate_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......
......@@ -277,13 +277,15 @@ scale_size_changed (GtkWidget *w,
(height != (transform_core->trans_info[Y1] -
transform_core->trans_info[Y0])))
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->trans_info[X1] =
transform_core->trans_info[X0] + width;
transform_core->trans_info[Y1] =
transform_core->trans_info[Y0] + height;
scale_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......
......@@ -246,10 +246,12 @@ rotate_angle_changed (GtkWidget *w,
if (value != transform_core->trans_info[ANGLE])
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->trans_info[ANGLE] = value;
rotate_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......@@ -277,11 +279,13 @@ rotate_center_changed (GtkWidget *w,
if ((cx != transform_core->cx) ||
(cy != transform_core->cy))
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->cx = cx;
transform_core->cy = cy;
rotate_tool_recalc (tool, gdisp);
draw_core_resume (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_resume (transform_core->core, tool);
}
}
}
......
......@@ -277,13 +277,15 @@ scale_size_changed (GtkWidget *w,
(height != (transform_core->trans_info[Y1] -
transform_core->trans_info[Y0])))
{
draw_core_pause (transform_core->core, tool);
if(transform_core->core->draw_state != INVISIBLE)
draw_core_pause (transform_core->core, tool);
transform_core->trans_info[X1] =
transform_core->trans_info[X0] + width;