Commit 3e131f45 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

fixed regression where empty image box appeared on gop-ed parent in incorrect...

fixed regression where empty image box appeared on gop-ed parent in incorrect locations and/or it was not supposed to show up at all. Some refinements to the path detection/removal of debug output.
parent 99a41cf1
......@@ -35,14 +35,14 @@ void image_doopen(t_image* x) {
char fname[FILENAME_MAX];
canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
fname, FILENAME_MAX);
fprintf(stderr,"post @ cooked name <%s>\n", fname);
//fprintf(stderr,"post @ cooked name <%s>\n", fname);
sys_vgui(".x%x.c create rectangle \
%d %d %d %d -tags %xMT -outline black -fill gray\n",
glist_getcanvas(glist),
text_xpix(&x->x_obj, glist) - x->x_width/2,
text_ypix(&x->x_obj, glist) - x->x_height/2,
text_xpix(&x->x_obj, glist) + x->x_width/2,
text_ypix(&x->x_obj, glist) + x->x_height/2, x);
glist,
text_xpix(&x->x_obj, x->x_glist) - x->x_width/2,
text_ypix(&x->x_obj, x->x_glist) - x->x_height/2,
text_xpix(&x->x_obj, x->x_glist) + x->x_width/2,
text_ypix(&x->x_obj, x->x_glist) + x->x_height/2, x);
sys_vgui("catch {image delete $img%x}\n", x);
sys_vgui("set img%x [image create photo -file {%s}]\n", x, fname);
sys_vgui(".x%x.c itemconfigure %xS -image $img%x\n",
......@@ -52,11 +52,11 @@ void image_doopen(t_image* x) {
else {
sys_vgui(".x%x.c create rectangle \
%d %d %d %d -tags %xMT -outline black -fill gray\n",
glist_getcanvas(glist),
text_xpix(&x->x_obj, glist) - x->x_width/2,
text_ypix(&x->x_obj, glist) - x->x_height/2,
text_xpix(&x->x_obj, glist) + x->x_width/2,
text_ypix(&x->x_obj, glist) + x->x_height/2, x);
glist,
text_xpix(&x->x_obj, x->x_glist) - x->x_width/2,
text_ypix(&x->x_obj, x->x_glist) - x->x_height/2,
text_xpix(&x->x_obj, x->x_glist) + x->x_width/2,
text_ypix(&x->x_obj, x->x_glist) + x->x_height/2, x);
}
}
......@@ -99,6 +99,7 @@ static t_symbol *get_filename(t_int argc, t_atom *argv)
{
t_symbol *fname;
fname = atom_getsymbolarg(0, argc, argv);
//fprintf(stderr,"fname=<%s>\n", fname->s_name);
if(argc > 1)
{
int i;
......@@ -114,6 +115,7 @@ static t_symbol *get_filename(t_int argc, t_atom *argv)
}
}
fname = gensym(buf);
//fprintf(stderr,"argc>1 fname=<%s>\n", fname->s_name);
}
return fname;
}
......@@ -313,7 +315,7 @@ static void image_imagesize_callback(t_image *x, t_float w, t_float h) {
//fprintf(stderr,"erasing\n");
image_erase(x, glist_getcanvas(x->x_glist));
} else {
sys_vgui("catch {.x%x.c delete %xMT}\n", x->x_glist, x);
sys_vgui("catch {.x%x.c delete %xMT}\n", glist_getcanvas(x->x_glist), x);
canvas_fixlinesfor(x->x_glist,(t_text*) x);
}
}
......@@ -354,7 +356,7 @@ static void *image_new(t_symbol *s, t_int argc, t_atom *argv)
x->x_fname = get_filename(argc, argv);
if (strlen(x->x_fname->s_name) > 0) {
//fprintf(stderr,"get_filename succeeded %s\n", x->x_fname->s_name);
//fprintf(stderr,"get_filename succeeded <%s> <%s>\n", x->x_fname->s_name, atom_getsymbol(argv)->s_name);
argc--;
argv++;
}
......
......@@ -213,16 +213,17 @@ void canvas_makefilename(t_canvas *x, char *file, char *result, int resultsize)
{
char interim[FILENAME_MAX];
sys_expandpathelems(file, interim);
//fprintf(stderr,"interim = <%s>\n", interim);
char *dir = canvas_getenv(x)->ce_dir->s_name;
if (interim[0] == '/' || (interim[0] && interim[1] == ':') || !*dir)
{
fprintf(stderr,"root file\n");
//fprintf(stderr,"root file\n");
strncpy(result, interim, resultsize);
result[resultsize-1] = 0;
}
else
{
fprintf(stderr,"relative file\n");
//fprintf(stderr,"relative file\n");
int nleft;
strncpy(result, dir, resultsize);
result[resultsize-1] = 0;
......@@ -232,7 +233,7 @@ void canvas_makefilename(t_canvas *x, char *file, char *result, int resultsize)
strncat(result, interim, nleft);
result[resultsize-1] = 0;
}
fprintf(stderr,"resulting file = <%s>\n", result);
//fprintf(stderr,"resulting file = <%s>\n", result);
}
void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir)
......
......@@ -1408,8 +1408,22 @@ void canvas_undo_arrange(t_canvas *x, void *z, int action)
// and finally redraw canvas--we have to redraw canvas since
// there is no consistent naming of objects
t_object *ob = NULL;
t_rtext *yr = NULL;
ob = pd_checkobject(&next->g_pd);
if (ob) {
yr = glist_findrtext(x, (t_text *)&ob->ob_g);
}
if (yr) {
fprintf(stderr,"lower\n");
sys_vgui(".x%lx.c lower selected %s\n", x, rtext_gettag(yr));
//sys_vgui(".x%lx.c raise all_cords\n", x);
} else {
fprintf(stderr,"redraw\n");
canvas_redraw(x);
}
//sys_vgui(".x%lx.c lower selected .%lx\n", x, (t_int)next);
canvas_redraw(x);
//canvas_redraw(x);
glob_preset_node_list_check_loc_and_update();
}
......@@ -1430,11 +1444,24 @@ void canvas_undo_arrange(t_canvas *x, void *z, int action)
prev->g_next = y;
y->g_next = next;
// and finally redraw canvas--we have to redraw canvas since
// there is no consistent naming of objects
// and finally redraw canvas
t_object *ob = NULL;
t_rtext *yr = NULL;
ob = pd_checkobject(&prev->g_pd);
if (ob) {
yr = glist_findrtext(x, (t_text *)&ob->ob_g);
}
if (yr) {
fprintf(stderr,"raise\n");
sys_vgui(".x%lx.c raise selected %s\n", x, rtext_gettag(yr));
//sys_vgui(".x%lx.c raise all_cords\n", x);
} else {
fprintf(stderr,"redraw\n");
canvas_redraw(x);
}
//sys_vgui(".x%lx.c raise selected .%lx\n", x, (t_int)prev);
//sys_vgui(".x%lx.c raise all_cords\n", x);
canvas_redraw(x);
//canvas_redraw(x);
glob_preset_node_list_check_loc_and_update();
}
......@@ -2476,9 +2503,20 @@ static void canvas_doarrange(t_canvas *x, t_float which, t_gobj *oldy, t_gobj *o
else x->gl_list = oldy_next;
// and finally redraw
sys_vgui(".x%lx.c raise selected\n", x);
sys_vgui(".x%lx.c raise all_cords\n", x);
//canvas_redraw(x);
t_object *ob = NULL;
t_rtext *yr = NULL;
ob = pd_checkobject(&y_end->g_pd);
if (ob) {
yr = glist_findrtext(x, (t_text *)&ob->ob_g);
}
if (yr) {
fprintf(stderr,"raise\n");
sys_vgui(".x%lx.c raise selected %s\n", x, rtext_gettag(yr));
//sys_vgui(".x%lx.c raise all_cords\n", x);
} else {
fprintf(stderr,"redraw\n");
canvas_redraw(x);
}
}
if (which == 4) /* to back */
{
......
......@@ -149,16 +149,20 @@ static void sys_expandpath(const char *from, char *to)
void sys_expandpathelems(const char *name, char *result)
{
//check for expandable elements in path (e.g. @pd_extra, ~/) and replace
//fprintf(stderr,"sys_expandpathelems name=<%s>\n", name);
char interim[FILENAME_MAX];
if (strstr(name, "@pd_extra") != NULL) {
t_namelist *path = pd_extrapath;
while (path->nl_next)
path = path->nl_next;
sys_path_replace(name, interim, "@pd_extra", path->nl_string);
//fprintf(stderr,"path->nl_string=<%s>\n", path->nl_string);
} else {
strcpy(interim, name);
}
//fprintf(stderr,"sys_expandpathelems interim=<%s>\n", interim);
sys_expandpath(interim, result);
//fprintf(stderr,"sys_expandpathelems result=<%s>\n", result);
}
/* test if path is absolute or relative, based on leading /, env vars, ~, etc */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment