./app/layer.c.orig ./app/lc_dialog.c.orig ./app/paths_dialog.c.orig

Tue Jul  6 22:16:07 BST 1999 Andy Thomas <alt@gimp.org>

	* ./app/layer.c.orig
	* ./app/lc_dialog.c.orig
	* ./app/paths_dialog.c.orig
	* ./app/pathsP.h.orig
	* ./libgimp/gimpmenu.c.orig
	* ./tools/pdbgen/pdb/paths.pdb.orig
	* ./app/paths_cmds.c
	* ./app/internal_procs.c

	Fixed small LCP menu preview problems. Now works for all
	image types and updated correctly when alpha channel added.

	Additional PDB functions for paths. Fixed some PDB functions
	(gimp_paths_set_points). Now works as advertised.
This commit is contained in:
BST 1999 Andy Thomas 1999-07-06 21:19:34 +00:00 committed by Andy Thomas
parent b12614646d
commit 3fcea79688
12 changed files with 581 additions and 320 deletions

View File

@ -1,3 +1,20 @@
Tue Jul 6 22:16:07 BST 1999 Andy Thomas <alt@gimp.org>
* ./app/layer.c.orig
* ./app/lc_dialog.c.orig
* ./app/paths_dialog.c.orig
* ./app/pathsP.h.orig
* ./libgimp/gimpmenu.c.orig
* ./tools/pdbgen/pdb/paths.pdb.orig
* ./app/paths_cmds.c
* ./app/internal_procs.c
Fixed small LCP menu preview problems. Now works for all
image types and updated correctly when alpha channel added.
Additional PDB functions for paths. Fixed some PDB functions
(gimp_paths_set_points). Now works as advertised.
Tue Jul 6 22:40:16 MEST 1999 Sven Neumann <sven@gimp.org>
* app/commands.[ch]

View File

@ -732,6 +732,7 @@ layer_add_alpha (layer)
GIMP_DRAWABLE(layer)->type = type;
GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1;
GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type);
GIMP_DRAWABLE(layer)->preview_valid = FALSE;
gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))),
"restructure");

View File

@ -732,6 +732,7 @@ layer_add_alpha (layer)
GIMP_DRAWABLE(layer)->type = type;
GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1;
GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type);
GIMP_DRAWABLE(layer)->preview_valid = FALSE;
gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))),
"restructure");

View File

