[PD-cvs] pd/src desire.c,1.1.2.217.2.12,1.1.2.217.2.13
Mathieu Bouchard
matju at users.sourceforge.net
Sat Dec 2 08:48:33 CET 2006
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16615
Modified Files:
Tag: desiredata
desire.c
Log Message:
SET macro, part 2
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.12
retrieving revision 1.1.2.217.2.13
diff -C2 -d -r1.1.2.217.2.12 -r1.1.2.217.2.13
*** desire.c 2 Dec 2006 07:09:31 -0000 1.1.2.217.2.12
--- desire.c 2 Dec 2006 07:48:28 -0000 1.1.2.217.2.13
***************
*** 72,75 ****
--- 72,78 ----
for (t_linetraverser TRAV(CANVAS); (WIRE=linetraverser_next(&TRAV)); )
+ #undef SET
+ #define SET(attr,value) gobj_changed(x,#attr), x->attr = (value);
+
#define CLAMP(_var,_min,_max) do { if (_var<_min) _var=_min; else if (_var>_max) _var=_max; } while(0)
template <class T> T min(T a, T b) {return a<b?a:b;}
***************
*** 352,357 ****
t_canvas *canvas_list; /* list of all root canvases */
static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2);
- static void canvas_drawlines(t_canvas *x);
-
static t_symbol *canvas_newfilename = &s_;
static t_symbol *canvas_newdirectory = &s_;
--- 355,358 ----
***************
*** 445,452 ****
t_symbol *bs = canvas_makebindsym(x->name);
if (x->name!=s_Pd) pd_unbind(x, bs);
! x->name = s;
if (x->name!=s_Pd) pd_bind(x, bs);
! if (dir && dir != &s_) canvas_getenv(x)->dir = dir;
! gobj_changed(x,0);
}
--- 446,455 ----
t_symbol *bs = canvas_makebindsym(x->name);
if (x->name!=s_Pd) pd_unbind(x, bs);
! SET(name,s);
if (x->name!=s_Pd) pd_bind(x, bs);
! if (dir && dir != &s_) {
! canvas_getenv(x)->dir = dir;
! gobj_changed(x,"dir");
! }
}
***************
*** 507,511 ****
if (hack) { /* only manage this canvas if it's not one of the 3 invisible builtin canvases */
gobj_subscribe(x,manager);
! gobj_changed(x,0);
}
}
--- 510,514 ----
if (hack) { /* only manage this canvas if it's not one of the 3 invisible builtin canvases */
gobj_subscribe(x,manager);
! gobj_changed(x,0); // could be made implicit
}
}
***************
*** 569,583 ****
void canvas_setgraph(t_canvas *x, int flag, int nogoprect);
- #undef SET
- #define SET(attr,value) gobj_changed(x,#attr), x->attr = (value);
-
static void canvas_coords(t_canvas *x, t_symbol *s, int argc, t_atom *argv) {
! printf("scanargs = %d\n",
! pd_scanargs(argc,argv,"ffffii*",&x->x1,&x->y1,&x->x2,&x->y2,&x->pixwidth,&x->pixheight));
if (argc <= 7) canvas_setgraph(x, atom_getintarg(6, argc, argv), 1);
else {
canvas_setgraph(x, atom_getintarg(6, argc, argv), 0);
! SET(xmargin, atom_getintarg(7, argc, argv));
! SET(ymargin, atom_getintarg(8, argc, argv));
}
gobj_changed(x,0);
--- 572,582 ----
void canvas_setgraph(t_canvas *x, int flag, int nogoprect);
static void canvas_coords(t_canvas *x, t_symbol *s, int argc, t_atom *argv) {
! pd_scanargs(argc,argv,"ffffii*",&x->x1,&x->y1,&x->x2,&x->y2,&x->pixwidth,&x->pixheight);
if (argc <= 7) canvas_setgraph(x, atom_getintarg(6, argc, argv), 1);
else {
canvas_setgraph(x, atom_getintarg(6, argc, argv), 0);
! SET(xmargin, atom_getintarg(7, argc, argv));
! SET(ymargin, atom_getintarg(8, argc, argv));
}
gobj_changed(x,0);
***************
*** 674,685 ****
}
- void canvas_drawredrect(t_canvas *x, int doit) {
- /*
- if (doit) sys_mgui(canvas_getcanvas(x),"gop_rectangle","iiii",
- x->xmargin, x->ymargin, x->pixwidth, x->pixheight);
- else sys_mgui(canvas_getcanvas(x),"gop_rectangle_delete","");
- */
- }
-
static void canvas_vis(t_canvas *x, t_floatarg f);
--- 673,676 ----
***************
*** 689,696 ****
if (f!=0 && !canvas_isvisible(x)) {
gobj_subscribe(x,manager);
! canvas_each(y,x) gobj_changed(y,0);
! gobj_changed(x,0);
! canvas_drawlines(x); /*quoi?*/
! if (x->isgraph && x->goprect) canvas_drawredrect(x, 1); /*perdu*/
}
if (f==0 && canvas_isvisible(x)) gobj_unsubscribe(x,manager);
--- 680,685 ----
if (f!=0 && !canvas_isvisible(x)) {
gobj_subscribe(x,manager);
! gobj_changed(x,0); canvas_each(y,x) gobj_changed(y,0); // could be made implicit
! canvas_wires_each(oc,t,x) gobj_changed(oc,0); // this too
}
if (f==0 && canvas_isvisible(x)) gobj_unsubscribe(x,manager);
***************
*** 714,718 ****
t_canvas *gl2 = x->owner;
if (!gl2) pd_error(x,"can't open a non-subcanvas");
! else {x->havewindow = 1; gobj_changed(x,0);}
}
}
--- 703,707 ----
t_canvas *gl2 = x->owner;
if (!gl2) pd_error(x,"can't open a non-subcanvas");
! else SET(havewindow,1);
}
}
***************
*** 750,757 ****
}
- static void canvas_drawlines(t_canvas *x) {
- canvas_wires_each(oc,t,x) gobj_changed(oc,0);
- }
-
/* kill all lines for one inlet or outlet */
void canvas_deletelinesforio(t_canvas *x, t_text *text, t_inlet *inp, t_outlet *outp) {
--- 739,742 ----
***************
*** 1164,1168 ****
}
}
! gobj_changed(x,0);
}
--- 1149,1153 ----
}
}
! gobj_changed(x,"wires");
}
***************
*** 1203,1207 ****
if (ob->ob_pd->c_firstin) closest--;
if (closest < 0)
! sys_mgui(".x%lx.c create text %d %d -anchor sw -text \"%s\" -tags y\n",
(t_int)x, xpos, ypos,ob->ob_pd->c_firsttip->s_name);
else
--- 1188,1192 ----
if (ob->ob_pd->c_firstin) closest--;
if (closest < 0)
! sys_vgui(".x%lx.c create text %d %d -anchor sw -text \"%s\" -tags y\n",
(t_int)x, xpos, ypos,ob->ob_pd->c_firsttip->s_name);
else
***************
*** 1410,1414 ****
if (is_dummy(from)) while (outlet >= obj_noutlets(from)) outlet_new(from, &s_);
if (is_dummy(to)) while ( inlet >= obj_ninlets(to)) inlet_new(to,to,&s_,&s_);
! gobj_changed(x,0);
if (!(oc = obj_connect(from,outlet,to,inlet))) goto bad;
pd_set_newest(oc);
--- 1395,1399 ----
if (is_dummy(from)) while (outlet >= obj_noutlets(from)) outlet_new(from, &s_);
if (is_dummy(to)) while ( inlet >= obj_ninlets(to)) inlet_new(to,to,&s_,&s_);
! gobj_changed(x,"wires");
if (!(oc = obj_connect(from,outlet,to,inlet))) goto bad;
pd_set_newest(oc);
***************
*** 2256,2260 ****
static void graph_graphrect(t_gobj *z, t_canvas *canvas, int *xp1, int *yp1, int *xp2, int *yp2);
- void canvas_drawredrect(t_canvas *x, int doit);
void canvas_add(t_canvas *x, t_gobj *y) {
--- 2241,2244 ----
***************
*** 2300,2307 ****
}
gobj_changed(x,0);
! if (x->isgraph && !x->goprect && pd_checkobject(y)) {
! x->goprect = 1;
! canvas_drawredrect(x, 1);
! }
if (class_isdrawcommand(y->_class))
canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(canvas_getcanvas(x)->name)), 0);
--- 2284,2288 ----
}
gobj_changed(x,0);
! if (x->isgraph && !x->goprect && pd_checkobject(y)) SET(goprect,1);
if (class_isdrawcommand(y->_class))
canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(canvas_getcanvas(x)->name)), 0);
***************
*** 2610,2629 ****
}
/* draw ticks on horizontal borders. If lperb field is zero, this is disabled. */
if (x->xtick.lperb) {
float upix, lpix;
! if (y2 < y1)
! upix = y1, lpix = y2;
! else upix = y2, lpix = y1;
for (i=0,f=x->xtick.point; f<0.99*x->x2+0.01*x->x1; i++, f+=x->xtick.inc) {
! int tickpix = i%x->xtick.lperb ? 2 : 4;
! int x0 = (int)canvas_xtopixels(x, f);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x0, (int)upix, x0, (int)(upix-tickpix), tag);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x0, (int)lpix, x0, (int)(lpix+tickpix), tag);
}
for (i=1,f=x->xtick.point-x->xtick.inc; f>0.99*x->x1+0.01*x->x2; i++,f-=x->xtick.inc) {
! int tickpix = i%x->xtick.lperb ? 2 : 4;
! int x0 = canvas_xtopixels(x, f);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x0, (int)upix, x0, (int)(upix-tickpix), tag);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x0, (int)lpix, x0, (int)(lpix+tickpix), tag);
}
}
--- 2591,2609 ----
}
/* draw ticks on horizontal borders. If lperb field is zero, this is disabled. */
+ #define DRAWTICK(x1,y1,x2,y2) sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", \
+ (long)c, int(x1),int(y1),int(x2),int(y2),tag)
if (x->xtick.lperb) {
float upix, lpix;
! if (y2<y1) {upix = y1; lpix = y2;}
! else {upix = y2; lpix = y1;}
for (i=0,f=x->xtick.point; f<0.99*x->x2+0.01*x->x1; i++, f+=x->xtick.inc) {
! int tickpix = i%x->xtick.lperb?2:4, x0 = (int)canvas_xtopixels(x, f);
! DRAWTICK(x0,upix,x0,upix-tickpix);
! DRAWTICK(x0,lpix,x0,lpix+tickpix);
}
for (i=1,f=x->xtick.point-x->xtick.inc; f>0.99*x->x1+0.01*x->x2; i++,f-=x->xtick.inc) {
! int tickpix = i%x->xtick.lperb?2:4, x0 = canvas_xtopixels(x, f);
! DRAWTICK(x0,upix,x0,upix-tickpix);
! DRAWTICK(x0,lpix,x0,lpix+tickpix);
}
}
***************
*** 2632,2662 ****
if (x->ytick.lperb) {
float ubound, lbound;
! if (x->y2 < x->y1)
! ubound = x->y1, lbound = x->y2;
! else ubound = x->y2, lbound = x->y1;
for (i=0,f=x->ytick.point; f<0.99*ubound+0.01*lbound; i++, f += x->ytick.inc) {
! int tickpix = i%x->ytick.lperb ? 2 : 4;
! int y0 = (int)canvas_ytopixels(x, f);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x1, y0, x1+tickpix, y0, tag);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x2, y0, x2-tickpix, y0, tag);
}
for (i=1,f=x->ytick.point-x->ytick.inc; f>0.99*lbound+0.01*ubound; i++,f-=x->ytick.inc) {
! int tickpix = i%x->ytick.lperb ? 2 : 4;
! int y0 = (int)canvas_ytopixels(x, f);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x1, y0, x1+tickpix, y0, tag);
! sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", (long)c, x2, y0, x2-tickpix, y0, tag);
}
}
/* draw x labels */
! for (int i=0; i < x->nxlabels; i++)
! sys_vgui(".x%lx.c create text %d %d -text {%s} -font "FONT" -tags %s\n",
! (long)c, (int)canvas_xtopixels(x, atof(x->xlabel[i]->s_name)),
! (int)canvas_ytopixels(x, x->xlabely), x->xlabel[i]->s_name, canvas_getfont(x), tag);
/* draw y labels */
! for (int i=0; i < x->nylabels; i++)
! sys_vgui(".x%lx.c create text %d %d -text {%s} -font "FONT" -tags %s\n",
! (long)c, (int)canvas_xtopixels(x, x->ylabelx),
! (int)canvas_ytopixels(x, atof(x->ylabel[i]->s_name)), x->ylabel[i]->s_name,
! canvas_getfont(x), tag);
/* draw contents of graph as canvas */
canvas_each(g,x) gobj_changed(x,0);
--- 2612,2640 ----
if (x->ytick.lperb) {
float ubound, lbound;
! if (x->y2<x->y1) {ubound = x->y1; lbound = x->y2;}
! else {ubound = x->y2; lbound = x->y1;}
for (i=0,f=x->ytick.point; f<0.99*ubound+0.01*lbound; i++, f += x->ytick.inc) {
! int tickpix = i%x->ytick.lperb?2:4, y0 = (int)canvas_ytopixels(x, f);
! DRAWTICK(x1,y0,x1+tickpix,y0);
! DRAWTICK(x2,y0,x2-tickpix,y0);
}
for (i=1,f=x->ytick.point-x->ytick.inc; f>0.99*lbound+0.01*ubound; i++,f-=x->ytick.inc) {
! int tickpix = i%x->ytick.lperb?2:4, y0 = (int)canvas_ytopixels(x, f);
! DRAWTICK(x1,y0,x1+tickpix,y0);
! DRAWTICK(x2,y0,x2-tickpix,y0);
}
}
/* draw x labels */
! for (int i=0; i < x->nxlabels; i++) {
! char *s = x->xlabel[i]->s_name;
! sys_vgui(".x%lx.c create text %d %d -text {%s} -font "FONT" -tags %s\n", (long)c,
! (int)canvas_xtopixels(x, atof(s)), (int)canvas_ytopixels(x, x->xlabely), s, canvas_getfont(x), tag);
! }
/* draw y labels */
! for (int i=0; i < x->nylabels; i++) {
! char *s = x->ylabel[i]->s_name;
! sys_vgui(".x%lx.c create text %d %d -text {%s} -font "FONT" -tags %s\n", (long)c,
! (int)canvas_xtopixels(x, x->ylabelx), (int)canvas_ytopixels(x, atof(s)), s, canvas_getfont(x), tag);
! }
/* draw contents of graph as canvas */
canvas_each(g,x) gobj_changed(x,0);
***************
*** 7053,7057 ****
CLAMP(x->number,1,128);
CLAMP(x->on,0,x->number-1);
! SET(on_old,x->on = x->isa&1 ? x->on : 0);
outlet_new(x, &s_list);
radio_reload(x,0,argc,argv);
--- 7031,7036 ----
CLAMP(x->number,1,128);
CLAMP(x->on,0,x->number-1);
! SET(on,x->isa&1 ? x->on : 0);
! SET(on_old,x->on);
outlet_new(x, &s_list);
radio_reload(x,0,argc,argv);
***************
*** 7171,7175 ****
binbuf_update(x,gensym((char *)(isvert(x)?"vsl":"hsl")),argc,argv);
if (!slider_pickle(x,&foo)) return;
! SET(pos,x->val = x->isa&1 ? x->val : 0);
iemgui_constrain(x);
slider_check_minmax(x);
--- 7150,7155 ----
binbuf_update(x,gensym((char *)(isvert(x)?"vsl":"hsl")),argc,argv);
if (!slider_pickle(x,&foo)) return;
! SET(val,x->isa&1 ? x->val : 0);
! SET(pos,x->val)
iemgui_constrain(x);
slider_check_minmax(x);
***************
*** 7411,7416 ****
x->h=IEM_VU_STEPS*3;
SET(scale,1);
! SET(peak,x->rms = 0); /* ??? */
! SET(fp,x->fr = -101.0);
vu_check_height(x,x->h);
inlet_new(x,x,&s_float,gensym("ft1"));
--- 7391,7398 ----
x->h=IEM_VU_STEPS*3;
SET(scale,1);
! SET(rms,0); /* ??? */
! SET(peak,0);
! SET(fp,-101.0);
! SET(fr,-101.0);
vu_check_height(x,x->h);
inlet_new(x,x,&s_float,gensym("ft1"));
***************
*** 7443,7451 ****
}
! static void cnv_size(t_cnv *x, t_symbol *s, int ac, t_atom *av)
! {SET(w,x->h = max(1,(int)atom_getintarg(0, ac, av))); iemgui_size(x);}
static void cnv_vis_size(t_cnv *x, t_symbol *s, int ac, t_atom *av) {
! SET(vis_h ,x->vis_w = max(1,(int)atom_getintarg(0, ac, av)));
if(ac > 1) SET(vis_h,max(1,(int)atom_getintarg(1, ac, av)));
gobj_changed(x,0);
--- 7425,7437 ----
}
! static void cnv_size(t_cnv *x, t_symbol *s, int ac, t_atom *av) {
! SET(h,max(1,(int)atom_getintarg(0, ac, av)));
! SET(w,x->h);
! iemgui_size(x);
! }
static void cnv_vis_size(t_cnv *x, t_symbol *s, int ac, t_atom *av) {
! SET(vis_w,max(1,(int)atom_getintarg(0, ac, av)));
! SET(vis_h,x->w);
if(ac > 1) SET(vis_h,max(1,(int)atom_getintarg(1, ac, av)));
gobj_changed(x,0);
***************
*** 7466,7470 ****
binbuf_update(x,gensym("cnv"),argc,argv);
if (!cnv_pickle(x,&foo)) return;
! SET(h,x->w = max(x->w,1));
SET(vis_w,max(x->vis_w,1));
SET(vis_h,max(x->vis_h,1));
--- 7452,7457 ----
binbuf_update(x,gensym("cnv"),argc,argv);
if (!cnv_pickle(x,&foo)) return;
! SET(w,max(x->w,1));
! SET(h,x->w);
SET(vis_w,max(x->vis_w,1));
SET(vis_h,max(x->vis_h,1));
More information about the Pd-cvs
mailing list