Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31410
Modified Files:
Tag: desiredata
desire.c
Log Message:
0.40: rest of the "data structures" stuff ([struct])
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.49
retrieving revision 1.1.2.217.2.50
diff -C2 -d -r1.1.2.217.2.49 -r1.1.2.217.2.50
*** desire.c 8 Dec 2006 17:03:18 -0000 1.1.2.217.2.49
--- desire.c 8 Dec 2006 20:41:29 -0000 1.1.2.217.2.50
***************
*** 1226,1233 ****
if (!flag && x->isgraph) {
x->isgraph = 0;
! } else if (flag && !x->isgraph) {
if (x->pixwidth <= 0) x->pixwidth = CANVAS_DEFGRAPHWIDTH;
if (x->pixheight <= 0) x->pixheight = CANVAS_DEFGRAPHHEIGHT;
SET(isgraph,1);
if (!nogoprect && !x->goprect) {
canvas_each(g,x) if (pd_checkobject(g)) {SET(goprect,1); break;}
--- 1226,1234 ----
if (!flag && x->isgraph) {
x->isgraph = 0;
! } else if (flag) {
if (x->pixwidth <= 0) x->pixwidth = CANVAS_DEFGRAPHWIDTH;
if (x->pixheight <= 0) x->pixheight = CANVAS_DEFGRAPHHEIGHT;
SET(isgraph,1);
+ SET(hidetext,!!(flag&2));
if (!nogoprect && !x->goprect) {
canvas_each(g,x) if (pd_checkobject(g)) {SET(goprect,1); break;}
***************
*** 1242,1246 ****
float xperpix, yperpix, x1, y1, x2, y2, xpix, ypix, xmargin, ymargin;
int graphme;
! pd_scanargs(argc,argv,"ffbffffffff",&xperpix,&yperpix,&graphme,
&x1,&y1,&x2,&y2,&xpix,&ypix,&xmargin,&ymargin);
SET(pixwidth,(int)xpix); SET(pixheight,(int)ypix);
--- 1243,1247 ----
float xperpix, yperpix, x1, y1, x2, y2, xpix, ypix, xmargin, ymargin;
int graphme;
! pd_scanargs(argc,argv,"ffiffffffff",&xperpix,&yperpix,&graphme,
&x1,&y1,&x2,&y2,&xpix,&ypix,&xmargin,&ymargin);
SET(pixwidth,(int)xpix); SET(pixheight,(int)ypix);
***************
*** 3722,3725 ****
--- 3723,3727 ----
static void gpointer_setcanvas(t_gpointer *gp, t_canvas *canvas, t_scalar *x);
+ static void gpointer_setarray(t_gpointer *gp, t_array *array, t_word *w);
/* make a new scalar and add to the canvas. We create a "gp" here which
***************
*** 3901,3905 ****
t_canvas *owner;
t_symbol *sym;
! t_gtemplate *x_next;
int argc;
t_atom *argv;
--- 3903,3907 ----
t_canvas *owner;
t_symbol *sym;
! t_gtemplate *next;
int argc;
t_atom *argv;
***************
*** 3953,3957 ****
} else {
pd_error(x, "%s: no such type", newtypesym->s_name);
! return 0;
}
newn = (oldn = x->n) + 1;
--- 3955,3959 ----
} else {
pd_error(x, "%s: no such type", newtypesym->s_name);
! goto bad;
}
newn = (oldn = x->n) + 1;
***************
*** 4227,4231 ****
template_conform(x, y);
pd_free(x);
! template_new(templatesym, argc, argv);
}
}
--- 4229,4234 ----
template_conform(x, y);
pd_free(x);
! t_template *y2 = template_new(templatesym, argc, argv);
! y2->t_list = 0;
}
}
***************
*** 4239,4242 ****
--- 4242,4246 ----
if (*x->sym->s_name) pd_unbind(x,x->sym);
t_freebytes(x->vec, x->n * sizeof(*x->vec));
+
}
***************
*** 4253,4257 ****
t_template *t = template_findbyname(sym);
x->owner = canvas_getcurrent();
! x->x_next = 0;
x->sym = sym;
x->argc = argc;
--- 4257,4261 ----
t_template *t = template_findbyname(sym);
x->owner = canvas_getcurrent();
! x->next = 0;
x->sym = sym;
x->argc = argc;
***************
*** 4266,4271 ****
if (t->t_list) {
t_gtemplate *x2, *x3;
! for (x2 = x->t->t_list; (x3 = x2->x_next); x2 = x3) {}
! x2->x_next = x;
post("template %s: warning: already exists.", sym->s_name);
} else {
--- 4270,4275 ----
if (t->t_list) {
t_gtemplate *x2, *x3;
! for (x2 = x->t->t_list; (x3 = x2->next); x2 = x3) {}
! x2->next = x;
post("template %s: warning: already exists.", sym->s_name);
} else {
***************
*** 4317,4335 ****
if (x == t->t_list) {
canvas_redrawallfortemplate(t, 2);
! if (x->x_next) {
/* if we were first on the list, and there are others on
the list, make a new template corresponding to the new
! first-on-list and replace teh existing template with it. */
! t_template *z = template_new(&s_, x->argc, x->argv);
template_conform(t, z);
pd_free(t);
pd_free(z);
! z = template_new(x->sym, x->argc, x->argv);
! z->t_list = x->x_next;
} else t->t_list = 0;
canvas_redrawallfortemplate(t, 1);
} else {
t_gtemplate *x2, *x3;
! for (x2=t->t_list; (x3=x2->x_next); x2=x3) if (x==x3) {x2->x_next=x3->x_next; break;}
}
freebytes(x->argv, sizeof(t_atom) * x->argc);
--- 4321,4340 ----
if (x == t->t_list) {
canvas_redrawallfortemplate(t, 2);
! if (x->next) {
/* if we were first on the list, and there are others on
the list, make a new template corresponding to the new
! first-on-list and replace the existing template with it. */
! t_template *z = template_new(&s_, x->next->argc, x->next->argv);
template_conform(t, z);
pd_free(t);
pd_free(z);
! z = template_new(x->sym, x->next->argc, x->next->argv);
! z->t_list = x->next;
! for (t_gtemplate *y=z->t_list; y ; y=y->next) y->t=z;
} else t->t_list = 0;
canvas_redrawallfortemplate(t, 1);
} else {
t_gtemplate *x2, *x3;
! for (x2=t->t_list; (x3=x2->next); x2=x3) if (x==x3) {x2->next=x3->next; break;}
}
freebytes(x->argv, sizeof(t_atom) * x->argc);
***************
*** 4398,4401 ****
--- 4403,4407 ----
#define CLOSED 1
#define BEZ 2
+ #define NOMOUSE 4
#define A_ARRAY 55 /* LATER decide whether to enshrine this in m_pd.h */
***************
*** 4486,4490 ****
/* includes polygons too */
struct t_curve : t_object {
! int flags; /* CLOSED and/or BEZ */
t_slot fillcolor, outlinecolor, width, vis;
int npoints;
--- 4492,4496 ----
/* includes polygons too */
struct t_curve : t_object {
! int flags; /* CLOSED and/or BEZ and/or NOMOUSE */
t_slot fillcolor, outlinecolor, width, vis;
int npoints;
***************
*** 4504,4510 ****
flags |= CLOSED;
} else classname += 4;
- if (classname[0] == 'c') flags |= BEZ;
- x->flags = flags;
slot_setfloat_const(&x->vis, 1);
while (1) {
t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
--- 4510,4515 ----
flags |= CLOSED;
} else classname += 4;
slot_setfloat_const(&x->vis, 1);
+ if (classname[0] == 'c') flags |= BEZ;
while (1) {
t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
***************
*** 4512,4517 ****
--- 4517,4527 ----
slot_setfloatarg(&x->vis, 1, argv+1);
argc -= 2; argv += 2;
+ } else
+ if (!strcmp(firstarg->s_name, "-x")) {
+ flags |= NOMOUSE;
+ argc -= 1; argv += 1;
} else break;
}
+ x->flags = flags;
if (flags&CLOSED&&argc) slot_setfloatarg( &x->fillcolor, argc--,argv++);
else slot_setfloat_const(&x->fillcolor, 0);
***************
*** 4546,4550 ****
t_slot *f = x->vec;
int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff;
! if (!slot_getfloat(&x->vis, t, data, 0)) {
*xp1 = *yp1 = 0x7fffffff;
*xp2 = *yp2 = -0x7fffffff;
--- 4556,4560 ----
t_slot *f = x->vec;
int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff;
! if (x->flags&NOMOUSE || !slot_getfloat(&x->vis, t, data, 0)) {
*xp1 = *yp1 = 0x7fffffff;
*xp2 = *yp2 = -0x7fffffff;
***************
*** 4613,4616 ****
--- 4623,4628 ----
t_word *wp;
t_template *t;
+ t_gpointer gpointer;
+
} cm;
***************
*** 4622,4631 ****
t_curve *x = (t_curve *)z;
t_slot *f = x->vec + cm.field;
cm.xcumulative += dx;
cm.ycumulative += dy;
if (f[0].var && dx!=0) slot_setcoord(f, cm.t, cm.wp, cm.xbase + cm.xcumulative*cm.xper, 1);
if (f[1].var && dy!=0) slot_setcoord(f+1, cm.t, cm.wp, cm.ybase + cm.ycumulative*cm.yper, 1);
! if (cm.scalar) scalar_redraw(cm.scalar, cm.canvas);
! if (cm.array) array_redraw(cm.array, cm.canvas);
}
#endif
--- 4634,4646 ----
t_curve *x = (t_curve *)z;
t_slot *f = x->vec + cm.field;
+ t_atom at;
+ if (!gpointer_check(&curve_motion_gpointer, 0)) {post("curve_motion: scalar disappeared"); return;}
cm.xcumulative += dx;
cm.ycumulative += dy;
if (f[0].var && dx!=0) slot_setcoord(f, cm.t, cm.wp, cm.xbase + cm.xcumulative*cm.xper, 1);
if (f[1].var && dy!=0) slot_setcoord(f+1, cm.t, cm.wp, cm.ybase + cm.ycumulative*cm.yper, 1);
! /* LATER figure out what to do to notify for an array? */
! if (cm.scalar) template_notifyforscalar(cm.t, cm.canvas, cm.scalar, gensym("change"), 1, &at);
! if (cm.scalar) gobj_changed(cm.scalar,0); else gobj_changed(cm.array,0);
}
#endif
***************
*** 4666,4669 ****
--- 4681,4686 ----
cm.field = 2*bestn;
cm.t = t;
+ if (cm.scalar) gpointer_setcanvas(&cm.gpointer, cm.canvas, cm.scalar);
+ else gpointer_setarray(&cm.gpointer, cm.array, cm.wp);
/* canvas_grab(canvas, z, curve_motion, 0, xpix, ypix); */
}
***************
*** 5160,5167 ****
t_drawnumber *x = (t_drawnumber *)z;
t_slot *f = &x->value;
dn.ycumulative -= dy;
template_setfloat(dn.t, f->u.varsym, dn.wp, dn.ycumulative, 1);
! if (dn.scalar) scalar_redraw(dn.scalar, dn.canvas);
! if (dn.array) array_redraw(dn.array, dn.canvas);
}
#endif
--- 5177,5186 ----
t_drawnumber *x = (t_drawnumber *)z;
t_slot *f = &x->value;
+ t_atom at;
+ if (!gpointer_check(&dn.gpointer, 0)) {post("drawnumber_motion: scalar disappeared"); return;}
+ if (dn.symbol) {post("drawnumber_motion: symbol"); return;}
dn.ycumulative -= dy;
template_setfloat(dn.t, f->u.varsym, dn.wp, dn.ycumulative, 1);
! if (dn.scalar) gobj_changed(dn.scalar); else gobj_changed(dn.array);
}
#endif
***************
*** 5205,5210 ****
template_setfloat(dn.t, f->u.varsym, dn.wp, newf, 1);
if (dn.scalar) template_notifyforscalar(dn.t, dn.canvas, dn.scalar, gensym("change"), 1, &at);
! if (dn.scalar) scalar_redraw(dn.scalar, dn.canvas);
! if (dn.array) array_redraw(dn.array, dn.canvas);
}
}
--- 5224,5228 ----
template_setfloat(dn.t, f->u.varsym, dn.wp, newf, 1);
if (dn.scalar) template_notifyforscalar(dn.t, dn.canvas, dn.scalar, gensym("change"), 1, &at);
! if (dn.scalar) gobj_changed(dn.scalar,0); else gobj_changed(dn.array,0);
}
}
***************
*** 5222,5227 ****
dn.scalar = sc;
dn.array = ap;
dn.ycumulative = slot_getfloat(&x->value, t, data, 0);
! /* canvas_grab(canvas, z, drawnumber_motion, 0, xpix, ypix); */
}
return 1;
--- 5240,5250 ----
dn.scalar = sc;
dn.array = ap;
+ dn.firstkey = 1;
dn.ycumulative = slot_getfloat(&x->value, t, data, 0);
! dn.symbol = (x->flags & DRAW_SYMBOL)!=0;
! if (dn.scalar)
! gpointer_setcanvas(&dn.gpointer, dn.canvas, dn.scalar);
! else gpointer_setarray(&dn.gpointer, dn.array, dn.wp);
! /* canvas_grab(glist, z, drawnumber_motion, drawnumber_key, xpix, ypix); */
}
return 1;