Commit 3fcea796 authored by BST 1999 Andy Thomas's avatar BST 1999 Andy Thomas Committed by Andy Thomas
Browse files

./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.
parent b1261464
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]
......
......@@ -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");
......
......@@ -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");
......
......@@ -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)
{
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++;
}
if(pp)
if(!paths_dialog)
{
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;
path_add_to_current(plist,bzpath,gimage,0);
}
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;
}
......@@ -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);
......
......@@ -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");
......
......@@ -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)
{
guchar *buf;
guchar *src;
gint x,y;
/* 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 */
even = g_malloc(width*3);
odd = g_malloc(width*3);
for (y = 0; y < height; y++)
{
gint x,y;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1,*even,*odd;
p0 = even;
p1 = odd;
/* Draw the thumbnail with checks */
src = drawable_data;
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 */
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;