aboutsummaryrefslogtreecommitdiff
path: root/pd/src/g_canvas.c
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2004-09-06 20:20:36 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2004-09-06 20:20:36 +0000
commited932acb5860bf8b9296169676499562a55d139e (patch)
treedc6a40dba908deb07c175cd40ee19c197318f72d /pd/src/g_canvas.c
parentdad636821f6e7d3ead02c157f308c0ceeba9af3d (diff)
checking in version 0.38test5.
Oops, I realize I forgot some more nice files, will add them and re-commit. svn path=/trunk/; revision=2010
Diffstat (limited to 'pd/src/g_canvas.c')
-rw-r--r--pd/src/g_canvas.c936
1 files changed, 469 insertions, 467 deletions
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index 980db26e..2d124ac3 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -29,10 +29,10 @@ to be different but are now unified except for some fossilized names.) */
struct _canvasenvironment
{
- t_symbol *ce_dir; /* directory patch lives in */
- int ce_argc; /* number of "$" arguments */
- t_atom *ce_argv; /* array of "$" arguments */
- int ce_dollarzero; /* value of "$0" */
+ t_symbol *ce_dir; /* directory patch lives in */
+ int ce_argc; /* number of "$" arguments */
+ t_atom *ce_argv; /* array of "$" arguments */
+ int ce_dollarzero; /* value of "$0" */
};
#define GLIST_DEFCANVASWIDTH 450
@@ -48,10 +48,10 @@ struct _canvasenvironment
extern t_pd *newest;
t_class *canvas_class;
-static int canvas_dspstate; /* whether DSP is on or off */
-t_canvas *canvas_editing; /* last canvas to start text edting */
-t_canvas *canvas_whichfind; /* last canvas we did a find in */
-t_canvas *canvas_list; /* list of all root canvases */
+static int canvas_dspstate; /* whether DSP is on or off */
+t_canvas *canvas_editing; /* last canvas to start text edting */
+t_canvas *canvas_whichfind; /* last canvas we did a find in */
+t_canvas *canvas_list; /* list of all root canvases */
/* ------------------ forward function declarations --------------- */
static void canvas_start_dsp(void);
@@ -76,22 +76,23 @@ static void glist_doupdatewindowlist(t_glist *gl, char *sbuf)
t_gobj *g;
if (!gl->gl_owner)
{
- /* this is a canvas; if we have a window, put on "windows" list */
- t_canvas *canvas = (t_canvas *)gl;
- if (canvas->gl_havewindow)
- {
- if (strlen(sbuf) + strlen(gl->gl_name->s_name) + 100 <= 1024)
- {
- char tbuf[1024];
- sprintf(tbuf, "{%s .x%x} ", gl->gl_name->s_name, (t_int)canvas);
- strcat(sbuf, tbuf);
- }
- }
+ /* this is a canvas; if we have a window, put on "windows" list */
+ t_canvas *canvas = (t_canvas *)gl;
+ if (canvas->gl_havewindow)
+ {
+ if (strlen(sbuf) + strlen(gl->gl_name->s_name) + 100 <= 1024)
+ {
+ char tbuf[1024];
+ sprintf(tbuf, "{%s .x%lx} ", gl->gl_name->s_name,
+ (t_int)canvas);
+ strcat(sbuf, tbuf);
+ }
+ }
}
for (g = gl->gl_list; g; g = g->g_next)
{
- if (pd_class(&g->g_pd) == canvas_class)
- glist_doupdatewindowlist((t_glist *)g, sbuf);
+ if (pd_class(&g->g_pd) == canvas_class)
+ glist_doupdatewindowlist((t_glist *)g, sbuf);
}
return;
}
@@ -102,9 +103,9 @@ void canvas_updatewindowlist( void)
t_canvas *x;
char sbuf[1024];
strcpy(sbuf, "set menu_windowlist {");
- /* find all root canvases */
+ /* find all root canvases */
for (x = canvas_list; x; x = x->gl_next)
- glist_doupdatewindowlist(x, sbuf);
+ glist_doupdatewindowlist(x, sbuf);
/* next line updates the window menu state before -postcommand tries it */
strcat(sbuf, "}\npdtk_fixwindowmenu\n");
sys_gui(sbuf);
@@ -119,25 +120,25 @@ static void canvas_addtolist(t_canvas *x)
static void canvas_takeofflist(t_canvas *x)
{
- /* take it off the window list */
+ /* take it off the window list */
if (x == canvas_list) canvas_list = x->gl_next;
else
{
- t_canvas *z;
- for (z = canvas_list; z->gl_next != x; z = z->gl_next)
- ;
- z->gl_next = x->gl_next;
+ t_canvas *z;
+ for (z = canvas_list; z->gl_next != x; z = z->gl_next)
+ ;
+ z->gl_next = x->gl_next;
}
}
void canvas_setargs(int argc, t_atom *argv)
{
- /* if there's an old one lying around free it here. This
- happens if an abstraction is loaded but never gets as far
- as calling canvas_new(). */
+ /* if there's an old one lying around free it here. This
+ happens if an abstraction is loaded but never gets as far
+ as calling canvas_new(). */
if (canvas_newargv)
- freebytes(canvas_newargv, canvas_newargc * sizeof(t_atom));
+ freebytes(canvas_newargv, canvas_newargc * sizeof(t_atom));
canvas_newargc = argc;
canvas_newargv = copybytes(argv, argc * sizeof(t_atom));
}
@@ -167,8 +168,8 @@ t_canvasenvironment *canvas_getenv(t_canvas *x)
{
if (!x) bug("canvas_getenv");
while (!x->gl_env)
- if (!(x = x->gl_owner))
- bug("t_canvasenvironment", x);
+ if (!(x = x->gl_owner))
+ bug("t_canvasenvironment", x);
return (x->gl_env);
}
@@ -177,7 +178,7 @@ int canvas_getdollarzero( void)
t_canvas *x = canvas_getcurrent();
t_canvasenvironment *env = (x ? canvas_getenv(x) : 0);
if (env)
- return (env->ce_dollarzero);
+ return (env->ce_dollarzero);
else return (0);
}
@@ -194,11 +195,11 @@ t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s)
char *name = s->s_name;
if (*name == '$' && name[1] >= '0' && name[1] <= '9')
{
- t_canvasenvironment *env = canvas_getenv(x);
- canvas_setcurrent(x);
- ret = binbuf_realizedollsym(gensym(name+1),
- env->ce_argc, env->ce_argv, 1);
- canvas_unsetcurrent(x);
+ t_canvasenvironment *env = canvas_getenv(x);
+ canvas_setcurrent(x);
+ ret = binbuf_realizedollsym(gensym(name+1),
+ env->ce_argc, env->ce_argv, 1);
+ canvas_unsetcurrent(x);
}
else ret = s;
return (ret);
@@ -221,35 +222,35 @@ void canvas_makefilename(t_canvas *x, char *file, char *result, int resultsize)
char *dir = canvas_getenv(x)->ce_dir->s_name;
if (file[0] == '/' || (file[0] && file[1] == ':') || !*dir)
{
- strncpy(result, file, resultsize);
- result[resultsize-1] = 0;
+ strncpy(result, file, resultsize);
+ result[resultsize-1] = 0;
}
else
{
- int nleft;
- strncpy(result, dir, resultsize);
- result[resultsize-1] = 0;
- nleft = resultsize - strlen(result) - 1;
- if (nleft <= 0) return;
- strcat(result, "/");
- strncat(result, file, nleft);
- result[resultsize-1] = 0;
- }
+ int nleft;
+ strncpy(result, dir, resultsize);
+ result[resultsize-1] = 0;
+ nleft = resultsize - strlen(result) - 1;
+ if (nleft <= 0) return;
+ strcat(result, "/");
+ strncat(result, file, nleft);
+ result[resultsize-1] = 0;
+ }
}
void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir)
{
if (strcmp(x->gl_name->s_name, "Pd"))
- pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
+ pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
x->gl_name = s;
if (strcmp(x->gl_name->s_name, "Pd"))
- pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
+ pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
if (glist_isvisible(x))
- canvas_reflecttitle(x);
+ canvas_reflecttitle(x);
if (dir && dir != &s_)
{
- t_canvasenvironment *e = canvas_getenv(x);
- e->ce_dir = dir;
+ t_canvasenvironment *e = canvas_getenv(x);
+ e->ce_dir = dir;
}
}
@@ -260,7 +261,7 @@ int canvas_getindex(t_canvas *x, t_gobj *y)
t_gobj *y2;
int indexno;
for (indexno = 0, y2 = x->gl_list; y2 && y2 != y; y2 = y2->g_next)
- indexno++;
+ indexno++;
return (indexno);
}
@@ -278,51 +279,51 @@ t_outconnect *linetraverser_next(t_linetraverser *t)
int outno;
while (!rval)
{
- outno = t->tr_nextoutno;
- while (outno == t->tr_nout)
- {
- t_gobj *y;
- t_object *ob = 0;
- if (!t->tr_ob) y = t->tr_x->gl_list;
- else y = t->tr_ob->ob_g.g_next;
- for (; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd)) break;
- if (!ob) return (0);
- t->tr_ob = ob;
- t->tr_nout = obj_noutlets(ob);
- outno = 0;
- if (glist_isvisible(t->tr_x))
- gobj_getrect(y, t->tr_x,
- &t->tr_x11, &t->tr_y11, &t->tr_x12, &t->tr_y12);
- else t->tr_x11 = t->tr_y11 = t->tr_x12 = t->tr_y12 = 0;
- }
- t->tr_nextoutno = outno + 1;
- rval = obj_starttraverseoutlet(t->tr_ob, &t->tr_outlet, outno);
- t->tr_outno = outno;
+ outno = t->tr_nextoutno;
+ while (outno == t->tr_nout)
+ {
+ t_gobj *y;
+ t_object *ob = 0;
+ if (!t->tr_ob) y = t->tr_x->gl_list;
+ else y = t->tr_ob->ob_g.g_next;
+ for (; y; y = y->g_next)
+ if (ob = pd_checkobject(&y->g_pd)) break;
+ if (!ob) return (0);
+ t->tr_ob = ob;
+ t->tr_nout = obj_noutlets(ob);
+ outno = 0;
+ if (glist_isvisible(t->tr_x))
+ gobj_getrect(y, t->tr_x,
+ &t->tr_x11, &t->tr_y11, &t->tr_x12, &t->tr_y12);
+ else t->tr_x11 = t->tr_y11 = t->tr_x12 = t->tr_y12 = 0;
+ }
+ t->tr_nextoutno = outno + 1;
+ rval = obj_starttraverseoutlet(t->tr_ob, &t->tr_outlet, outno);
+ t->tr_outno = outno;
}
t->tr_nextoc = obj_nexttraverseoutlet(rval, &t->tr_ob2,
- &t->tr_inlet, &t->tr_inno);
+ &t->tr_inlet, &t->tr_inno);
t->tr_nin = obj_ninlets(t->tr_ob2);
if (!t->tr_nin) bug("drawline");
if (glist_isvisible(t->tr_x))
{
- int inplus = (t->tr_nin == 1 ? 1 : t->tr_nin - 1);
- int outplus = (t->tr_nout == 1 ? 1 : t->tr_nout - 1);
- gobj_getrect(&t->tr_ob2->ob_g, t->tr_x,
- &t->tr_x21, &t->tr_y21, &t->tr_x22, &t->tr_y22);
- t->tr_lx1 = t->tr_x11 +
- ((t->tr_x12 - t->tr_x11 - IOWIDTH) * t->tr_outno) /
- outplus + IOMIDDLE;
- t->tr_ly1 = t->tr_y12;
- t->tr_lx2 = t->tr_x21 +
- ((t->tr_x22 - t->tr_x21 - IOWIDTH) * t->tr_inno)/inplus +
- IOMIDDLE;
- t->tr_ly2 = t->tr_y21;
+ int inplus = (t->tr_nin == 1 ? 1 : t->tr_nin - 1);
+ int outplus = (t->tr_nout == 1 ? 1 : t->tr_nout - 1);
+ gobj_getrect(&t->tr_ob2->ob_g, t->tr_x,
+ &t->tr_x21, &t->tr_y21, &t->tr_x22, &t->tr_y22);
+ t->tr_lx1 = t->tr_x11 +
+ ((t->tr_x12 - t->tr_x11 - IOWIDTH) * t->tr_outno) /
+ outplus + IOMIDDLE;
+ t->tr_ly1 = t->tr_y12;
+ t->tr_lx2 = t->tr_x21 +
+ ((t->tr_x22 - t->tr_x21 - IOWIDTH) * t->tr_inno)/inplus +
+ IOMIDDLE;
+ t->tr_ly2 = t->tr_y21;
}
else
{
- t->tr_x21 = t->tr_y21 = t->tr_x22 = t->tr_y22 = 0;
- t->tr_lx1 = t->tr_ly1 = t->tr_lx2 = t->tr_ly2 = 0;
+ t->tr_x21 = t->tr_y21 = t->tr_x22 = t->tr_y22 = 0;
+ t->tr_lx1 = t->tr_ly1 = t->tr_lx2 = t->tr_ly2 = 0;
}
return (rval);
@@ -339,7 +340,7 @@ int glist_valid = 10000;
void glist_init(t_glist *x)
{
- /* zero out everyone except "pd" field */
+ /* zero out everyone except "pd" field */
memset(((char *)x) + sizeof(x->gl_pd), 0, sizeof(*x) - sizeof(x->gl_pd));
x->gl_stub = gstub_new(x, 0);
x->gl_valid = ++glist_valid;
@@ -361,40 +362,40 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
glist_init(x);
x->gl_obj.te_type = T_OBJECT;
if (!owner)
- canvas_addtolist(x);
- /* post("canvas %x, owner %x", x, owner); */
+ canvas_addtolist(x);
+ /* post("canvas %lx, owner %lx", x, owner); */
if (argc == 5) /* toplevel: x, y, w, h, font */
{
- xloc = atom_getintarg(0, argc, argv);
- yloc = atom_getintarg(1, argc, argv);
- width = atom_getintarg(2, argc, argv);
- height = atom_getintarg(3, argc, argv);
- font = atom_getintarg(4, argc, argv);
+ xloc = atom_getintarg(0, argc, argv);
+ yloc = atom_getintarg(1, argc, argv);
+ width = atom_getintarg(2, argc, argv);
+ height = atom_getintarg(3, argc, argv);
+ font = atom_getintarg(4, argc, argv);
}
else if (argc == 6) /* subwindow: x, y, w, h, name, vis */
{
- xloc = atom_getintarg(0, argc, argv);
- yloc = atom_getintarg(1, argc, argv);
- width = atom_getintarg(2, argc, argv);
- height = atom_getintarg(3, argc, argv);
- s = atom_getsymbolarg(4, argc, argv);
- vis = atom_getintarg(5, argc, argv);
+ xloc = atom_getintarg(0, argc, argv);
+ yloc = atom_getintarg(1, argc, argv);
+ width = atom_getintarg(2, argc, argv);
+ height = atom_getintarg(3, argc, argv);
+ s = atom_getsymbolarg(4, argc, argv);
+ vis = atom_getintarg(5, argc, argv);
}
- /* (otherwise assume we're being created from the menu.) */
+ /* (otherwise assume we're being created from the menu.) */
if (canvas_newdirectory->s_name[0])
{
- static int dollarzero = 1000;
- t_canvasenvironment *env = x->gl_env =
- (t_canvasenvironment *)getbytes(sizeof(*x->gl_env));
- env->ce_dir = canvas_newdirectory;
- env->ce_argc = canvas_newargc;
- env->ce_argv = canvas_newargv;
- env->ce_dollarzero = dollarzero++;
- canvas_newdirectory = &s_;
- canvas_newargc = 0;
- canvas_newargv = 0;
+ static int dollarzero = 1000;
+ t_canvasenvironment *env = x->gl_env =
+ (t_canvasenvironment *)getbytes(sizeof(*x->gl_env));
+ env->ce_dir = canvas_newdirectory;
+ env->ce_argc = canvas_newargc;
+ env->ce_argv = canvas_newargv;
+ env->ce_dollarzero = dollarzero++;
+ canvas_newdirectory = &s_;
+ canvas_newargc = 0;
+ canvas_newargv = 0;
}
else x->gl_env = 0;
@@ -409,9 +410,9 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
canvas_setbounds(x, xloc, yloc, xloc + width, yloc + height);
x->gl_owner = owner;
x->gl_name = (*s->s_name ? s :
- (canvas_newfilename ? canvas_newfilename : gensym("Pd")));
+ (canvas_newfilename ? canvas_newfilename : gensym("Pd")));
if (strcmp(x->gl_name->s_name, "Pd"))
- pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
+ pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
x->gl_loading = 1;
x->gl_willvis = vis;
x->gl_edit = !strncmp(x->gl_name->s_name, "Untitled", 8);
@@ -448,33 +449,33 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
x->gl_obj.te_type = T_OBJECT;
if (!*sym->s_name)
{
- char buf[40];
- sprintf(buf, "graph%d", ++gcount);
- sym = gensym(buf);
- menu = 1;
+ char buf[40];
+ sprintf(buf, "graph%d", ++gcount);
+ sym = gensym(buf);
+ menu = 1;
}
else if (!strncmp((str = sym->s_name), "graph", 5)
- && (zz = atoi(str + 5)) > gcount)
- gcount = zz;
- /* in 0.34 and earlier, the pixel rectangle and the y bounds were
- reversed; this would behave the same, except that the dialog window
- would be confusing. The "correct" way is to have "py1" be the value
- that is higher on the screen. */
+ && (zz = atoi(str + 5)) > gcount)
+ gcount = zz;
+ /* in 0.34 and earlier, the pixel rectangle and the y bounds were
+ reversed; this would behave the same, except that the dialog window
+ would be confusing. The "correct" way is to have "py1" be the value
+ that is higher on the screen. */
if (py2 < py1)
{
- float zz;
- zz = y2;
- y2 = y1;
- y1 = zz;
- zz = py2;
- py2 = py1;
- py1 = zz;
+ float zz;
+ zz = y2;
+ y2 = y1;
+ y1 = zz;
+ zz = py2;
+ py2 = py1;
+ py1 = zz;
}
if (x1 == x2 || y1 == y2)
- x1 = 0, x2 = 100, y1 = 1, y2 = -1;
+ x1 = 0, x2 = 100, y1 = 1, y2 = -1;
if (px1 >= px2 || py1 >= py2)
- px1 = 100, py1 = 20, px2 = 100 + GLIST_DEFGRAPHWIDTH,
- py2 = 20 + GLIST_DEFGRAPHHEIGHT;
+ px1 = 100, py1 = 20, px2 = 100 + GLIST_DEFGRAPHWIDTH,
+ py2 = 20 + GLIST_DEFGRAPHHEIGHT;
x->gl_name = sym;
x->gl_x1 = x1;
x->gl_x2 = x2;
@@ -485,22 +486,22 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
x->gl_pixwidth = px2 - px1;
x->gl_pixheight = py2 - py1;
x->gl_font = (canvas_getcurrent() ?
- canvas_getcurrent()->gl_font : sys_defaultfont);
+ canvas_getcurrent()->gl_font : sys_defaultfont);
x->gl_screenx1 = x->gl_screeny1 = 0;
x->gl_screenx2 = 450;
x->gl_screeny2 = 300;
if (strcmp(x->gl_name->s_name, "Pd"))
- pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
+ pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
x->gl_owner = g;
x->gl_stretch = 1;
x->gl_isgraph = 1;
x->gl_obj.te_binbuf = binbuf_new();
binbuf_addv(x->gl_obj.te_binbuf, "s", gensym("graph"));
if (!menu)
- pd_pushsym(&x->gl_pd);
+ pd_pushsym(&x->gl_pd);
glist_add(g, &x->gl_gobj);
if (glist_isvisible(g))
- canvas_create_editor(x, 1);
+ canvas_create_editor(x, 1);
return (x);
}
@@ -532,6 +533,9 @@ static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2)
{
int heightwas = y2 - y1;
int heightchange = y2 - y1 - (x->gl_screeny2 - x->gl_screeny1);
+ if (x->gl_screenx1 == x1 && x->gl_screeny1 == y1 &&
+ x->gl_screenx2 == x2 && x->gl_screeny2 == y2)
+ return;
x->gl_screenx1 = x1;
x->gl_screeny1 = y1;
x->gl_screenx2 = x2;
@@ -539,20 +543,20 @@ static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2)
/* post("set bounds %d %d %d %d", x1, y1, x2, y2); */
if (!glist_isgraph(x) && (x->gl_y2 < x->gl_y1))
{
- /* if it's flipped so that y grows upward,
- fix so that zero is bottom edge and redraw. This is
- only appropriate if we're a regular "text" object on the
- parent. */
- float diff = x->gl_y1 - x->gl_y2;
- t_gobj *y;
- x->gl_y1 = heightwas * diff;
- x->gl_y2 = x->gl_y1 - diff;
- /* and move text objects accordingly; they should stick
- to the bottom, not the top. */
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_checkobject(&y->g_pd))
- gobj_displace(y, x, 0, heightchange);
- canvas_redraw(x);
+ /* if it's flipped so that y grows upward,
+ fix so that zero is bottom edge and redraw. This is
+ only appropriate if we're a regular "text" object on the
+ parent. */
+ float diff = x->gl_y1 - x->gl_y2;
+ t_gobj *y;
+ x->gl_y1 = heightwas * diff;
+ x->gl_y2 = x->gl_y1 - diff;
+ /* and move text objects accordingly; they should stick
+ to the bottom, not the top. */
+ for (y = x->gl_list; y; y = y->g_next)
+ if (pd_checkobject(&y->g_pd))
+ gobj_displace(y, x, 0, heightchange);
+ canvas_redraw(x);
}
}
@@ -570,23 +574,23 @@ void canvas_reflecttitle(t_canvas *x)
t_canvasenvironment *env = canvas_getenv(x);
if (env->ce_argc)
{
- int i;
- strcpy(namebuf, " (");
- for (i = 0; i < env->ce_argc; i++)
- {
- if (strlen(namebuf) > MAXPDSTRING/2 - 5)
- break;
- if (i != 0)
- strcat(namebuf, " ");
- atom_string(&env->ce_argv[i], namebuf + strlen(namebuf),
- MAXPDSTRING/2);
- }
- strcat(namebuf, ")");
+ int i;
+ strcpy(namebuf, " (");
+ for (i = 0; i < env->ce_argc; i++)
+ {
+ if (strlen(namebuf) > MAXPDSTRING/2 - 5)
+ break;
+ if (i != 0)
+ strcat(namebuf, " ");
+ atom_string(&env->ce_argv[i], namebuf + strlen(namebuf),
+ MAXPDSTRING/2);
+ }
+ strcat(namebuf, ")");
}
else namebuf[0] = 0;
- sys_vgui("wm title .x%x {%s%c%s - %s}\n",
- x, x->gl_name->s_name, (x->gl_dirty? '*' : ' '), namebuf,
- canvas_getdir(x)->s_name);
+ 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);
}
void canvas_dirty(t_canvas *x, t_int n)
@@ -594,8 +598,8 @@ void canvas_dirty(t_canvas *x, t_int n)
t_canvas *x2 = canvas_getrootfor(x);
if ((unsigned)n != x2->gl_dirty)
{
- x2->gl_dirty = n;
- canvas_reflecttitle(x2);
+ x2->gl_dirty = n;
+ canvas_reflecttitle(x2);
}
}
@@ -608,38 +612,36 @@ void canvas_map(t_canvas *x, t_floatarg f)
t_gobj *y;
if (flag)
{
- if (!glist_isvisible(x))
- {
- t_selection *sel;
- if (!x->gl_havewindow)
- {
- bug("canvas_map");
- canvas_vis(x, 1);
- }
- for (y = x->gl_list; y; y = y->g_next)
- gobj_vis(y, x, 1);
- 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);
- /* simulate a mouse up so u_main will calculate scrollbars...
- ugly! */
- sys_vgui("pdtk_canvas_mouseup .x%x.c 0 0 0\n", x);
- }
+ if (!glist_isvisible(x))
+ {
+ t_selection *sel;
+ if (!x->gl_havewindow)
+ {
+ bug("canvas_map");
+ canvas_vis(x, 1);
+ }
+ for (y = x->gl_list; y; y = y->g_next)
+ gobj_vis(y, x, 1);
+ 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);
+ sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x);
+ }
}
else
{
- if (glist_isvisible(x))
- {
- /* just clear out the whole canvas... */
- sys_vgui(".x%x.c delete all\n", x);
- /* alternatively, we could have erased them one by one...
- for (y = x->gl_list; y; y = y->g_next)
- gobj_vis(y, x, 0);
- ... but we should go through and erase the lines as well
- if we do it that way. */
- x->gl_mapped = 0;
- }
+ if (glist_isvisible(x))
+ {
+ /* just clear out the whole canvas... */
+ sys_vgui(".x%lx.c delete all\n", x);
+ /* alternatively, we could have erased them one by one...
+ for (y = x->gl_list; y; y = y->g_next)
+ gobj_vis(y, x, 0);
+ ... but we should go through and erase the lines as well
+ if we do it that way. */
+ x->gl_mapped = 0;
+ }
}
}
@@ -647,8 +649,8 @@ void canvas_redraw(t_canvas *x)
{
if (glist_isvisible(x))
{
- canvas_map(x, 0);
- canvas_map(x, 1);
+ canvas_map(x, 0);
+ canvas_map(x, 1);
}
}
@@ -661,7 +663,7 @@ static t_editor *editor_new(t_glist *owner)
x->e_connectbuf = binbuf_new();
x->e_deleted = binbuf_new();
x->e_glist = owner;
- sprintf(buf, ".x%x", (t_int)owner);
+ sprintf(buf, ".x%lx", (t_int)owner);
x->e_guiconnect = guiconnect_new(&owner->gl_pd, gensym(buf));
return (x);
}
@@ -683,33 +685,33 @@ void canvas_create_editor(t_glist *x, int createit)
t_object *ob;
if (createit)
{
- if (x->gl_editor)
- bug("canvas_create_editor");
- else
- {
- x->gl_editor = editor_new(x);
- for (y = x->gl_list; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd))
- rtext_new(x, ob);
- }
+ if (x->gl_editor)
+ bug("canvas_create_editor");
+ else
+ {
+ x->gl_editor = editor_new(x);
+ for (y = x->gl_list; y; y = y->g_next)
+ if (ob = pd_checkobject(&y->g_pd))
+ rtext_new(x, ob);
+ }
}
else
{
- if (!x->gl_editor)
- bug("canvas_create_editor");
- else
- {
- for (y = x->gl_list; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd))
- rtext_free(glist_findrtext(x, ob));
- editor_free(x->gl_editor, x);
- x->gl_editor = 0;
- }
+ if (!x->gl_editor)
+ bug("canvas_create_editor");
+ else
+ {
+ for (y = x->gl_list; y; y = y->g_next)
+ if (ob = pd_checkobject(&y->g_pd))
+ rtext_free(glist_findrtext(x, ob));
+ editor_free(x->gl_editor, x);
+ x->gl_editor = 0;
+ }
}
for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class &&
- ((t_canvas *)y)->gl_isgraph)
- canvas_create_editor((t_canvas *)y, createit);
+ if (pd_class(&y->g_pd) == canvas_class &&
+ ((t_canvas *)y)->gl_isgraph)
+ canvas_create_editor((t_canvas *)y, createit);
}
/* we call this when we want the window to become visible, mapped, and
@@ -721,68 +723,68 @@ void canvas_vis(t_canvas *x, t_floatarg f)
int flag = (f != 0);
if (flag)
{
- /* test if we're already visible and toplevel */
- if (glist_isvisible(x) && !x->gl_isgraph)
- { /* just put us in front */
+ /* test if we're already visible and toplevel */
+ if (glist_isvisible(x) && !x->gl_isgraph)
+ { /* just put us in front */
#ifdef MSW
- canvas_vis(x, 0);
- canvas_vis(x, 1);
+ canvas_vis(x, 0);
+ canvas_vis(x, 1);
#else
- sys_vgui("raise .x%x\n", x);
- sys_vgui("focus .x%x.c\n", x);
- sys_vgui("wm deiconify .x%x\n", x);
+ sys_vgui("raise .x%lx\n", x);
+ sys_vgui("focus .x%lx.c\n", x);
+ sys_vgui("wm deiconify .x%lx\n", x);
#endif
- }
- else
- {
- canvas_create_editor(x, 1);
- sys_vgui("pdtk_canvas_new .x%x %d %d +%d+%d %d\n", x,
- (int)(x->gl_screenx2 - x->gl_screenx1),
- (int)(x->gl_screeny2 - x->gl_screeny1),
- (int)(x->gl_screenx1), (int)(x->gl_screeny1),
- x->gl_edit);
- canvas_reflecttitle(x);
- x->gl_havewindow = 1;
- canvas_updatewindowlist();
- }
+ }
+ else
+ {
+ canvas_create_editor(x, 1);
+ sys_vgui("pdtk_canvas_new .x%lx %d %d +%d+%d %d\n", x,
+ (int)(x->gl_screenx2 - x->gl_screenx1),
+ (int)(x->gl_screeny2 - x->gl_screeny1),
+ (int)(x->gl_screenx1), (int)(x->gl_screeny1),
+ x->gl_edit);
+ canvas_reflecttitle(x);
+ x->gl_havewindow = 1;
+ canvas_updatewindowlist();
+ }
}
else /* make invisible */
{
- int i;
- t_canvas *x2;
- if (!x->gl_havewindow)
- {
- /* bug workaround -- a graph in a visible patch gets "invised"
- when the patch is closed, and must lose the editor here. It's
- probably not the natural place to do this. Other cases like
- subpatches fall here too but don'd need the editor freed, so
- we check if it exists. */
- if (x->gl_editor)
- canvas_create_editor(x, 0);
- return;
- }
- glist_noselect(x);
- if (glist_isvisible(x))
- canvas_map(x, 0);
- canvas_create_editor(x, 0);
- sys_vgui("destroy .x%x\n", x);
- for (i = 1, x2 = x; x2; x2 = x2->gl_next, i++)
- ;
- sys_vgui(".mbar.find delete %d\n", i);
- /* if we're a graph on our parent, and if the parent exists
- and is visible, show ourselves on parent. */
- if (glist_isgraph(x) && x->gl_owner)
- {
- t_glist *gl2 = x->gl_owner;
- canvas_create_editor(x, 1);
- if (glist_isvisible(gl2))
- gobj_vis(&x->gl_gobj, gl2, 0);
- x->gl_havewindow = 0;
- if (glist_isvisible(gl2))
- gobj_vis(&x->gl_gobj, gl2, 1);
- }
- else x->gl_havewindow = 0;
- canvas_updatewindowlist();
+ int i;
+ t_canvas *x2;
+ if (!x->gl_havewindow)
+ {
+ /* bug workaround -- a graph in a visible patch gets "invised"
+ when the patch is closed, and must lose the editor here. It's
+ probably not the natural place to do this. Other cases like
+ subpatches fall here too but don'd need the editor freed, so
+ we check if it exists. */
+ if (x->gl_editor)
+ canvas_create_editor(x, 0);
+ return;
+ }
+ glist_noselect(x);
+ if (glist_isvisible(x))
+ canvas_map(x, 0);
+ canvas_create_editor(x, 0);
+ sys_vgui("destroy .x%lx\n", x);
+ for (i = 1, x2 = x; x2; x2 = x2->gl_next, i++)
+ ;
+ sys_vgui(".mbar.find delete %d\n", i);
+ /* if we're a graph on our parent, and if the parent exists
+ and is visible, show ourselves on parent. */
+ if (glist_isgraph(x) && x->gl_owner)
+ {
+ t_glist *gl2 = x->gl_owner;
+ canvas_create_editor(x, 1);
+ if (glist_isvisible(gl2))
+ gobj_vis(&x->gl_gobj, gl2, 0);
+ x->gl_havewindow = 0;
+ if (glist_isvisible(gl2))
+ gobj_vis(&x->gl_gobj, gl2, 1);
+ }
+ else x->gl_havewindow = 0;
+ canvas_updatewindowlist();
}
}
@@ -792,19 +794,19 @@ void glist_menu_open(t_glist *x)
{
if (glist_isvisible(x) && !glist_istoplevel(x))
{
- t_glist *gl2 = x->gl_owner;
- if (!gl2)
- bug("canvas_vis"); /* shouldn't happen but don't get too upset. */
- else
- {
- /* erase ourself in parent window */
- gobj_vis(&x->gl_gobj, gl2, 0);
- /* get rid of our editor (and subeditors) */
- canvas_create_editor(x, 0);
- x->gl_havewindow = 1;
- /* redraw ourself in parent window (blanked out this time) */
- gobj_vis(&x->gl_gobj, gl2, 1);
- }
+ t_glist *gl2 = x->gl_owner;
+ if (!gl2)
+ bug("canvas_vis"); /* shouldn't happen but don't get too upset. */
+ else
+ {
+ /* erase ourself in parent window */
+ gobj_vis(&x->gl_gobj, gl2, 0);
+ /* get rid of our editor (and subeditors) */
+ canvas_create_editor(x, 0);
+ x->gl_havewindow = 1;
+ /* redraw ourself in parent window (blanked out this time) */
+ gobj_vis(&x->gl_gobj, gl2, 1);
+ }
}
canvas_vis(x, 1);
}
@@ -816,9 +818,9 @@ int glist_isvisible(t_glist *x)
int glist_istoplevel(t_glist *x)
{
- /* we consider a graph "toplevel" if it has its own window
- or if it appears as a box in its parent window so that we
- don't draw the actual contents there. */
+ /* we consider a graph "toplevel" if it has its own window
+ or if it appears as a box in its parent window so that we
+ don't draw the actual contents there. */
return (x->gl_havewindow || !x->gl_isgraph);
}
@@ -833,26 +835,26 @@ void canvas_free(t_canvas *x)
int dspstate = canvas_suspend_dsp();
canvas_noundo(x);
if (canvas_editing == x)
- canvas_editing = 0;
+ canvas_editing = 0;
if (canvas_whichfind == x)
- canvas_whichfind = 0;
+ canvas_whichfind = 0;
glist_noselect(x);
while (y = x->gl_list)
- glist_delete(x, y);
+ glist_delete(x, y);
canvas_vis(x, 0);
if (strcmp(x->gl_name->s_name, "Pd"))
- pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
+ pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
if (x->gl_env)
{
- freebytes(x->gl_env->ce_argv, x->gl_env->ce_argc * sizeof(t_atom));
- freebytes(x->gl_env, sizeof(*x->gl_env));
+ freebytes(x->gl_env->ce_argv, x->gl_env->ce_argc * sizeof(t_atom));
+ freebytes(x->gl_env, sizeof(*x->gl_env));
}
canvas_resume_dsp(dspstate);
glist_cleanup(x);
- gfxstub_deleteforkey(x); /* probably unnecessary */
+ gfxstub_deleteforkey(x); /* probably unnecessary */
if (!x->gl_owner)
- canvas_takeofflist(x);
+ canvas_takeofflist(x);
}
/* ----------------- lines ---------- */
@@ -862,13 +864,13 @@ static void canvas_drawlines(t_canvas *x)
t_linetraverser t;
t_outconnect *oc;
{
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
- glist_getcanvas(x),
- t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2,
- (outlet_getsymbol(t.tr_outlet) == &s_signal ? 2:1),
- oc);
+ linetraverser_start(&t, x);
+ while (oc = linetraverser_next(&t))
+ sys_vgui(".x%lx.c create line %d %d %d %d -width %d -tags l%lx\n",
+ glist_getcanvas(x),
+ t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2,
+ (outlet_getsymbol(t.tr_outlet) == &s_signal ? 2:1),
+ oc);
}
}
@@ -880,12 +882,12 @@ void canvas_fixlinesfor(t_canvas *x, t_text *text)
linetraverser_start(&t, x);
while (oc = linetraverser_next(&t))
{
- if (t.tr_ob == text || t.tr_ob2 == text)
- {
- sys_vgui(".x%x.c coords l%x %d %d %d %d\n",
- glist_getcanvas(x), oc,
- t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
- }
+ if (t.tr_ob == text || t.tr_ob2 == 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);
+ }
}
}
@@ -897,15 +899,15 @@ void canvas_deletelinesfor(t_canvas *x, t_text *text)
linetraverser_start(&t, x);
while (oc = linetraverser_next(&t))
{
- if (t.tr_ob == text || t.tr_ob2 == text)
- {
- if (x->gl_editor)
- {
- sys_vgui(".x%x.c delete l%x\n",
- glist_getcanvas(x), oc);
- }
- obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
- }
+ if (t.tr_ob == text || t.tr_ob2 == text)
+ {
+ if (x->gl_editor)
+ {
+ sys_vgui(".x%lx.c delete l%lx\n",
+ glist_getcanvas(x), oc);
+ }
+ obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
+ }
}
}
@@ -918,23 +920,23 @@ void canvas_deletelinesforio(t_canvas *x, t_text *text,
linetraverser_start(&t, x);
while (oc = linetraverser_next(&t))
{
- if ((t.tr_ob == text && t.tr_outlet == outp) ||
- (t.tr_ob2 == text && t.tr_inlet == inp))
- {
- if (x->gl_editor)
- {
- sys_vgui(".x%x.c delete l%x\n",
- glist_getcanvas(x), oc);
- }
- obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
- }
+ if ((t.tr_ob == text && t.tr_outlet == outp) ||
+ (t.tr_ob2 == text && t.tr_inlet == inp))
+ {
+ if (x->gl_editor)
+ {
+ sys_vgui(".x%lx.c delete l%lx\n",
+ glist_getcanvas(x), oc);
+ }
+ obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
+ }
}
}
static void canvas_pop(t_canvas *x, t_floatarg fvis)
{
if (fvis != 0)
- canvas_vis(x, 1);
+ canvas_vis(x, 1);
pd_popsym(&x->gl_pd);
canvas_resortinlets(x);
canvas_resortoutlets(x);
@@ -947,35 +949,35 @@ 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)
{ /* IOhannes */
t_pd *z;
- /* this should be unnecessary, but sometimes the canvas's name gets
- out of sync with the owning box's argument; this fixes that */
+ /* this should be unnecessary, but sometimes the canvas's name gets
+ out of sync with the owning box's argument; this fixes that */
if (argc > 3)
{
- t_atom *ap=argv+3;
- if (ap->a_type == A_SYMBOL)
- {
- char *buf=ap->a_w.w_symbol->s_name, *bufp;
- if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9')
- {
- for (bufp = buf+2; *bufp; bufp++)
- if (*bufp < '0' || *bufp > '9')
- {
- SETDOLLSYM(ap, gensym(buf+1));
- goto didit;
- }
- SETDOLLAR(ap, atoi(buf+1));
- didit: ;
- }
- }
-
- if (ap->a_type == A_DOLLSYM)
- {
- t_canvasenvironment *e = canvas_getenv(canvas_getcurrent());
- canvas_rename(x, binbuf_realizedollsym(ap->a_w.w_symbol,
- e->ce_argc, e->ce_argv, 1), 0);
- }
- else if (ap->a_type == A_SYMBOL)
- canvas_rename(x, argv[3].a_w.w_symbol, 0);
+ t_atom *ap=argv+3;
+ if (ap->a_type == A_SYMBOL)
+ {
+ char *buf=ap->a_w.w_symbol->s_name, *bufp;
+ if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9')
+ {
+ for (bufp = buf+2; *bufp; bufp++)
+ if (*bufp < '0' || *bufp > '9')
+ {
+ SETDOLLSYM(ap, gensym(buf+1));
+ goto didit;
+ }
+ SETDOLLAR(ap, atoi(buf+1));
+ didit: ;
+ }
+ }
+
+ if (ap->a_type == A_DOLLSYM)
+ {
+ t_canvasenvironment *e = canvas_getenv(canvas_getcurrent());
+ canvas_rename(x, binbuf_realizedollsym(ap->a_w.w_symbol,
+ e->ce_argc, e->ce_argv, 1), 0);
+ }
+ else if (ap->a_type == A_SYMBOL)
+ canvas_rename(x, argv[3].a_w.w_symbol, 0);
}
canvas_pop(x, x->gl_willvis);
@@ -983,9 +985,9 @@ void canvas_restore(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
else if (*z != canvas_class) error("canvas_restore: wasn't a canvas");
else
{
- t_canvas *x2 = (t_canvas *)z;
- x->gl_owner = x2;
- canvas_objfor(x2, &x->gl_obj, argc, argv);
+ t_canvas *x2 = (t_canvas *)z;
+ x->gl_owner = x2;
+ canvas_objfor(x2, &x->gl_obj, argc, argv);
}
}
@@ -994,12 +996,12 @@ static void canvas_loadbangabstractions(t_canvas *x)
t_gobj *y;
t_symbol *s = gensym("loadbang");
for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class)
+ if (pd_class(&y->g_pd) == canvas_class)
{
- if (canvas_isabstraction((t_canvas *)y))
- canvas_loadbang((t_canvas *)y);
- else
- canvas_loadbangabstractions((t_canvas *)y);
+ if (canvas_isabstraction((t_canvas *)y))
+ canvas_loadbang((t_canvas *)y);
+ else
+ canvas_loadbangabstractions((t_canvas *)y);
}
}
@@ -1008,15 +1010,15 @@ void canvas_loadbangsubpatches(t_canvas *x)
t_gobj *y;
t_symbol *s = gensym("loadbang");
for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class)
+ if (pd_class(&y->g_pd) == canvas_class)
{
- if (!canvas_isabstraction((t_canvas *)y))
- canvas_loadbangsubpatches((t_canvas *)y);
+ if (!canvas_isabstraction((t_canvas *)y))
+ canvas_loadbangsubpatches((t_canvas *)y);
}
for (y = x->gl_list; y; y = y->g_next)
- if ((pd_class(&y->g_pd) != canvas_class) &&
- zgetfn(&y->g_pd, s))
- pd_vmess(&y->g_pd, s, "");
+ if ((pd_class(&y->g_pd) != canvas_class) &&
+ zgetfn(&y->g_pd, s))
+ pd_vmess(&y->g_pd, s, "");
}
void canvas_loadbang(t_canvas *x)
@@ -1044,14 +1046,14 @@ static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom,
{
int cxpix, cypix, cw, ch, txpix, typix, tw, th;
if (sscanf(canvasgeom->s_name, "%dx%d+%d+%d", &cw, &ch, &cxpix, &cypix)
- < 4 ||
- sscanf(topgeom->s_name, "%dx%d+%d+%d", &tw, &th, &txpix, &typix) < 4)
- bug("canvas_relocate");
- /* for some reason this is initially called with cw=ch=1 so
- we just suppress that here. */
+ < 4 ||
+ sscanf(topgeom->s_name, "%dx%d+%d+%d", &tw, &th, &txpix, &typix) < 4)
+ bug("canvas_relocate");
+ /* for some reason this is initially called with cw=ch=1 so
+ we just suppress that here. */
if (cw > 5 && ch > 5)
- canvas_setbounds(x, txpix, typix,
- txpix + cw - HORIZBORDER, typix + ch - VERTBORDER);
+ canvas_setbounds(x, txpix, typix,
+ txpix + cw - HORIZBORDER, typix + ch - VERTBORDER);
}
void canvas_popabstraction(t_canvas *x)
@@ -1068,7 +1070,7 @@ void canvas_logerror(t_object *y)
#ifdef LATER
canvas_vis(x, 1);
if (!glist_isselected(x, &y->ob_g))
- glist_select(x, &y->ob_g);
+ glist_select(x, &y->ob_g);
#endif
}
@@ -1093,7 +1095,7 @@ static void *subcanvas_new(t_symbol *s)
static void canvas_click(t_canvas *x,
t_floatarg xpos, t_floatarg ypos,
- t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{
canvas_vis(x, 1);
}
@@ -1111,7 +1113,7 @@ void canvas_fattensub(t_canvas *x,
static void canvas_rename_method(t_canvas *x, t_symbol *s, int ac, t_atom *av)
{
if (ac && av->a_type == A_SYMBOL)
- canvas_rename(x, av->a_w.w_symbol, 0);
+ canvas_rename(x, av->a_w.w_symbol, 0);
else canvas_rename(x, gensym("Pd"), 0);
}
@@ -1126,13 +1128,13 @@ static void *table_new(t_symbol *s, t_floatarg f)
t_canvas *x, *z = canvas_getcurrent();
if (s == &s_)
{
- char tabname[255];
- t_symbol *t = gensym("table");
- sprintf(tabname, "%s%d", t->s_name, tabcount++);
- s = gensym(tabname);
+ char tabname[255];
+ t_symbol *t = gensym("table");
+ sprintf(tabname, "%s%d", t->s_name, tabcount++);
+ s = gensym(tabname);
}
if (f <= 1)
- f = 100;
+ f = 100;
SETFLOAT(a, 0);
SETFLOAT(a+1, GLIST_DEFCANVASYLOC);
SETFLOAT(a+2, 600);
@@ -1143,9 +1145,9 @@ static void *table_new(t_symbol *s, t_floatarg f)
x->gl_owner = z;
- /* create a graph for the table */
+ /* create a graph for the table */
gl = glist_addglist((t_glist*)x, &s_, 0, -1, (f > 1 ? f-1 : 1), 1,
- 50, 350, 550, 50);
+ 50, 350, 550, 50);
graph_array(gl, s, &s_float, f, 0);
@@ -1167,7 +1169,7 @@ int canvas_istable(t_canvas *x)
t_atom *argv = (x->gl_obj.te_binbuf? binbuf_getvec(x->gl_obj.te_binbuf):0);
int argc = (x->gl_obj.te_binbuf? binbuf_getnatom(x->gl_obj.te_binbuf) : 0);
int istable = (argc && argv[0].a_type == A_SYMBOL &&
- argv[0].a_w.w_symbol == gensym("table"));
+ argv[0].a_w.w_symbol == gensym("table"));
return (istable);
}
@@ -1178,7 +1180,7 @@ int canvas_showtext(t_canvas *x)
t_atom *argv = (x->gl_obj.te_binbuf? binbuf_getvec(x->gl_obj.te_binbuf):0);
int argc = (x->gl_obj.te_binbuf? binbuf_getnatom(x->gl_obj.te_binbuf) : 0);
int isarray = (argc && argv[0].a_type == A_SYMBOL &&
- argv[0].a_w.w_symbol == gensym("graph"));
+ argv[0].a_w.w_symbol == gensym("graph"));
return (!isarray);
}
@@ -1192,7 +1194,7 @@ static void canvas_dsp(t_canvas *x, t_signal **sp)
t_canvas *canvas_getrootfor(t_canvas *x)
{
if ((!x->gl_owner) || canvas_isabstraction(x))
- return (x);
+ return (x);
else return (canvas_getrootfor(x->gl_owner));
}
@@ -1224,26 +1226,26 @@ static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp)
t_symbol *dspsym = gensym("dsp");
t_dspcontext *dc;
- /* create a new "DSP graph" object to use in sorting this canvas.
- If we aren't toplevel, there are already other dspcontexts around. */
+ /* create a new "DSP graph" object to use in sorting this canvas.
+ If we aren't toplevel, there are already other dspcontexts around. */
dc = ugen_start_graph(toplevel, sp,
- obj_nsiginlets(&x->gl_obj),
- obj_nsigoutlets(&x->gl_obj));
+ obj_nsiginlets(&x->gl_obj),
+ obj_nsigoutlets(&x->gl_obj));
- /* find all the "dsp" boxes and add them to the graph */
+ /* find all the "dsp" boxes and add them to the graph */
for (y = x->gl_list; y; y = y->g_next)
- if ((ob = pd_checkobject(&y->g_pd)) && zgetfn(&y->g_pd, dspsym))
- ugen_add(dc, ob);
+ if ((ob = pd_checkobject(&y->g_pd)) && zgetfn(&y->g_pd, dspsym))
+ ugen_add(dc, ob);
- /* ... and all dsp interconnections */
+ /* ... and all dsp interconnections */
linetraverser_start(&t, x);
while (oc = linetraverser_next(&t))
- if (obj_issignaloutlet(t.tr_ob, t.tr_outno))
- ugen_connect(dc, t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
+ if (obj_issignaloutlet(t.tr_ob, t.tr_outno))
+ ugen_connect(dc, t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
- /* finally, sort them and add them to the DSP chain */
+ /* finally, sort them and add them to the DSP chain */
ugen_done_graph(dc);
}
@@ -1256,7 +1258,7 @@ static void canvas_start_dsp(void)
ugen_start();
for (x = canvas_list; x; x = x->gl_next)
- canvas_dodsp(x, 1, 0);
+ canvas_dodsp(x, 1, 0);
canvas_dspstate = 1;
}
@@ -1265,9 +1267,9 @@ static void canvas_stop_dsp(void)
{
if (canvas_dspstate)
{
- ugen_stop();
- sys_gui("pdtk_pd_dsp OFF\n");
- canvas_dspstate = 0;
+ ugen_stop();
+ sys_gui("pdtk_pd_dsp OFF\n");
+ canvas_dspstate = 0;
}
}
@@ -1299,17 +1301,17 @@ void glob_dsp(void *dummy, t_symbol *s, int argc, t_atom *argv)
int newstate;
if (argc)
{
- newstate = atom_getintarg(0, argc, argv);
- if (newstate && !canvas_dspstate)
- {
- sys_set_audio_state(1);
- canvas_start_dsp();
- }
- else if (!newstate && canvas_dspstate)
- {
- canvas_stop_dsp();
- sys_set_audio_state(0);
- }
+ newstate = atom_getintarg(0, argc, argv);
+ if (newstate && !canvas_dspstate)
+ {
+ sys_set_audio_state(1);
+ canvas_start_dsp();
+ }
+ else if (!newstate && canvas_dspstate)
+ {
+ canvas_stop_dsp();
+ sys_set_audio_state(0);
+ }
}
else post("dsp state %d", canvas_dspstate);
}
@@ -1319,8 +1321,8 @@ void glist_redrawitem(t_glist *owner, t_gobj *gobj)
{
if (glist_isvisible(owner))
{
- gobj_vis(gobj, owner, 0);
- gobj_vis(gobj, owner, 1);
+ gobj_vis(gobj, owner, 0);
+ gobj_vis(gobj, owner, 1);
}
}
@@ -1333,11 +1335,11 @@ static void glist_redrawall(t_glist *gl)
int vis = glist_isvisible(gl);
for (g = gl->gl_list; g; g = g->g_next)
{
- t_class *cl;
- if (vis && g->g_pd == scalar_class)
- glist_redrawitem(gl, g);
- else if (g->g_pd == canvas_class)
- glist_redrawall((t_glist *)g);
+ t_class *cl;
+ if (vis && g->g_pd == scalar_class)
+ glist_redrawitem(gl, g);
+ else if (g->g_pd == canvas_class)
+ glist_redrawall((t_glist *)g);
}
}
@@ -1345,9 +1347,9 @@ static void glist_redrawall(t_glist *gl)
void canvas_redrawallfortemplate(t_canvas *templatecanvas)
{
t_canvas *x;
- /* find all root canvases */
+ /* find all root canvases */
for (x = canvas_list; x; x = x->gl_next)
- glist_redrawall(x);
+ glist_redrawall(x);
}
/* ------------------------------- setup routine ------------------------ */
@@ -1381,39 +1383,39 @@ extern void graph_properties(t_gobj *z, t_glist *owner);
void g_canvas_setup(void)
{
- /* we prevent the user from typing "canvas" in an object box
- by sending 0 for a creator function. */
+ /* we prevent the user from typing "canvas" in an object box
+ by sending 0 for a creator function. */
canvas_class = class_new(gensym("canvas"), 0,
- (t_method)canvas_free, sizeof(t_canvas), CLASS_NOINLET, 0);
- /* here is the real creator function, invoked in patch files
- by sending the "canvas" message to #N, which is bound
- to pd_camvasmaker. */
+ (t_method)canvas_free, sizeof(t_canvas), CLASS_NOINLET, 0);
+ /* here is the real creator function, invoked in patch files
+ by sending the "canvas" message to #N, which is bound
+ to pd_camvasmaker. */
class_addmethod(pd_canvasmaker, (t_method)canvas_new, gensym("canvas"),
- A_GIMME, 0);
+ A_GIMME, 0);
class_addmethod(canvas_class, (t_method)canvas_restore,
- gensym("restore"), A_GIMME, 0);
+ gensym("restore"), A_GIMME, 0);
class_addmethod(canvas_class, (t_method)canvas_coords,
- gensym("coords"), A_GIMME, 0);
+ gensym("coords"), A_GIMME, 0);
/* -------------------------- objects ----------------------------- */
class_addmethod(canvas_class, (t_method)canvas_obj,
- gensym("obj"), A_GIMME, A_NULL);
+ gensym("obj"), A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_msg,
- gensym("msg"), A_GIMME, A_NULL);
+ gensym("msg"), A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_floatatom,
- gensym("floatatom"), A_GIMME, A_NULL);
+ gensym("floatatom"), A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_symbolatom,
- gensym("symbolatom"), A_GIMME, A_NULL);
+ gensym("symbolatom"), A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)glist_text,
- gensym("text"), A_GIMME, A_NULL);
+ gensym("text"), A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)glist_glist, gensym("graph"),
- A_GIMME, A_NULL);
+ A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)glist_scalar,
- gensym("scalar"), A_GIMME, A_NULL);
+ gensym("scalar"), A_GIMME, A_NULL);
/* -------------- Thomas Musil's GUI objects ------------ */
class_addmethod(canvas_class, (t_method)canvas_bng, gensym("bng"),
- A_GIMME, A_NULL);
+ A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_toggle, gensym("toggle"),
A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_vslider, gensym("vslider"),
@@ -1421,7 +1423,7 @@ void g_canvas_setup(void)
class_addmethod(canvas_class, (t_method)canvas_hslider, gensym("hslider"),
A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_hdial, gensym("hdial"),
- A_GIMME, A_NULL);
+ A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_vdial, gensym("vdial"),
A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_hradio, gensym("hradio"),
@@ -1431,43 +1433,43 @@ void g_canvas_setup(void)
class_addmethod(canvas_class, (t_method)canvas_vumeter, gensym("vumeter"),
A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_mycnv, gensym("mycnv"),
- A_GIMME, A_NULL);
+ A_GIMME, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_numbox, gensym("numbox"),
A_GIMME, A_NULL);
/* ------------------------ gui stuff --------------------------- */
class_addmethod(canvas_class, (t_method)canvas_pop, gensym("pop"),
- A_DEFFLOAT, A_NULL);
+ A_DEFFLOAT, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_loadbang,
- gensym("loadbang"), A_NULL);
+ gensym("loadbang"), A_NULL);
class_addmethod(canvas_class, (t_method)canvas_relocate,
- gensym("relocate"), A_SYMBOL, A_SYMBOL, A_NULL);
+ gensym("relocate"), A_SYMBOL, A_SYMBOL, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_vis,
- gensym("vis"), A_FLOAT, A_NULL);
+ gensym("vis"), A_FLOAT, A_NULL);
class_addmethod(canvas_class, (t_method)glist_menu_open,
- gensym("menu-open"), A_NULL);
+ gensym("menu-open"), A_NULL);
class_addmethod(canvas_class, (t_method)canvas_map,
- gensym("map"), A_FLOAT, A_NULL);
+ gensym("map"), A_FLOAT, A_NULL);
class_setpropertiesfn(canvas_class, graph_properties);
/* ---------------------- list handling ------------------------ */
class_addmethod(canvas_class, (t_method)glist_clear, gensym("clear"),
- A_NULL);
+ A_NULL);
/* ----- subcanvases, which you get by typing "pd" in a box ---- */
class_addcreator((t_newmethod)subcanvas_new, gensym("pd"), A_DEFSYMBOL, 0);
class_addcreator((t_newmethod)subcanvas_new, gensym("page"), A_DEFSYMBOL, 0);
class_addmethod(canvas_class, (t_method)canvas_click,
- gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(canvas_class, (t_method)canvas_dsp, gensym("dsp"), 0);
class_addmethod(canvas_class, (t_method)canvas_rename_method,
- gensym("rename"), A_GIMME, 0);
+ gensym("rename"), A_GIMME, 0);
/*---------------------------- tables -- GG ------------------- */
class_addcreator((t_newmethod)table_new, gensym("table"),
- A_DEFSYM, A_DEFFLOAT, 0);
+ A_DEFSYM, A_DEFFLOAT, 0);
/* -------------- setups from other files for canvas_class ---------------- */
g_graph_setup();