@ -439,7 +439,7 @@ strip_off_cnumber(gchar *str)
return copy;
}
/* Return NULL is already unique else a unique string */
/* Return NULL if already unique else a unique string */
static gchar *
unique_name(GimpImage *gimage,gchar *cstr)
@ -1836,7 +1836,12 @@ paths_dialog_flush()
gimage = paths_dialog->gimage;
if ((gimage->width != paths_dialog->gimage_width) ||
/* Check current_path_list since we might not have a valid preview.
* which means it should be removed.. Or if we have one
* created it!
*/
if ((paths_dialog->current_path_list == NULL) ||
(gimage->width != paths_dialog->gimage_width) ||
(gimage->height != paths_dialog->gimage_height))
{
paths_dialog->gimage = NULL;
@ -2031,6 +2036,7 @@ static void file_ok_callback(GtkWidget * widget, gpointer client_data)
GSList * pts_list = NULL;
PATHIMAGELISTP plp;
gint row = paths_dialog->selected_row_num;
gint this_path_count = 0;
fs = GTK_FILE_SELECTION (file_dlg);
filename = gtk_file_selection_get_filename (fs);
@ -2092,6 +2098,27 @@ static void file_ok_callback(GtkWidget * widget, gpointer client_data)
gtk_widget_hide (file_dlg);
return;
}
this_path_count++;
switch(type)
{
case BEZIER_ANCHOR:
case BEZIER_CONTROL:
break;
case BEZIER_MOVE:
if(this_path_count < 6)
{
g_warning(_("Invalid single point in path\n"));
gtk_widget_hide (file_dlg);
return;
}
this_path_count = 0;
break;
default:
g_warning(_("Invalid point type passed\n"));
gtk_widget_hide (file_dlg);
return;
}
bpt = pathpoint_new(type, (gdouble)x, (gdouble)y);
pts_list = g_slist_append(pts_list,bpt);
}
@ -2565,10 +2592,12 @@ paths_set_path_points(GimpImage * gimage,
GSList *pts_list = NULL;
PATHP bzpath;
gint pcount = 0;
gint this_path_count = 0;
gchar *suniq;
if(num_pnts < 6 ||
(pclosed && ((num_pnts/2) % 3)) ||
(!pclosed && ((num_pnts/2) % 3) != 2))
(pclosed && ((num_pnts/3) % 3)) ||
(!pclosed && ((num_pnts/3) % 3) != 2))
{
g_warning(_("wrong number of points\n"));
return FALSE;
@ -2577,6 +2606,11 @@ paths_set_path_points(GimpImage * gimage,
if(ptype != BEZIER)
ptype = BEZIER;
suniq = unique_name(gimage,pname);
if(suniq)
pname = suniq;
while(num_pnts)
{
PATHPOINTP bpt;
@ -2584,13 +2618,34 @@ paths_set_path_points(GimpImage * gimage,
gdouble x;
gdouble y;
if((pcount/2)%3)
type = BEZIER_CONTROL;
else
type = BEZIER_ANCHOR;
/* if((pcount/2)%3) */
/* type = BEZIER_CONTROL; */
/* else */
/* type = BEZIER_ANCHOR; */
x = pnts[pcount++];
y = pnts[pcount++];
type = (gint)pnts[pcount++];
this_path_count++;
switch(type)
{
case BEZIER_ANCHOR:
case BEZIER_CONTROL:
break;
case BEZIER_MOVE:
if(this_path_count < 6)
{
g_warning(_("Invalid single point in path\n"));
return FALSE;
}
this_path_count = 0;
break;
default:
g_warning(_("Invalid point type passed\n"));
return FALSE;
}
/* printf("New point type = %s, x = %d y= %d\n", */
/* (type==BEZIER_CONTROL)?"CNTL":"ANCH", */
@ -2600,14 +2655,14 @@ paths_set_path_points(GimpImage * gimage,
bpt = pathpoint_new(type, (gdouble)x, (gdouble)y);
pts_list = g_slist_append(pts_list,bpt);
num_pnts -= 2;
num_pnts -= 3;
}
if(!plist)
{
GSList *bzp_list = NULL;
/* No paths at all.... create one & rename */
/* No paths at all.... create one */
bzpath = path_new(gimage,
ptype,
pts_list,
@ -2616,63 +2671,35 @@ paths_set_path_points(GimpImage * gimage,
0, /* Can't be locked */
0, /* No tattoo assigned */
pname);
bzp_list = g_slist_append(bzp_list,bzpath);
plist = pathsList_new(gimage,0,bzp_list);
gimp_image_set_paths(gimage,plist);
if(!paths_dialog)
{
bzp_list = g_slist_append(bzp_list,bzpath);
plist = pathsList_new(gimage,0,bzp_list);
gimp_image_set_paths(gimage,plist);
}
}
else
{
GSList *tlist;
PATHP pp = NULL;
gint row = 0;
/* Check if name already exists.. if so delete all points assoc with it
* if not create a new one with the passed name.
*/
tlist = plist->bz_paths;
bzpath = path_new(gimage,
ptype,
pts_list,
pclosed,
(pclosed)?BEZIER_EDIT:BEZIER_ADD,/*state,*/
0, /* Can't be locked */
0, /* No tattoo assigned */
pname);
while(tlist)
if(!paths_dialog)
{
gchar *test_str = ((PATHP)(tlist->data))->name->str;
if(strcmp(pname,test_str) == 0)
{
pp = (PATHP)(tlist->data);
break;
}
tlist = g_slist_next(tlist);
row++;
path_add_to_current(plist,bzpath,gimage,0);
}
}
if(pp)
{
pathpoints_free(pp->path_details);
pp->path_details = pts_list;
pp->pathtype = ptype;
pp->closed = pclosed;
pp->locked = 0;
if(paths_dialog)
gtk_clist_select_row(GTK_CLIST(paths_dialog->paths_list),
row,
1);
return TRUE;
}
else
{
bzpath = path_new(gimage,
ptype,
pts_list,
pclosed,
(pclosed)?BEZIER_EDIT:BEZIER_ADD,/*state,*/
0, /* Can't be locked */
0, /* No tattoo assigned */
pname);
path_add_to_current(plist,bzpath,gimage,-1);
}
}
if(paths_dialog)
if(paths_dialog)
{
gint tmprow;
BezierSelect *bezier_sel;
paths_dialog->current_path_list =
path_add_to_current(paths_dialog->current_path_list,
bzpath,
@ -2681,6 +2708,15 @@ paths_set_path_points(GimpImage * gimage,
paths_add_path(bzpath,0);
/* Update the preview */
bezier_sel = path_to_beziersel(bzpath);
tmprow = paths_dialog->current_path_list->last_selected_row;
paths_dialog->current_path_list->last_selected_row = 0;
paths_update_preview(bezier_sel);
beziersel_free(bezier_sel);
paths_dialog->current_path_list->last_selected_row = tmprow;
paths_dialog->selected_row_num = tmprow;
gtk_clist_select_row(GTK_CLIST(paths_dialog->paths_list),
paths_dialog->current_path_list->last_selected_row,
1);
@ -2696,6 +2732,12 @@ paths_set_path_points(GimpImage * gimage,
point_ops_button_set_sensitive(POINT_NEW_BUTTON,TRUE);
point_ops_button_set_sensitive(POINT_EDIT_BUTTON,TRUE);
}
else
{
/* Mark this path as selected */
plist->last_selected_row = 0;
}
return TRUE;
}
@ -2762,3 +2804,65 @@ paths_get_path_by_tattoo(GimpImage *gimage,Tattoo tattoo)
}
return (NULL);
}
gboolean
paths_delete_path(GimpImage *gimage,
gchar *pname)
{
gint row = 0;
gboolean found = FALSE;
GSList *tlist;
PATHIMAGELISTP plp;
if(!pname || !gimage)
{
g_warning(_("paths_delete_path: invalid path"));
return 0;
}
/* Removed the named path ... */
/* Get bzpath structure */
plp = (PATHIMAGELISTP)gimp_image_get_paths(gimage);
if(!plp)
return FALSE;
tlist = plp->bz_paths;
while(tlist)
{
gchar *test_str = ((PATHP)(tlist->data))->name->str;
if(strcmp(pname,test_str) == 0)
{
found = TRUE;
break;
}
row++;
tlist = g_slist_next(tlist);
}
if(!found)
return FALSE;
plp->bz_paths = g_slist_remove(plp->bz_paths,tlist->data);
/* If now empty free everything up */
if(!plp->bz_paths || g_slist_length(plp->bz_paths) == 0)
{
gtk_signal_disconnect(GTK_OBJECT (plp->gimage),
plp->sig_id);
gimp_image_set_paths(plp->gimage,NULL);
pathimagelist_free(plp);
}
/* Redisplay if required */
if(paths_dialog && paths_dialog->gimage == gimage)
{
paths_dialog->current_path_list = NULL;
paths_dialog_flush();
}
return TRUE;
}

View File

@ -59,7 +59,7 @@ void register_tools_procs (void);
void register_undo_procs (void);
void register_unit_procs (void);
/* 297 procedures registered total */
/* 298 procedures registered total */
void
internal_procs_init (void)
@ -82,70 +82,70 @@ internal_procs_init (void)
app_init_update_status (NULL, _("Convert"), 0.141);
register_convert_procs ();
app_init_update_status (NULL, _("Drawable procedures"), 0.155);
app_init_update_status (NULL, _("Drawable procedures"), 0.154);
register_drawable_procs ();
app_init_update_status (NULL, _("Edit procedures"), 0.229);
app_init_update_status (NULL, _("Edit procedures"), 0.228);
register_edit_procs ();
app_init_update_status (NULL, _("File Operations"), 0.249);
app_init_update_status (NULL, _("File Operations"), 0.248);
register_fileops_procs ();
app_init_update_status (NULL, _("Floating selections"), 0.269);
app_init_update_status (NULL, _("Floating selections"), 0.268);
register_floating_sel_procs ();
app_init_update_status (NULL, _("GDisplay procedures"), 0.29);
app_init_update_status (NULL, _("GDisplay procedures"), 0.289);
register_gdisplay_procs ();
app_init_update_status (NULL, _("Image"), 0.3);
app_init_update_status (NULL, _("Image"), 0.299);
register_gimage_procs ();
app_init_update_status (NULL, _("Image mask"), 0.481);
app_init_update_status (NULL, _("Image mask"), 0.48);
register_gimage_mask_procs ();
app_init_update_status (NULL, _("Gimprc procedures"), 0.539);
app_init_update_status (NULL, _("Gimprc procedures"), 0.537);
register_gimprc_procs ();
app_init_update_status (NULL, _("Gradients"), 0.545);
app_init_update_status (NULL, _("Gradients"), 0.544);
register_gradient_procs ();
app_init_update_status (NULL, _("Gradient UI"), 0.562);
app_init_update_status (NULL, _("Gradient UI"), 0.56);
register_gradient_select_procs ();
app_init_update_status (NULL, _("Guide procedures"), 0.576);
app_init_update_status (NULL, _("Guide procedures"), 0.574);
register_guides_procs ();
app_init_update_status (NULL, _("Interface"), 0.596);
app_init_update_status (NULL, _("Interface"), 0.594);
register_interface_procs ();
app_init_update_status (NULL, _("Layer"), 0.606);
app_init_update_status (NULL, _("Layer"), 0.604);
register_layer_procs ();
app_init_update_status (NULL, _("Miscellaneous"), 0.707);
app_init_update_status (NULL, _("Miscellaneous"), 0.705);
register_misc_procs ();
app_init_update_status (NULL, _("Palette"), 0.714);
app_init_update_status (NULL, _("Palette"), 0.711);
register_palette_procs ();
app_init_update_status (NULL, _("Parasite procedures"), 0.737);
app_init_update_status (NULL, _("Parasite procedures"), 0.735);
register_parasite_procs ();
app_init_update_status (NULL, _("Paths"), 0.781);
app_init_update_status (NULL, _("Paths"), 0.779);
register_paths_procs ();
app_init_update_status (NULL, _("Pattern UI"), 0.811);
app_init_update_status (NULL, _("Pattern UI"), 0.812);
register_pattern_select_procs ();
app_init_update_status (NULL, _("Patterns"), 0.822);
register_patterns_procs ();
app_init_update_status (NULL, _("Plug-in"), 0.835);
app_init_update_status (NULL, _("Plug-in"), 0.836);
register_plug_in_procs ();
app_init_update_status (NULL, _("Procedural database"), 0.848);
app_init_update_status (NULL, _("Procedural database"), 0.849);
register_procedural_db_procs ();
app_init_update_status (NULL, _("Text procedures"), 0.875);
app_init_update_status (NULL, _("Text procedures"), 0.876);
register_text_tool_procs ();
app_init_update_status (NULL, _("Tool procedures"), 0.889);

View File

@ -732,6 +732,7 @@ layer_add_alpha (layer)
GIMP_DRAWABLE(layer)->type = type;
GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1;
GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type);
GIMP_DRAWABLE(layer)->preview_valid = FALSE;
gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))),
"restructure");

