Commit 4717bd58 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Jonathan's clean-up of the g_canvas.c

parent ef4b5e5b
......@@ -216,19 +216,19 @@ t_symbol *canvas_getdir(t_canvas *x)
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 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;
......@@ -238,7 +238,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)
......@@ -419,7 +419,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
(canvas_newfilename ? canvas_newfilename : gensym("Pd")));
canvas_bind(x);
x->gl_loading = 1;
//fprintf(stderr,"loading = 1 .x%lx owner=.x%lx\n", (t_int)x, (t_int)x->gl_owner);
//fprintf(stderr,"loading = 1 .x%lx owner=.x%lx\n", (t_int)x, (t_int)x->gl_owner);
x->gl_goprect = 0; /* no GOP rectangle unless it's turned on later */
/* cancel "vis" flag if we're a subpatch of an
abstraction inside another patch. A separate mechanism prevents
......@@ -438,39 +438,39 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
x->gl_font = sys_nearestfontsize(font);
pd_pushsym(&x->gl_pd);
//dpsaha@vt.edu gop resize
//resize blob
t_scalehandle *sh;
char buf[64];
x->x_handle = pd_new(scalehandle_class);
sh = (t_scalehandle *)x->x_handle;
sh->h_master = (t_gobj*)x;
sprintf(buf, "_h%lx", (t_int)sh);
pd_bind(x->x_handle, sh->h_bindsym = gensym(buf));
sprintf(sh->h_outlinetag, "h%lx", (t_int)sh);
sh->h_dragon = 0;
sh->h_scale = 1;
x->scale_offset_x = 0;
x->scale_offset_y = 0;
x->scale_vis = 0;
//move blob
t_scalehandle *mh;
char mbuf[64];
x->x_mhandle = pd_new(scalehandle_class);
mh = (t_scalehandle *)x->x_mhandle;
mh->h_master = (t_gobj*)x;
sprintf(mbuf, "_h%lx", (t_int)mh);
pd_bind(x->x_mhandle, mh->h_bindsym = gensym(mbuf));
sprintf(mh->h_outlinetag, "h%lx", (t_int)mh);
mh->h_dragon = 0;
mh->h_scale = 0;
x->move_offset_x = 0;
x->move_offset_y = 0;
x->move_vis = 0;
x->u_queue = canvas_undo_init(x);
//dpsaha@vt.edu gop resize
//resize blob
t_scalehandle *sh;
char buf[64];
x->x_handle = pd_new(scalehandle_class);
sh = (t_scalehandle *)x->x_handle;
sh->h_master = (t_gobj*)x;
sprintf(buf, "_h%lx", (t_int)sh);
pd_bind(x->x_handle, sh->h_bindsym = gensym(buf));
sprintf(sh->h_outlinetag, "h%lx", (t_int)sh);
sh->h_dragon = 0;
sh->h_scale = 1;
x->scale_offset_x = 0;
x->scale_offset_y = 0;
x->scale_vis = 0;
//move blob
t_scalehandle *mh;
char mbuf[64];
x->x_mhandle = pd_new(scalehandle_class);
mh = (t_scalehandle *)x->x_mhandle;
mh->h_master = (t_gobj*)x;
sprintf(mbuf, "_h%lx", (t_int)mh);
pd_bind(x->x_mhandle, mh->h_bindsym = gensym(mbuf));
sprintf(mh->h_outlinetag, "h%lx", (t_int)mh);
mh->h_dragon = 0;
mh->h_scale = 0;
x->move_offset_x = 0;
x->move_offset_y = 0;
x->move_vis = 0;
x->u_queue = canvas_undo_init(x);
return(x);
}
......@@ -479,8 +479,8 @@ void canvas_setgraph(t_glist *x, int flag, int nogoprect);
static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv)
{
//IB: first delete the graph in case we are downsizing the object size via script
canvas_setgraph(x, 0, 0);
//IB: first delete the graph in case we are downsizing the object size via script
canvas_setgraph(x, 0, 0);
x->gl_x1 = atom_getfloatarg(0, argc, argv);
x->gl_y1 = atom_getfloatarg(1, argc, argv);
......@@ -537,8 +537,8 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
}
if (x1 == x2 || y1 == y2)
x1 = 0, x2 = 100, y1 = 1, y2 = -1;
if (px1 != 0 && px2 == 0) px2 = px1 + GLIST_DEFGRAPHWIDTH;
if (py1 != 0 && py2 == py1) py2 = py1 + GLIST_DEFGRAPHHEIGHT;
if (px1 != 0 && px2 == 0) px2 = px1 + GLIST_DEFGRAPHWIDTH;
if (py1 != 0 && py2 == py1) py2 = py1 + GLIST_DEFGRAPHHEIGHT;
if (px1 >= px2 || py1 >= py2)
px1 = 100, py1 = 20, px2 = 100 + GLIST_DEFGRAPHWIDTH,
py2 = 20 + GLIST_DEFGRAPHHEIGHT;
......@@ -558,7 +558,7 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
x->gl_screenx2 = 450;
x->gl_screeny2 = 300;
x->gl_owner = g;
canvas_bind(x);
canvas_bind(x);
x->gl_isgraph = 1;
x->gl_goprect = 0;
x->gl_obj.te_binbuf = binbuf_new();
......@@ -566,7 +566,7 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
if (!menu)
pd_pushsym(&x->gl_pd);
glist_add(g, &x->gl_gobj);
if (!do_not_redraw) sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)glist_getcanvas(g));
if (!do_not_redraw) sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)glist_getcanvas(g));
return (x);
}
......@@ -576,10 +576,10 @@ extern int we_are_undoing;
void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv)
{
if (canvas_hasarray(g)) return;
pd_vmess(&g->gl_pd, gensym("editmode"), "i", 1);
pd_vmess(&g->gl_pd, gensym("editmode"), "i", 1);
t_symbol *sym = atom_getsymbolarg(0, argc, argv);
/* if we wish to put a graph where the mouse is we need to replace bogus name */
if (!strcmp(sym->s_name, "NULL")) sym = &s_;
/* if we wish to put a graph where the mouse is we need to replace bogus name */
if (!strcmp(sym->s_name, "NULL")) sym = &s_;
t_float x1 = atom_getfloatarg(1, argc, argv);
t_float y1 = atom_getfloatarg(2, argc, argv);
t_float x2 = atom_getfloatarg(3, argc, argv);
......@@ -618,7 +618,7 @@ int glist_isgraph(t_glist *x)
moved or resized. */
void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2)
{
//fprintf(stderr,"canvas_setbounds %d %d %d %d\n", x1, y1, x2, y2);
//fprintf(stderr,"canvas_setbounds %d %d %d %d\n", x1, y1, x2, y2);
int heightwas = y2 - y1;
int heightchange = y2 - y1 - (x->gl_screeny2 - x->gl_screeny1);
......@@ -658,7 +658,7 @@ t_symbol *canvas_makebindsym(t_symbol *s)
void canvas_reflecttitle(t_canvas *x)
{
//fprintf(stderr,"canvas_reflecttitle\n");
//fprintf(stderr,"canvas_reflecttitle\n");
char namebuf[MAXPDSTRING];
t_canvasenvironment *env = canvas_getenv(x);
if (env->ce_argc)
......@@ -682,14 +682,16 @@ void canvas_reflecttitle(t_canvas *x)
x, x->gl_dirty, canvas_getdir(x)->s_name, x->gl_name->s_name);
sys_vgui("wm title .x%lx {%s%s}\n", x, x->gl_name->s_name, namebuf);
#else
//if(glist_havewindow(x) || !x->gl_isgraph || x->gl_isgraph && x->gl_havewindow || x->gl_loading || x->gl_dirty) {
/*fprintf(stderr,"%d %d %d %d %d\n", glist_istoplevel(x), !x->gl_isgraph,
x->gl_isgraph && x->gl_havewindow, x->gl_loading,
x->gl_dirty);*/
sys_vgui("wm title .x%lx {%s%c%s - %s}\n",
x, x->gl_name->s_name, (x->gl_dirty? '*' : ' '), namebuf,
//if(glist_havewindow(x) || !x->gl_isgraph || x->gl_isgraph && x->gl_havewindow || x->gl_loading || x->gl_dirty) {
/*fprintf(stderr,"%d %d %d %d %d\n", glist_istoplevel(x), !x->gl_isgraph,
x->gl_isgraph && x->gl_havewindow, x->gl_loading,
x->gl_dirty);*/
sys_vgui("wm title .x%lx {%s%c%s - %s}\n",
x, x->gl_name->s_name, (x->gl_dirty? '*' : ' '), namebuf,
canvas_getdir(x)->s_name);
//}
//}
#endif
}
......@@ -722,67 +724,78 @@ extern void canvas_check_nlet_highlights(t_canvas *x);
/*********** dpsaha@vt.edu resize move hooks ****************/
void canvas_draw_gop_resize_hooks(t_canvas* x)
{
t_scalehandle *sh = (t_scalehandle *)(x->x_handle);
t_scalehandle *mh = (t_scalehandle *)(x->x_mhandle);
if (!sh || !mh) return; //in case we are an array which does not initialize its hooks
if(x->gl_edit && glist_isvisible(x) && glist_istoplevel(x) && x->gl_goprect && !x->gl_editor->e_selection) {
//Drawing and Binding Resize_Blob for GOP
//fprintf(stderr,"draw_gop_resize_hooks %lx %lx\n", (t_int)x, (t_int)glist_getcanvas(x));
sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)x, (t_int)sh);
sys_vgui("destroy %s\n", sh->h_pathname);
sys_vgui(".x%lx.c delete GOP_resblob\n", x);
sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 -cursor bottom_right_corner\n",
sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %lxGOP GOP_resblob}\n",
x, x->gl_xmargin + x->gl_pixwidth - SCALEHANDLE_WIDTH - 1,
x->gl_ymargin + 3 + x->gl_pixheight - SCALEHANDLE_HEIGHT - 4,
SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT,
sh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
sh->h_pathname, sh->h_bindsym->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n",
sh->h_pathname, sh->h_bindsym->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
sh->h_pathname, sh->h_bindsym->s_name);
//Drawing and Binding Move_Blob for GOP
sprintf(mh->h_pathname, ".x%lx.h%lx", (t_int)x, (t_int)mh);
sys_vgui("destroy %s\n", mh->h_pathname);
sys_vgui(".x%lx.c delete GOP_movblob\n", x);
sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 -cursor crosshair\n",
mh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxMOVE %lxGOP GOP_movblob}\n",
x, x->gl_xmargin + 2 ,
x->gl_ymargin + 2 ,
SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT,
mh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
mh->h_pathname, mh->h_bindsym->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n",
mh->h_pathname, mh->h_bindsym->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
mh->h_pathname, mh->h_bindsym->s_name);
}
else{
if (sh && sh->h_pathname)
sys_vgui("destroy %s\n", sh->h_pathname);
if (mh && mh->h_pathname)
sys_vgui("destroy %s\n", mh->h_pathname);
sys_vgui(".x%lx.c delete GOP_resblob ; .x%lx.c delete GOP_movblob ;\n", x, x); //delete the GOP_resblob and GOP_movblob
}
canvas_check_nlet_highlights(x);
t_scalehandle *sh = (t_scalehandle *)(x->x_handle);
t_scalehandle *mh = (t_scalehandle *)(x->x_mhandle);
//in case we are an array which does not initialize its hooks
if (!sh || !mh) return;
if(x->gl_edit && glist_isvisible(x) && glist_istoplevel(x) &&
x->gl_goprect && !x->gl_editor->e_selection)
{
//Drawing and Binding Resize_Blob for GOP
//fprintf(stderr,"draw_gop_resize_hooks %lx %lx\n",
// (t_int)x, (t_int)glist_getcanvas(x));
sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)x, (t_int)sh);
sys_vgui("destroy %s\n", sh->h_pathname);
sys_vgui(".x%lx.c delete GOP_resblob\n", x);
sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) "
"-bd 0 -cursor bottom_right_corner\n",
sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw "
"-width %d -height %d -window %s "
"-tags {%lxSCALE %lxGOP GOP_resblob}\n",
x, x->gl_xmargin + x->gl_pixwidth - SCALEHANDLE_WIDTH - 1,
x->gl_ymargin + 3 + x->gl_pixheight - SCALEHANDLE_HEIGHT - 4,
SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT,
sh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
sh->h_pathname, sh->h_bindsym->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n",
sh->h_pathname, sh->h_bindsym->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
sh->h_pathname, sh->h_bindsym->s_name);
//Drawing and Binding Move_Blob for GOP
sprintf(mh->h_pathname, ".x%lx.h%lx", (t_int)x, (t_int)mh);
sys_vgui("destroy %s\n", mh->h_pathname);
sys_vgui(".x%lx.c delete GOP_movblob\n", x);
sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) "
"-bd 0 -cursor crosshair\n",
mh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d "
"-window %s -tags {%lxMOVE %lxGOP GOP_movblob}\n",
x, x->gl_xmargin + 2 ,
x->gl_ymargin + 2 ,
SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT,
mh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
mh->h_pathname, mh->h_bindsym->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n",
mh->h_pathname, mh->h_bindsym->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
mh->h_pathname, mh->h_bindsym->s_name);
}
else
{
if (sh && sh->h_pathname)
sys_vgui("destroy %s\n", sh->h_pathname);
if (mh && mh->h_pathname)
sys_vgui("destroy %s\n", mh->h_pathname);
//delete the GOP_resblob and GOP_movblob
sys_vgui(".x%lx.c delete GOP_resblob ; "
".x%lx.c delete GOP_movblob ;\n",
x, x);
}
canvas_check_nlet_highlights(x);
}
/*****************************************************************************/
void canvas_drawredrect(t_canvas *x, int doit)
{
if (doit){
if (doit)
{
//fprintf(stderr,"GOP %d %d\n", x->gl_pixwidth, x->gl_pixheight);
sys_vgui(".x%lx.c create line\
%d %d %d %d %d %d %d %d %d %d -fill #ff8080 -tags GOP\n",
......@@ -792,10 +805,10 @@ void canvas_drawredrect(t_canvas *x, int doit)
x->gl_xmargin + x->gl_pixwidth, x->gl_ymargin + x->gl_pixheight,
x->gl_xmargin, x->gl_ymargin + x->gl_pixheight,
x->gl_xmargin, x->gl_ymargin);
if (x->gl_goprect && x->gl_edit){
canvas_draw_gop_resize_hooks(x); //dpsaha@vt.edu for drawing the GOP_blobs
}
}
//dpsaha@vt.edu for drawing the GOP_blobs
if (x->gl_goprect && x->gl_edit)
canvas_draw_gop_resize_hooks(x);
}
else sys_vgui(".x%lx.c delete GOP\n", glist_getcanvas(x));
}
......@@ -804,15 +817,15 @@ void canvas_drawredrect(t_canvas *x, int doit)
called from the GUI after the fact to "notify" us that we're mapped. */
void canvas_map(t_canvas *x, t_floatarg f)
{
//fprintf(stderr,"canvas_map %lx %f\n", (t_int)x, f);
//fprintf(stderr,"canvas_map %lx %f\n", (t_int)x, f);
int flag = (f != 0);
t_gobj *y;
if (flag)
{
//fprintf(stderr,"canvas_map 1\n");
//fprintf(stderr,"canvas_map 1\n");
//if (!glist_isvisible(x))
//{
//fprintf(stderr,"canvas_map 1 isvisible\n");
//fprintf(stderr,"canvas_map 1 isvisible\n");
t_selection *sel;
if (!x->gl_havewindow)
{
......@@ -820,16 +833,16 @@ void canvas_map(t_canvas *x, t_floatarg f)
canvas_vis(x, 1);
}
if (!x->gl_list) {
//if there are no objects on the canvas
canvas_create_editor(x);
}
if (!x->gl_list) {
//if there are no objects on the canvas
canvas_create_editor(x);
}
else for (y = x->gl_list; y; y = y->g_next) {
gobj_vis(y, x, 1);
}
if (x->gl_editor && x->gl_editor->e_selection)
for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
gobj_select(sel->sel_what, x, 1);
}
if (x->gl_editor && x->gl_editor->e_selection)
for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
gobj_select(sel->sel_what, x, 1);
x->gl_mapped = 1;
canvas_drawlines(x);
if (x->gl_isgraph && x->gl_goprect)
......@@ -839,13 +852,13 @@ void canvas_map(t_canvas *x, t_floatarg f)
}
else
{
//fprintf(stderr,"canvas_map 0\n");
//fprintf(stderr,"canvas_map 0\n");
if (glist_isvisible(x))
{
/* just clear out the whole canvas */
sys_vgui(".x%lx.c dtag all selected\n", x);
sys_vgui(".x%lx.c dtag all selected\n", x);
//sys_vgui(".x%lx.c delete all\n", x);
sys_vgui("foreach item [.x%lx.c find withtag {(!root)}] { .x%lx.c delete $item }\n", x, x);
sys_vgui("foreach item [.x%lx.c find withtag {(!root)}] { .x%lx.c delete $item }\n", x, x);
x->gl_mapped = 0;
}
}
......@@ -853,51 +866,55 @@ void canvas_map(t_canvas *x, t_floatarg f)
void canvas_redraw(t_canvas *x)
{
if (do_not_redraw) return;
//fprintf(stderr,"canvas_redraw %lx\n", (t_int)x);
if (do_not_redraw) return;
//fprintf(stderr,"canvas_redraw %lx\n", (t_int)x);
if (glist_isvisible(x))
{
//fprintf(stderr,"canvas_redraw glist_isvisible=true\n");
//fprintf(stderr,"canvas_redraw glist_isvisible=true\n");
canvas_map(x, 0);
canvas_map(x, 1);
/* now re-highlight our selection */
t_selection *y;
if (x->gl_editor && x->gl_editor->e_selection)
for (y = x->gl_editor->e_selection; y; y = y->sel_next)
gobj_select(y->sel_what, x, 1);
/* now re-highlight our selection */
t_selection *y;
if (x->gl_editor && x->gl_editor->e_selection)
for (y = x->gl_editor->e_selection; y; y = y->sel_next)
gobj_select(y->sel_what, x, 1);
}
}
/* we call this on a non-toplevel glist to "open" it into its
own window. */
void glist_menu_open(t_glist *x)
{
if (glist_isvisible(x))
{
if (!glist_istoplevel(x)) {
t_glist *gl2 = x->gl_owner;
if (!gl2)
bug("glist_menu_open"); /* shouldn't happen but not dangerous */
else
{
/* erase ourself in parent window */
gobj_vis(&x->gl_gobj, gl2, 0);
/* get rid of our editor (and subeditors) */
if (x->gl_editor)
canvas_destroy_editor(x);
x->gl_havewindow = 1;
/* redraw ourself in parent window (blanked out this time) */
gobj_vis(&x->gl_gobj, gl2, 1);
}
} else {
sys_vgui("focus .x%lx\n", (t_int)x);
}
} else {
if (!glist_istoplevel(x))
{
t_glist *gl2 = x->gl_owner;
if (!gl2)
bug("glist_menu_open"); /* shouldn't happen but not dangerous */
else
{
/* erase ourself in parent window */
gobj_vis(&x->gl_gobj, gl2, 0);
/* get rid of our editor (and subeditors) */
if (x->gl_editor)
canvas_destroy_editor(x);
x->gl_havewindow = 1;
/* redraw ourself in parent window (blanked out this time) */
gobj_vis(&x->gl_gobj, gl2, 1);
}
}
else
{
sys_vgui("focus .x%lx\n", (t_int)x);
}
}
else
{
if (x->gl_editor)
canvas_destroy_editor(x);
}
canvas_destroy_editor(x);
}
canvas_vis(x, 1);
}
......@@ -924,12 +941,12 @@ int glist_getfont(t_glist *x)
void canvas_free(t_canvas *x)
{
//fprintf(stderr,"canvas_free %lx\n", x);
//fprintf(stderr,"canvas_free %lx\n", x);
t_gobj *y;
int dspstate = canvas_suspend_dsp();
//canvas_noundo(x);
canvas_undo_free(x);
canvas_undo_free(x);
if (canvas_editing == x)
canvas_editing = 0;
......@@ -942,7 +959,7 @@ void canvas_free(t_canvas *x)
canvas_vis(x, 0);
if (x->gl_editor)
canvas_destroy_editor(x); /* bug workaround; should already be gone*/
canvas_unbind(x);
canvas_unbind(x);
if (x->gl_env)
{
freebytes(x->gl_env->ce_argv, x->gl_env->ce_argc * sizeof(t_atom));
......@@ -962,18 +979,23 @@ static void canvas_drawlines(t_canvas *x)
t_linetraverser t;
t_outconnect *oc;
int issignal;
linetraverser_start(&t, x);
while (oc = linetraverser_next(&t))
linetraverser_start(&t, x);
while (oc = linetraverser_next(&t))
{
issignal = (outlet_getsymbol(t.tr_outlet) == &s_signal ? 1 : 0);
if (!(pd_class(&t.tr_ob2->ob_g.g_pd) == preset_node_class && pd_class(&t.tr_ob->ob_g.g_pd) != message_class))
canvas_drawconnection(glist_getcanvas(x), t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, (t_int)oc, issignal);
/*sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %s -stroke %s \
-tags {l%lx all_cords %s}\n",
glist_getcanvas(x), t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2,
(issignal ? "$pd_colors(signal_cord_width)" : "$pd_colors(control_cord_width)"), (issignal ? "$pd_colors(signal_cord)" : "$pd_colors(control_cord)"),
oc);*/
if (!(pd_class(&t.tr_ob2->ob_g.g_pd) == preset_node_class &&
pd_class(&t.tr_ob->ob_g.g_pd) != message_class))
canvas_drawconnection(glist_getcanvas(x), t.tr_lx1, t.tr_ly1,
t.tr_lx2, t.tr_ly2, (t_int)oc, issignal);
/*sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %s "
"-stroke %s -tags {l%lx all_cords %s}\n",
glist_getcanvas(x), t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2,
(issignal ? "$pd_colors(signal_cord_width)" :
"$pd_colors(control_cord_width)"),
(issignal ? "$pd_colors(signal_cord)" :
"$pd_colors(control_cord)"),
oc);*/
}
}
......@@ -990,7 +1012,7 @@ void canvas_fixlinesfor(t_canvas *x, t_text *text)
/*sys_vgui(".x%lx.c coords l%lx %d %d %d %d\n",
glist_getcanvas(x), oc,
t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);*/
canvas_updateconnection(x, t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, (t_int)oc);
canvas_updateconnection(x, t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, (t_int)oc);
}
}
}
......@@ -1015,8 +1037,8 @@ void canvas_deletelinesfor(t_canvas *x, t_text *text)
}
}
/* delete all lines for the object
for efficient redrawing of connections */
/* delete all lines for the object
for efficient redrawing of connections */
void canvas_eraselinesfor(t_canvas *x, t_text *text)
{
t_linetraverser t;
......@@ -1066,13 +1088,12 @@ static void canvas_pop(t_canvas *x, t_floatarg fvis)
canvas_resortinlets(x);
canvas_resortoutlets(x);
x->gl_loading = 0;
//sys_vgui("pdtk_canvas_force_getscroll .x%lx.c\n", x);
//fprintf(stderr,"loading = 0 .x%lx owner=.x%lx\n", x, x->gl_owner);
//sys_vgui("pdtk_canvas_force_getscroll .x%lx.c\n", x);
//fprintf(stderr,"loading = 0 .x%lx owner=.x%lx\n", x, x->gl_owner);
}
void canvas_objfor(t_glist *gl, t_text *x, int argc, t_atom *argv);
void canvas_restore(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
{
t_pd *z;
......@@ -1104,18 +1125,21 @@ void canvas_loadbangsubpatches(t_canvas *x, t_symbol *s)
//t_symbol *s = gensym("loadbang");
for (y = x->gl_list; y; y = y->g_next)
if (pd_class(&y->g_pd) == canvas_class)
{
if (!canvas_isabstraction((t_canvas *)y)) {
//fprintf(stderr,"%lx s:canvas_loadbangsubpatches %s\n",x,s->s_name);
{
if (!canvas_isabstraction((t_canvas *)y))
{
//fprintf(stderr,"%lx s:canvas_loadbangsubpatches %s\n",
// x, s->s_name);
canvas_loadbangsubpatches((t_canvas *)y, s);
}
}
}
}
for (y = x->gl_list; y; y = y->g_next)
if ((pd_class(&y->g_pd) != canvas_class) &&