Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13637
Modified Files: Tag: devel_0_39 desire.c Log Message: simplified observers (part 4)
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.33 retrieving revision 1.1.2.34 diff -C2 -d -r1.1.2.33 -r1.1.2.34 *** desire.c 21 Oct 2005 13:17:01 -0000 1.1.2.33 --- desire.c 21 Oct 2005 15:38:28 -0000 1.1.2.34 *************** *** 60,64 ****
// if !k then suppose all of the object might have changed. ! void gobj_changed (t_gobj *self, const char *k) { int dirty = k ? (1<<class_getfieldindex(self->g_pd,k)) : -1; t_atom argv[1]; --- 60,65 ----
// if !k then suppose all of the object might have changed. ! void gobj_changed (void *self_, const char *k) { ! t_gobj *self = (t_gobj *)self_; int dirty = k ? (1<<class_getfieldindex(self->g_pd,k)) : -1; t_atom argv[1]; *************** *** 67,71 **** }
! void gobj_changed2 (t_gobj *self, int argc, t_atom *argv) { t_appendix *d = self->g_adix; int i; --- 68,75 ---- }
! // if only a float is sent, it's a bitset of at most 25 elements ! // else it may mean whatever else... ! void gobj_changed2 (void *self_, int argc, t_atom *argv) { ! t_gobj *self = (t_gobj *)self_; t_appendix *d = self->g_adix; int i; *************** *** 1387,1392 **** }
! void gobj_vis(t_gobj *x, struct _glist *glist, int flag) ! { t_widgetbehavior *w = x->g_pd->c_wb; if (w && w->w_visfn) --- 1391,1397 ---- }
! void gobj_vis(t_gobj *x, struct _glist *glist, int flag) { ! post("warning: t_visfn shouldn't do anything anymore"); ! /* t_widgetbehavior *w = x->g_pd->c_wb; if (w && w->w_visfn) *************** *** 1395,1411 **** glist->gl_owner && (pd_class(&glist->gl_pd) != garray_class)) { ! /* if we're graphing-on-parent and the object falls outside the ! graph rectangle, don't draw it. */ int x1, y1, x2, y2, gx1, gy1, gx2, gy2, m; gobj_getrect(&glist->gl_gobj, glist->gl_owner, &x1, &y1, &x2, &y2); ! if (x1 > x2) m = x1, x1 = x2, x2 = m; ! if (y1 > y2) m = y1, y1 = y2, x2 = m; gobj_getrect(x, glist, &gx1, &gy1, &gx2, &gy2); ! if (gx1 < x1 || gx1 > x2 || gx2 < x1 || gx2 > x2 || ! gy1 < y1 || gy1 > y2 || gy2 < y1 || gy2 > y2) return; } w->w_visfn(x, glist, flag); } }
--- 1400,1417 ---- glist->gl_owner && (pd_class(&glist->gl_pd) != garray_class)) { ! // if we're graphing-on-parent and the object falls outside the ! // graph rectangle, don't draw it. int x1, y1, x2, y2, gx1, gy1, gx2, gy2, m; gobj_getrect(&glist->gl_gobj, glist->gl_owner, &x1, &y1, &x2, &y2); ! if (x1>x2) m=x1, x1=x2, x2=m; ! if (y1>y2) m=y1, y1=y2, x2=m; gobj_getrect(x, glist, &gx1, &gy1, &gx2, &gy2); ! if (gx1<x1 || gx1>x2 || gx2<x1 || gx2>WWWWx2 || ! gy1<y1 || gy1>y2 || gy2<y1 || gy2>y2) return; } w->w_visfn(x, glist, flag); } + */ }
*************** *** 5213,5219 **** void glist_add(t_glist *x, t_gobj *y) { - t_object *ob; y->g_adix = appendix_new(y); /* mb: i found no better place for initing this */ ! gobj_subscribe(y,x); y->g_next = 0; if (!x->gl_list) x->gl_list = y; --- 5219,5225 ---- void glist_add(t_glist *x, t_gobj *y) { y->g_adix = appendix_new(y); /* mb: i found no better place for initing this */ ! gobj_subscribe(y,(t_gobj *)x); ! gobj_changed(y,""); y->g_next = 0; if (!x->gl_list) x->gl_list = y; *************** *** 11500,11512 **** void pd_upload(t_gobj *self);
- /* Todo: this will instead maintain a hashtable of objects that should redrawn, - and the scheduler will flush it (or part of it) once in a while... */ - static void pd_changed (/*t_gobj*/ void *x) { - t_gobj *self = (t_gobj *)x; - pd_upload(self); - //if (!glist_isvisible(glist_getcanvas(glist))) return; /* <-- doesn't really work */ - //sys_mgui(self,"draw",""); - } - void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv) { t_text *x = (t_text *)pd_new(text_class); --- 11506,11509 ---- *************** *** 11573,11577 **** x->te_width = 0; x->te_type = T_OBJECT; - pd_changed(x); glist_add(gl, &x->te_g); if (selected) { --- 11570,11573 ---- *************** *** 12022,12027 **** static void text_vis(t_gobj *z, t_glist *glist, int vis) { t_text *x = (t_text *)z; ! pd_changed(x); ! if (vis) {if (text_shouldvis(x, glist)) /*pd_changed(x)*/;} }
--- 12018,12022 ---- static void text_vis(t_gobj *z, t_glist *glist, int vis) { t_text *x = (t_text *)z; ! gobj_changed(x,0); }
*************** *** 12172,12184 **** }
! static void iemgui_send(t_iemgui *x, t_symbol *s) ! { x->snd = canvas_realizedollar(x->glist, s); ! if (x->snd==s_empty) x->snd=0; ! pd_changed(x); }
! static void iemgui_receive(t_iemgui *x, t_symbol *s) ! { t_symbol *rcv = canvas_realizedollar(x->glist, s); if (rcv==s_empty) rcv=0; --- 12167,12176 ---- }
! static void iemgui_send(t_iemgui *x, t_symbol *s) { x->snd = canvas_realizedollar(x->glist, s); ! if (x->snd==s_empty) {x->snd=0; gobj_changed(x,"snd");} }
! static void iemgui_receive(t_iemgui *x, t_symbol *s) { t_symbol *rcv = canvas_realizedollar(x->glist, s); if (rcv==s_empty) rcv=0; *************** *** 12193,12219 **** x->rcv = rcv; } ! pd_changed(x); }
static void iemgui_label(t_iemgui *x, t_symbol *s) { x->lab = s; ! pd_changed(x); } static void iemgui_label_pos(t_iemgui *x, t_float ldx, t_float ldy) { x->ldx = (int)ldx; x->ldy = (int)ldy; ! pd_changed(x); } static void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { x->fontsize = MAX(4,(int)atom_getintarg(1, ac, av)); x->font_style = atom_getintarg(0, ac, av); ! pd_changed(x); } ! static ! void iemgui_size(t_iemgui *x) { ! if(glist_isvisible(x->glist)) { ! pd_changed(x); ! canvas_fixlinesfor(glist_getcanvas(x->glist), (t_text*)x); ! } } static void iemgui_delta(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { --- 12185,12208 ---- x->rcv = rcv; } ! gobj_changed(x,"rcv"); }
static void iemgui_label(t_iemgui *x, t_symbol *s) { x->lab = s; ! gobj_changed(x,"lab"); } static void iemgui_label_pos(t_iemgui *x, t_float ldx, t_float ldy) { x->ldx = (int)ldx; x->ldy = (int)ldy; ! gobj_changed(x,0); } static void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { x->fontsize = MAX(4,(int)atom_getintarg(1, ac, av)); x->font_style = atom_getintarg(0, ac, av); ! gobj_changed(x,0); } ! static void iemgui_size(t_iemgui *x) { /*useless?*/ ! gobj_changed(x,0); ! canvas_fixlinesfor(glist_getcanvas(x->glist), (t_text*)x); } static void iemgui_delta(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { *************** *** 12237,12241 **** if(ac > 2) x->fcol = iemgui_compatible_col(atom_getintarg(i++, ac, av)); x->lcol = iemgui_compatible_col(atom_getintarg(i++, ac, av)); ! pd_changed(x); }
--- 12226,12230 ---- if(ac > 2) x->fcol = iemgui_compatible_col(atom_getintarg(i++, ac, av)); x->lcol = iemgui_compatible_col(atom_getintarg(i++, ac, av)); ! gobj_changed(x,0); }
*************** *** 12490,12494 **** }
! static void bng_set(t_bng *x) {x->count++; pd_changed(x);} static void bng_bout2(t_bng *x) { outlet_bang(x->obj.ob_outlet); --- 12479,12483 ---- }
! static void bng_set(t_bng *x) {x->count++; gobj_changed(x,"count");} static void bng_bout2(t_bng *x) { outlet_bang(x->obj.ob_outlet); *************** *** 12537,12541 **** iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! pd_changed(x); }
--- 12526,12530 ---- iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! gobj_changed(x,0); }
*************** *** 12589,12593 **** static void toggle_bang(t_toggle *x) { x->on = x->on?0.0:x->nonzero; ! pd_changed(x); toggle_action(x); } --- 12578,12582 ---- static void toggle_bang(t_toggle *x) { x->on = x->on?0.0:x->nonzero; ! gobj_changed(x,"on"); toggle_action(x); } *************** *** 12597,12601 **** x->on=f; if(f) x->nonzero=f; ! if (on!=x->on) pd_changed(x); }
--- 12586,12590 ---- x->on=f; if(f) x->nonzero=f; ! if (on!=x->on) gobj_changed(x,"on"); }
*************** *** 12636,12640 **** iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! pd_changed(x); }
--- 12625,12629 ---- iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! gobj_changed(x,0); }
*************** *** 12681,12685 **** if(x->on!=old) x->on_old = x->on; x->on = i; ! pd_changed(x); if(x->on!=old) x->on_old = old; } --- 12670,12674 ---- if(x->on!=old) x->on_old = x->on; x->on = i; ! gobj_changed(x,"on"); if(x->on!=old) x->on_old = old; } *************** *** 12711,12761 **** }
! static void radio_fout(t_radio *x, t_floatarg f) ! { ! int i=(int)f; ! CLAMP(i,0,x->number-1); ! if (x->flavor == sym_vdl || x->flavor == sym_hdl) ! { ! /* compatibility with earlier "hdial" behavior */ ! if(x->change && i!=x->on_old) radio_send2(x,x->on_old,0.0); ! x->on_old = x->on; ! x->on = i; ! pd_changed(x); ! x->on_old = x->on; ! radio_send2(x,x->on,1.0); ! } else { ! x->on = i; ! radio_send(x,x->on); ! pd_changed(x); ! x->on_old = x->on; ! } ! } ! ! static void radio_float(t_radio *x, t_floatarg f) ! { int i=(int)f; CLAMP(i,0,x->number-1); ! if (x->flavor == sym_vdl || x->flavor == sym_hdl) ! { ! /* compatibility with earlier "vdial" behavior */ ! if (x->change && i!=x->on_old && iemgui_forward(x)) radio_send2(x,x->on_old,0.0); x->on_old = x->on; x->on = i; ! pd_changed(x); x->on_old = x->on; ! if(iemgui_forward(x)) radio_send2(x,x->on,1.0); } else { x->on = i; ! if (iemgui_forward(x)) radio_send(x,x->on); ! pd_changed(x); x->on_old = x->on; } }
static void radio_loadbang(t_radio *x) {if(iemgui_loadbang(x)) radio_bang(x);}
! static void radio_number(t_radio *x, t_floatarg num) ! { int n=(int)num; CLAMP(n,1,128); --- 12700,12730 ---- }
! static void radio_fout2(t_radio *x, t_floatarg f, int forwardonly) { ! int isdial = x->flavor == sym_vdl || x->flavor == sym_hdl; int i=(int)f; CLAMP(i,0,x->number-1); ! if (isdial) { ! /* compatibility with earlier "hdial" behavior */ ! if(x->change && i!=x->on_old && (!forwardonly || iemgui_forward(x))) radio_send2(x,x->on_old,0.0); x->on_old = x->on; x->on = i; ! gobj_changed(x,"on"); x->on_old = x->on; ! radio_send2(x,x->on,1.0); ! if(!forwardonly || iemgui_forward(x)) radio_send2(x,x->on,1.0); } else { x->on = i; ! if (!forwardonly || iemgui_forward(x)) radio_send(x,x->on); ! gobj_changed(x,"on"); x->on_old = x->on; } }
+ static void radio_fout (t_radio *x, t_floatarg f) {radio_fout2(x,f,0);} + static void radio_float(t_radio *x, t_floatarg f) {radio_fout2(x,f,1);} static void radio_loadbang(t_radio *x) {if(iemgui_loadbang(x)) radio_bang(x);}
! static void radio_number(t_radio *x, t_floatarg num) { int n=(int)num; CLAMP(n,1,128); *************** *** 12765,12774 **** CLAMP(x->on,0,x->number-1); x->on_old = x->on; ! pd_changed(x); } }
! static void radio_size(t_radio *x, t_float size) ! { x->h = x->w = iemgui_clip_size(size); iemgui_size((t_iemgui *)x); --- 12734,12743 ---- CLAMP(x->on,0,x->number-1); x->on_old = x->on; ! gobj_changed(x,"on"); ! gobj_changed(x,"number"); } }
! static void radio_size(t_radio *x, t_float size) { x->h = x->w = iemgui_clip_size(size); iemgui_size((t_iemgui *)x); *************** *** 12799,12803 **** iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! pd_changed(x); }
--- 12768,12772 ---- iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! gobj_changed(x,0); }
*************** *** 12887,12891 **** x->val = (int)(100.0*g + 0.49999); x->pos = x->val; ! pd_changed(x); }
--- 12856,12861 ---- x->val = (int)(100.0*g + 0.49999); x->pos = x->val; ! gobj_changed(x,"val"); ! gobj_changed(x,"pos"); }
*************** *** 12947,12954 **** iemgui_constrain((t_iemgui *)x); slider_check_minmax(x); ! if (isvert(x)) slider_check_width(x, x->h); ! else slider_check_width(x, x->w); if(x->rcv) pd_bind((t_pd *)x, x->rcv); ! pd_changed(x); }
--- 12917,12923 ---- iemgui_constrain((t_iemgui *)x); slider_check_minmax(x); ! slider_check_width(x, isvert(x) ? x->h : x->w); if(x->rcv) pd_bind((t_pd *)x, x->rcv); ! gobj_changed(x,0); }
*************** *** 13018,13023 **** }
! static void nbbang(t_nbx *x) ! { outlet_float(x->obj.ob_outlet, x->val); if(x->snd && x->snd->s_thing) --- 12987,12991 ---- }
! static void nbbang(t_nbx *x) { outlet_float(x->obj.ob_outlet, x->val); if(x->snd && x->snd->s_thing) *************** *** 13026,13030 ****
static void nbset(t_nbx *x, t_floatarg f) ! {x->val=f; nbclip(x); pd_changed(x);}
static void nblog_height(t_nbx *x, t_floatarg lh) { --- 12994,12998 ----
static void nbset(t_nbx *x, t_floatarg f) ! {x->val=f; nbclip(x); gobj_changed(x,0);}
static void nblog_height(t_nbx *x, t_floatarg lh) { *************** *** 13036,13041 **** {nbset(x, f); if(iemgui_forward(x)) nbbang(x);}
! static void nbsize(t_nbx *x, t_symbol *s, int ac, t_atom *av) ! { x->w = MAX(1,(int)atom_getintarg(0, ac, av)); if(ac > 1) x->h = MAX(8,(int)atom_getintarg(1, ac, av)); --- 13004,13008 ---- {nbset(x, f); if(iemgui_forward(x)) nbbang(x);}
! static void nbsize(t_nbx *x, t_symbol *s, int ac, t_atom *av) { x->w = MAX(1,(int)atom_getintarg(0, ac, av)); if(ac > 1) x->h = MAX(8,(int)atom_getintarg(1, ac, av)); *************** *** 13044,13059 ****
static void nbrange(t_nbx *x, t_float min, t_float max) ! {x->min=min; x->max=max; ! if(nbcheck_minmax(x)) pd_changed(x);} ! ! static void nblin(t_nbx *x) {x->is_log=0;} ! static void nblog(t_nbx *x) {x->is_log=1; ! if(nbcheck_minmax(x)) pd_changed(x);}
! static void nbloadbang(t_nbx *x) ! {if(iemgui_loadbang(x)) nbbang(x);}
! static void nblist(t_nbx *x, t_symbol *s, int ac, t_atom *av) ! { if (!IS_A_FLOAT(av,0)) return; nbset(x, atom_getfloatarg(0, ac, av)); --- 13011,13021 ----
static void nbrange(t_nbx *x, t_float min, t_float max) ! {x->min=min; x->max=max; if(nbcheck_minmax(x)) gobj_changed(x,0);}
! static void nblin(t_nbx *x) {x->is_log=0; gobj_changed(x,"is_log");} ! static void nblog(t_nbx *x) {x->is_log=1; nbcheck_minmax(x); gobj_changed(x,"is_log");} ! static void nbloadbang(t_nbx *x) {if(iemgui_loadbang(x)) nbbang(x);}
! static void nblist(t_nbx *x, t_symbol *s, int ac, t_atom *av) { if (!IS_A_FLOAT(av,0)) return; nbset(x, atom_getfloatarg(0, ac, av)); *************** *** 13076,13085 **** }
! static void nbreload(t_nbx *x, t_symbol *s, int argc, t_atom *argv) ! { t_foo foo = { argc, argv, 0 }; binbuf_update((t_iemgui *)x,gensym("nbx"),argc,argv); if (!nbpickle(x,&foo)) return; - int w; if (!x->isa&1) x->val=0.0; w=x->w; --- 13038,13046 ---- }
! static void nbreload(t_nbx *x, t_symbol *s, int argc, t_atom *argv) { t_foo foo = { argc, argv, 0 }; + int w; binbuf_update((t_iemgui *)x,gensym("nbx"),argc,argv); if (!nbpickle(x,&foo)) return; if (!x->isa&1) x->val=0.0; w=x->w; *************** *** 13089,13093 **** x->w = MAX(x->w,1); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! pd_changed(x); }
--- 13050,13054 ---- x->w = MAX(x->w,1); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! gobj_changed(x,0); }
*************** *** 13152,13158 **** static t_class *vu_class;
- static void vu_update(t_vu *x, t_glist *glist) - {if(glist_isvisible(glist)) sys_mgui((t_gobj *)x,"set","ii",x->rms,x->peak);} - static void vu_check_height(t_vu *x, int h) { --- 13113,13116 ---- *************** *** 13160,13175 **** x->led_size = n-1; x->h = IEM_VU_STEPS * n; }
static void vu_scale(t_vu *x, t_floatarg fscale) ! {x->scale = !!fscale; pd_changed(x);}
static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av) { x->w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); ! if(ac > 1) vu_check_height(x, (int)atom_getintarg(1, ac, av)); ! pd_changed(x); ! if(glist_isvisible(x->glist)) ! canvas_fixlinesfor(glist_getcanvas(x->glist), (t_text*)x); }
--- 13118,13133 ---- x->led_size = n-1; x->h = IEM_VU_STEPS * n; + gobj_changed(x,0); }
static void vu_scale(t_vu *x, t_floatarg fscale) ! {x->scale = !!fscale; gobj_changed(x,"scale");}
static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av) { x->w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); ! if(ac>1) vu_check_height(x, (int)atom_getintarg(1, ac, av)); ! gobj_changed(x,0); ! if(glist_isvisible(x->glist)) canvas_fixlinesfor(glist_getcanvas(x->glist), (t_text*)x); }
*************** *** 13180,13195 **** }
! static void vu_float0(t_vu *x, t_floatarg v) { ! x->rms = vuify(x,v); x->fr = 0.01*(int)(100.0*v+0.5); ! outlet_float(x->out_rms, x->fr); vu_update(x, x->glist);} ! static void vu_float1(t_vu *x, t_floatarg v) { ! x->peak = vuify(x,v); x->fp = 0.01*(int)(100.0*v+0.5); ! outlet_float(x->out_peak, x->fp); vu_update(x, x->glist);}
! static void vu_bang(t_vu *x) ! { outlet_float(x->out_peak, x->fp); outlet_float(x->out_rms, x->fr); - vu_update(x, x->glist); }
--- 13138,13147 ---- }
! static void vu_float0(t_vu *x, t_floatarg v) {x->rms =vuify(x,v); x->fr=0.01*(int)(100.0*v+0.5); outlet_float(x->out_rms, x->fr); gobj_changed(x,"rms" );} ! static void vu_float1(t_vu *x, t_floatarg v) {x->peak=vuify(x,v); x->fp=0.01*(int)(100.0*v+0.5); outlet_float(x->out_peak, x->fp); gobj_changed(x,"peak");}
! static void vu_bang(t_vu *x) { outlet_float(x->out_peak, x->fp); outlet_float(x->out_rms, x->fr); }
*************** *** 13207,13212 **** }
! static void vu_reload(t_vu *x, t_symbol *s, int argc, t_atom *argv) ! { t_foo foo = { argc, argv, 0 }; binbuf_update((t_iemgui *)x,gensym("vu"),argc,argv); --- 13159,13163 ---- }
! static void vu_reload(t_vu *x, t_symbol *s, int argc, t_atom *argv) { t_foo foo = { argc, argv, 0 }; binbuf_update((t_iemgui *)x,gensym("vu"),argc,argv); *************** *** 13214,13218 **** iemgui_constrain((t_iemgui *)x); if(x->rcv) pd_bind((t_pd *)x, x->rcv); ! pd_changed(x); }
--- 13165,13169 ---- iemgui_constrain((t_iemgui *)x); if(x->rcv) pd_bind((t_pd *)x, x->rcv); ! gobj_changed(x,0); }
*************** *** 13265,13271 **** static void cnv_vis_size(t_cnv *x, t_symbol *s, int ac, t_atom *av) { ! x->vis_h = x->vis_w = MAX(1,(int)atom_getintarg(0, ac, av)); if(ac > 1) x->vis_h = MAX(1,(int)atom_getintarg(1, ac, av)); ! pd_changed(x); }
--- 13216,13222 ---- static void cnv_vis_size(t_cnv *x, t_symbol *s, int ac, t_atom *av) { ! x->vis_h = x->vis_w = MAX(1,(int)atom_getintarg(0, ac, av)); if(ac > 1) x->vis_h = MAX(1,(int)atom_getintarg(1, ac, av)); ! gobj_changed(x,0); }
*************** *** 13295,13299 **** iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! pd_changed(x); } #undef FOO --- 13246,13250 ---- iemgui_constrain((t_iemgui *)x); if (x->rcv) pd_bind((t_pd *)x, x->rcv); ! gobj_changed(x,0); } #undef FOO *************** *** 13361,13365 **** if (x->rcv) pd_bind((t_pd *)x, x->rcv); iemgui_constrain((t_iemgui *)x); ! pd_changed(x); }
--- 13312,13316 ---- if (x->rcv) pd_bind((t_pd *)x, x->rcv); iemgui_constrain((t_iemgui *)x); ! gobj_changed(x,0); }