View File

@ -416,6 +416,13 @@ lc_dialog_fill_preview_with_thumb(GtkWidget *w,
gint bpp;
gint dwidth;
gint dheight;
gint has_alpha;
gint x,y;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1,*even,*odd;
bpp = 0; /* Only returned */
@ -435,99 +442,67 @@ lc_dialog_fill_preview_with_thumb(GtkWidget *w,
buf = gimp_image_construct_composite_preview(gimage,
width,
height);
drawable_data = temp_buf_data(buf);
bpp = buf->bytes;
gtk_preview_size(GTK_PREVIEW(w),width,height);
/* Draw the thumbnail with checks */
src = drawable_data;
/* First greyscale and non-alpha */
if(bpp < 4)
even = g_malloc(width*3);
odd = g_malloc(width*3);
for (y = 0; y < height; y++)
{
guchar *buf;
guchar *src;
gint x,y;
p0 = even;
p1 = odd;
/* Draw the image */
buf = g_new (gchar, width * 3);
src = drawable_data;
for (y = 0; y < height; y++)
{
if (bpp == 1)
for (x = 0; x < width; x++)
{
buf[x*3+0] = src[x];
buf[x*3+1] = src[x];
buf[x*3+2] = src[x];
}
else
for (x = 0; x < width; x++)
{
buf[x*3+0] = src[x*3+0];
buf[x*3+1] = src[x*3+1];
buf[x*3+2] = src[x*3+2];
}
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)buf, 0, y, width);
src += width * bpp;
}
g_free(buf);
}
else /* Has alpha channel */
{
gint x,y;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1,*even,*odd;
/* Draw the thumbnail with checks */
src = drawable_data;
even = g_malloc(width*3);
odd = g_malloc(width*3);
for (y = 0; y < height; y++)
{
p0 = even;
p1 = odd;
for (x = 0; x < width; x++) {
r = ((gdouble)src[x*4+0])/255.0;
g = ((gdouble)src[x*4+1])/255.0;
b = ((gdouble)src[x*4+2])/255.0;
a = ((gdouble)src[x*4+3])/255.0;
if ((x / GRAD_CHECK_SIZE_SM) & 1) {
c0 = GRAD_CHECK_LIGHT;
c1 = GRAD_CHECK_DARK;
} else {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
} /* else */
*p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0;
} /* for */
if ((y / GRAD_CHECK_SIZE_SM) & 1)
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)odd, 0, y, width);
}
else
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)even, 0, y, width);
}
src += width * bpp;
}
g_free(even);
g_free(odd);
for (x = 0; x < width; x++) {
if(bpp == 4)
{
r = ((gdouble)src[x*4+0])/255.0;
g = ((gdouble)src[x*4+1])/255.0;
b = ((gdouble)src[x*4+2])/255.0;
a = ((gdouble)src[x*4+3])/255.0;
}
else
{
r = ((gdouble)src[x*bpp+0])/255.0;
g = b = r;
a = ((gdouble)src[x*bpp+1])/255.0;
}
if ((x / GRAD_CHECK_SIZE_SM) & 1) {
c0 = GRAD_CHECK_LIGHT;
c1 = GRAD_CHECK_DARK;
} else {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
} /* else */
*p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0;
} /* for */
if ((y / GRAD_CHECK_SIZE_SM) & 1)
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)odd, 0, y, width);
}
else
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)even, 0, y, width);
}
src += width * bpp;
}
g_free(even);
g_free(odd);
}
static void

View File

@ -73,5 +73,6 @@ void * paths_transform_start_undo(GimpImage *);
void paths_transform_free_undo(void *);
void paths_transform_do_undo(GimpImage *,void *);
void paths_transform_current_path(GimpImage *,GimpMatrix,gboolean);
gboolean paths_delete_path(GimpImage *,gchar *);
#endif /* __PATHSP_H__ */

View File

@ -34,6 +34,7 @@ static ProcRecord path_stroke_current_proc;
static ProcRecord path_get_point_at_dist_proc;
static ProcRecord path_get_tattoo_proc;
static ProcRecord get_path_by_tattoo_proc;
static ProcRecord path_delete_proc;
void
register_paths_procs (void)
@ -47,6 +48,7 @@ register_paths_procs (void)
procedural_db_register (&path_get_point_at_dist_proc);
procedural_db_register (&path_get_tattoo_proc);
procedural_db_register (&get_path_by_tattoo_proc);
procedural_db_register (&path_delete_proc);
}
static Argument *
@ -418,9 +420,9 @@ path_set_points_invoker (Argument *args)
if (success)
{
if ((numpoints / 2) % 3 == 0)
if ((numpoints / 3) % 3 == 0)
pclosed = TRUE;
else if ((numpoints / 2) % 3 != 2)
else if ((numpoints / 3) % 3 != 2)
success = FALSE;
if (success && !paths_set_path_points (gimage, pname, ptype, pclosed,
@ -441,7 +443,7 @@ static ProcArg path_set_points_inargs[] =
{
PDB_STRING,
"pathname",
"The name of the path to create (if it exists then all current points are removed). This will not be set as the current path. You will have to do a gimp_set_current_path after creating the path to make it current."
"The name of the path to create (if it exists then a unique name will be created - query the list of paths if you want to make sure that the name of the path you create is unique. This will not be set as the current path. You will have to do a gimp_set_current_path after creating the path to make it current."
},
{
PDB_INT32,
@ -451,7 +453,7 @@ static ProcArg path_set_points_inargs[] =
{
PDB_INT32,
"num_path_points",
"The number of points in the path. Each point is made up of (x,y) of floats. Currently only the creation of bezier curves is allowed. The type parameter must be set to (1) to indicate a BEZIER type curve. For BEZIERS. Note the that points must be given in the following order... ACCACCAC ... If the path is not closed the last control point is missed off. Points consist of three control points (control/anchor/control) so for a curve that is not closed there must be at least two points passed (2 x,y pairs). If num_path_pnts % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC."
"The number of points in the path. Each point is made up of (x,y,type) of floats. Currently only the creation of bezier curves is allowed. The type parameter must be set to (1) to indicate a BEZIER type curve. For BEZIERS. Note the that points must be given in the following order... ACCACCAC ... If the path is not closed the last control point is missed off. Points consist of three control points (control/anchor/control) so for a curve that is not closed there must be at least two points passed (2 x,y pairs). If num_path_pnts % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC."
},
{
PDB_FLOATARRAY,
@ -801,3 +803,54 @@ static ProcRecord get_path_by_tattoo_proc =
get_path_by_tattoo_outargs,
{ { get_path_by_tattoo_invoker } }
};
static Argument *
path_delete_invoker (Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gchar *pname;
gimage = pdb_id_to_image (args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
pname = (gchar *) args[1].value.pdb_pointer;
if (pname == NULL)
success = FALSE;
if (success)
success = paths_delete_path (gimage, pname);
return procedural_db_return_args (&path_delete_proc, success);
}
static ProcArg path_delete_inargs[] =
{
{
PDB_IMAGE,
"image",
"The ID of the image to list delete the paths from"
},
{
PDB_STRING,
"path_name_to_del",
"The name of the path to delete"
}
};
static ProcRecord path_delete_proc =
{
"gimp_path_delete",
"Delete the named paths associated with the passed image.",
"Delete the named path.",
"Andy Thomas",
"Andy Thomas",
"1999",
PDB_INTERNAL,
2,
path_delete_inargs,
0,
NULL,
{ { path_delete_invoker } }
};

View File

@ -439,7 +439,7 @@ strip_off_cnumber(gchar *str)
return copy;
}
/* Return NULL is already unique else a unique string */
/* Return NULL if already unique else a unique string */
static gchar *
unique_name(GimpImage *gimage,gchar *cstr)
@ -1836,7 +1836,12 @@ paths_dialog_flush()
gimage = paths_dialog->gimage;
if ((gimage->width != paths_dialog->gimage_width) ||
/* Check current_path_list since we might not have a valid preview.
* which means it should be removed.. Or if we have one
* created it!
*/
if ((paths_dialog->current_path_list == NULL) ||
(gimage->width != paths_dialog->gimage_width) ||
(gimage->height != paths_dialog->gimage_height))
{
paths_dialog->gimage = NULL;
@ -2031,6 +2036,7 @@ static void file_ok_callback(GtkWidget * widget, gpointer client_data)
GSList * pts_list = NULL;
PATHIMAGELISTP plp;
gint row = paths_dialog->selected_row_num;
gint this_path_count = 0;
fs = GTK_FILE_SELECTION (file_dlg);
filename = gtk_file_selection_get_filename (fs);
@ -2092,6 +2098,27 @@ static void file_ok_callback(GtkWidget * widget, gpointer client_data)
gtk_widget_hide (file_dlg);
return;
}
this_path_count++;
switch(type)
{
case BEZIER_ANCHOR:
case BEZIER_CONTROL:
break;
case BEZIER_MOVE:
if(this_path_count < 6)
{
g_warning(_("Invalid single point in path\n"));
gtk_widget_hide (file_dlg);
return;
}
this_path_count = 0;
break;
default:
g_warning(_("Invalid point type passed\n"));
gtk_widget_hide (file_dlg);
return;
}
bpt = pathpoint_new(type, (gdouble)x, (gdouble)y);
pts_list = g_slist_append(pts_list,bpt);
}
@ -2565,10 +2592,12 @@ paths_set_path_points(GimpImage * gimage,
GSList *pts_list = NULL;
PATHP bzpath;
gint pcount = 0;
gint this_path_count = 0;
gchar *suniq;
if(num_pnts < 6 ||
(pclosed && ((num_pnts/2) % 3)) ||
(!pclosed && ((num_pnts/2) % 3) != 2))
(pclosed && ((num_pnts/3) % 3)) ||
(!pclosed && ((num_pnts/3) % 3) != 2))
{
g_warning(_("wrong number of points\n"));
return FALSE;
@ -2577,6 +2606,11 @@ paths_set_path_points(GimpImage * gimage,
if(ptype != BEZIER)
ptype = BEZIER;
suniq = unique_name(gimage,pname);
if(suniq)
pname = suniq;
while(num_pnts)
{
PATHPOINTP bpt;
@ -2584,13 +2618,34 @@ paths_set_path_points(GimpImage * gimage,
gdouble x;
gdouble y;
if((pcount/2)%3)
type = BEZIER_CONTROL;
else
type = BEZIER_ANCHOR;
/* if((pcount/2)%3) */
/* type = BEZIER_CONTROL; */
/* else */
/* type = BEZIER_ANCHOR; */
x = pnts[pcount++];
y = pnts[pcount++];
type = (gint)pnts[pcount++];
this_path_count++;
switch(type)
{
case BEZIER_ANCHOR:
case BEZIER_CONTROL:
break;
case BEZIER_MOVE:
if(this_path_count < 6)
{
g_warning(_("Invalid single point in path\n"));
return FALSE;
}
this_path_count = 0;
break;
default:
g_warning(_("Invalid point type passed\n"));
return FALSE;
}
/* printf("New point type = %s, x = %d y= %d\n", */
/* (type==BEZIER_CONTROL)?"CNTL":"ANCH", */
@ -2600,14 +2655,14 @@ paths_set_path_points(GimpImage * gimage,
bpt = pathpoint_new(type, (gdouble)x, (gdouble)y);
pts_list = g_slist_append(pts_list,bpt);
num_pnts -= 2;
num_pnts -= 3;
}
if(!plist)
{
GSList *bzp_list = NULL;
/* No paths at all.... create one & rename */
/* No paths at all.... create one */
bzpath = path_new(gimage,
ptype,
pts_list,
@ -2616,63 +2671,35 @@ paths_set_path_points(GimpImage * gimage,
0, /* Can't be locked */
0, /* No tattoo assigned */
pname);
bzp_list = g_slist_append(bzp_list,bzpath);
plist = pathsList_new(gimage,0,bzp_list);
gimp_image_set_paths(gimage,plist);
if(!paths_dialog)
{
bzp_list = g_slist_append(bzp_list,bzpath);
plist = pathsList_new(gimage,0,bzp_list);
gimp_image_set_paths(gimage,plist);
}
}
else
{
GSList *tlist;
PATHP pp = NULL;
gint row = 0;
/* Check if name already exists.. if so delete all points assoc with it
* if not create a new one with the passed name.
*/
tlist = plist->bz_paths;
bzpath = path_new(gimage,
ptype,
pts_list,
pclosed,
(pclosed)?BEZIER_EDIT:BEZIER_ADD,/*state,*/
0, /* Can't be locked */
0, /* No tattoo assigned */
pname);
while(tlist)
if(!paths_dialog)
{
gchar *test_str = ((PATHP)(tlist->data))->name->str;
if(strcmp(pname,test_str) == 0)
{
pp = (PATHP)(tlist->data);
break;
}
tlist = g_slist_next(tlist);
row++;
path_add_to_current(plist,bzpath,gimage,0);
}
}
if(pp)
{
pathpoints_free(pp->path_details);
pp->path_details = pts_list;
pp->pathtype = ptype;
pp->closed = pclosed;
pp->locked = 0;
if(paths_dialog)
gtk_clist_select_row(GTK_CLIST(paths_dialog->paths_list),
row,
1);
return TRUE;
}
else
{
bzpath = path_new(gimage,
ptype,
pts_list,
pclosed,
(pclosed)?BEZIER_EDIT:BEZIER_ADD,/*state,*/
0, /* Can't be locked */
0, /* No tattoo assigned */
pname);
path_add_to_current(plist,bzpath,gimage,-1);
}
}
if(paths_dialog)
if(paths_dialog)
{
gint tmprow;
BezierSelect *bezier_sel;
paths_dialog->current_path_list =
path_add_to_current(paths_dialog->current_path_list,
bzpath,
@ -2681,6 +2708,15 @@ paths_set_path_points(GimpImage * gimage,
paths_add_path(bzpath,0);
/* Update the preview */
bezier_sel = path_to_beziersel(bzpath);
tmprow = paths_dialog->current_path_list->last_selected_row;
paths_dialog->current_path_list->last_selected_row = 0;
paths_update_preview(bezier_sel);
beziersel_free(bezier_sel);
paths_dialog->current_path_list->last_selected_row = tmprow;
paths_dialog->selected_row_num = tmprow;
gtk_clist_select_row(GTK_CLIST(paths_dialog->paths_list),
paths_dialog->current_path_list->last_selected_row,
1);
@ -2696,6 +2732,12 @@ paths_set_path_points(GimpImage * gimage,
point_ops_button_set_sensitive(POINT_NEW_BUTTON,TRUE);
point_ops_button_set_sensitive(POINT_EDIT_BUTTON,TRUE);
}
else
{
/* Mark this path as selected */
plist->last_selected_row = 0;
}
return TRUE;
}
@ -2762,3 +2804,65 @@ paths_get_path_by_tattoo(GimpImage *gimage,Tattoo tattoo)
}
return (NULL);
}
gboolean
paths_delete_path(GimpImage *gimage,
gchar *pname)
{
gint row = 0;
gboolean found = FALSE;
GSList *tlist;
PATHIMAGELISTP plp;
if(!pname || !gimage)
{
g_warning(_("paths_delete_path: invalid path"));
return 0;
}
/* Removed the named path ... */
/* Get bzpath structure */
plp = (PATHIMAGELISTP)gimp_image_get_paths(gimage);
if(!plp)
return FALSE;
tlist = plp->bz_paths;
while(tlist)
{
gchar *test_str = ((PATHP)(tlist->data))->name->str;
if(strcmp(pname,test_str) == 0)
{
found = TRUE;
break;
}
row++;
tlist = g_slist_next(tlist);
}
if(!found)
return FALSE;
plp->bz_paths = g_slist_remove(plp->bz_paths,tlist->data);
/* If now empty free everything up */
if(!plp->bz_paths || g_slist_length(plp->bz_paths) == 0)
{
gtk_signal_disconnect(GTK_OBJECT (plp->gimage),
plp->sig_id);
gimp_image_set_paths(plp->gimage,NULL);
pathimagelist_free(plp);
}
/* Redisplay if required */
if(paths_dialog && paths_dialog->gimage == gimage)
{
paths_dialog->current_path_list = NULL;
paths_dialog_flush();
}
return TRUE;
}

View File

@ -591,8 +591,13 @@ gimp_menu_callback (GtkWidget *w,
static void
fill_preview_with_thumb(GtkWidget *w,gint32 drawableId,gint width,gint height)
{
guchar *drawable_data;
gint bpp;
guchar *drawable_data;
gint bpp;
gint x,y;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1,*even,*odd;
bpp = 0; /* Only returned */
@ -600,93 +605,70 @@ fill_preview_with_thumb(GtkWidget *w,gint32 drawableId,gint width,gint height)
gtk_preview_size(GTK_PREVIEW(w),width,height);
/* First greyscale and non-alpha */
if(bpp < 4)
even = g_malloc(width*3);
odd = g_malloc(width*3);
src = drawable_data;
for (y = 0; y < height; y++)
{
guchar *buf;
guchar *src;
gint x,y;
p0 = even;
p1 = odd;
/* Draw the image */
buf = g_new (gchar, width * 3);
src = drawable_data;
for (y = 0; y < height; y++)
{
if (bpp == 1)
for (x = 0; x < width; x++)
{
buf[x*3+0] = src[x];
buf[x*3+1] = src[x];
buf[x*3+2] = src[x];
}
else
for (x = 0; x < width; x++)
{
buf[x*3+0] = src[x*3+0];
buf[x*3+1] = src[x*3+1];
buf[x*3+2] = src[x*3+2];
}
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)buf, 0, y, width);
src += width * bpp;
}
g_free(buf);
}
else /* Has alpha channel */
{
gint x,y;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1,*even,*odd;
/* Draw the thumbnail with checks */
src = drawable_data;
even = g_malloc(width*3);
odd = g_malloc(width*3);
for (y = 0; y < height; y++)
{
p0 = even;
p1 = odd;
for (x = 0; x < width; x++) {
for (x = 0; x < width; x++) {
if(bpp == 4)
{
r = ((gdouble)src[x*4+0])/255.0;
g = ((gdouble)src[x*4+1])/255.0;
b = ((gdouble)src[x*4+2])/255.0;
a = ((gdouble)src[x*4+3])/255.0;
if ((x / GRAD_CHECK_SIZE_SM) & 1) {
c0 = GRAD_CHECK_LIGHT;
c1 = GRAD_CHECK_DARK;
} else {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
} /* else */
*p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0;
} /* for */
if ((y / GRAD_CHECK_SIZE_SM) & 1)
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)odd, 0, y, width);
}
else
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)even, 0, y, width);
}
src += width * bpp;
}
else if(bpp == 3)
{
r = ((gdouble)src[x*3+0])/255.0;
g = ((gdouble)src[x*3+1])/255.0;
b = ((gdouble)src[x*3+2])/255.0;
a = 1.0;
}
else
{
r = ((gdouble)src[x*bpp+0])/255.0;
g = b = r;
if(bpp == 2)
a = ((gdouble)src[x*bpp+1])/255.0;
else
a = 1.0;
}
if ((x / GRAD_CHECK_SIZE_SM) & 1) {
c0 = GRAD_CHECK_LIGHT;
c1 = GRAD_CHECK_DARK;
} else {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
} /* else */
*p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0;
} /* for */
if ((y / GRAD_CHECK_SIZE_SM) & 1)
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)odd, 0, y, width);
}
g_free(even);
g_free(odd);
else
{
gtk_preview_draw_row (GTK_PREVIEW (w), (guchar *)even, 0, y, width);
}
src += width * bpp;
}
g_free(even);
g_free(odd);
}

View File

@ -231,8 +231,10 @@ HELP
@inargs = (
&std_image_arg,
{ name => 'pathname', type => 'string',
desc => 'The name of the path to create (if it exists then all
current points are removed). This will not be set as the
desc => 'The name of the path to create (if it exists then a unique
name will be created - query the list of paths if you want
to make sure that the name of the path you create is
unique. This will not be set as the
current path. You will have to do a gimp_set_current_path
after creating the path to make it current.',
alias => 'pname', init => 1 },
@ -248,8 +250,8 @@ HELP
resolution',
array => { name => 'num_path_points',
desc => 'The number of points in the path. Each point is
made up of (x,y) of floats. Currently only the
creation of bezier curves is allowed. The type
made up of (x,y,type) of floats. Currently only
the creation of bezier curves is allowed. The type
parameter must be set to (1) to indicate a BEZIER
type curve. For BEZIERS. Note the that points
must be given in the following order... ACCACCAC
@ -268,9 +270,9 @@ HELP
vars => [ 'gboolean pclosed = FALSE' ],
code => <<'CODE'
{
if ((numpoints / 2) % 3 == 0)
if ((numpoints / 3) % 3 == 0)
pclosed = TRUE;
else if ((numpoints / 2) % 3 != 2)
else if ((numpoints / 3) % 3 != 2)
success = FALSE;
if (success && !paths_set_path_points (gimage, pname, ptype, pclosed,
@ -462,12 +464,32 @@ CODE
);
}
sub path_delete {
$blurb = 'Delete the named paths associated with the passed image.';
$help = <<'HELP';
Delete the named path.
HELP
&pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'path_name_to_del', type => 'string',
desc => 'The name of the path to delete',
alias => 'pname' }
);
$inargs[0]->{desc} = 'The ID of the image to list delete the paths from';
%invoke = ( code => 'success = paths_delete_path (gimage, pname);' );
}
@headers = qw(<string.h> "gimage.h" "pathsP.h");
@procs = qw(path_list path_get_points path_get_current path_set_current
path_set_points path_stroke_current path_get_point_at_dist
path_get_tattoo get_path_by_tattoo);
path_get_tattoo get_path_by_tattoo path_delete);
%exports = (app => [@procs]);
$desc = 'Paths';