Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17996
Modified Files:
Tag: desiredata
desire.c
Log Message:
replace canvas_map by onsubscribe
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.209
retrieving revision 1.1.2.217.2.210
diff -C2 -d -r1.1.2.217.2.209 -r1.1.2.217.2.210
*** desire.c 13 Aug 2007 20:24:46 -0000 1.1.2.217.2.209
--- desire.c 15 Aug 2007 21:21:09 -0000 1.1.2.217.2.210
***************
*** 120,123 ****
--- 120,125 ----
/* subscribing N spies takes N*N time, but it's not important for now */
+ /* subscription could become just a special use of t_outlet in the future, or sometimes become implied. */
+ /* perhaps use [bindelem] here? */
void gobj_subscribe(t_gobj *self, t_gobj *observer) {
t_appendix *d = self->dix;
***************
*** 125,129 ****
d->obs=(t_gobj **)realloc(d->obs,sizeof(t_gobj *)*(1+d->nobs));
d->obs[d->nobs++] = observer;
! gobj_changed(self,0);
}
--- 127,133 ----
d->obs=(t_gobj **)realloc(d->obs,sizeof(t_gobj *)*(1+d->nobs));
d->obs[d->nobs++] = observer;
! t_onsubscribe ons = self->_class->onsubscribe;
! ons(self,observer);
! //post("x%p has %d observers",self,(int)d->nobs);
}
***************
*** 141,145 ****
if (self->dix->canvas) gobj_unsubscribe(self,self->dix->canvas);
self->dix->canvas = c;
! if (self->dix->canvas) gobj_subscribe(self,self->dix->canvas);
}
--- 145,149 ----
if (self->dix->canvas) gobj_unsubscribe(self,self->dix->canvas);
self->dix->canvas = c;
! if (self->dix->canvas) gobj_subscribe(self,self->dix->canvas);
}
***************
*** 363,367 ****
x->gl_next = canvas_list;
canvas_list = x;
! if (x->havewindow || x->willvis) gobj_subscribe(x,manager);
}
--- 367,374 ----
x->gl_next = canvas_list;
canvas_list = x;
! if (x->havewindow || x->willvis) {
! gobj_subscribe(x,manager);
! //canvas_each(y,x) gobj_
! }
}
***************
*** 375,381 ****
}
! /* 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(). */
void canvas_setargs(int argc, t_atom *argv) {
if (canvas_newargv) free(canvas_newargv);
--- 382,387 ----
}
! /* 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(). */
void canvas_setargs(int argc, t_atom *argv) {
if (canvas_newargv) free(canvas_newargv);
***************
*** 495,499 ****
x->ylabel = (t_symbol **)getbytes(0);
// only manage this canvas if it's not one of the 3 invisible builtin canvases
- // if (hack) gobj_subscribe(x,manager);
return x;
}
--- 501,504 ----
***************
*** 638,659 ****
t_symbol *canvas_makebindsym(t_symbol *s) {return symprintf("pd-%s",s->name);}
- static void canvas_vis(t_canvas *x, t_floatarg f);
-
- void canvas_map(t_canvas *x) {
- gobj_subscribe(x,manager);
- canvas_redraw(x); /* lazy update implies deleting this */
- canvas_each(y,x) {
- if (y->_class==canvas_class && canvas_getcanvas((t_canvas *)y)==x) canvas_map((t_canvas *)y);
- gobj_changed(y,0); // could be made implicit
- }
- canvas_wires_each(oc,t,x) gobj_changed(oc,0); // this too
- }
-
static void canvas_vis(t_canvas *x, t_floatarg f) {
! int hadwindow = x->havewindow;
! /* if window contents have never been subscribed it should subscribe them here but it doesn't */
! SET(havewindow,!!f);
! if (!hadwindow && x->havewindow) canvas_map(x);
! // if (hadwindow && !x->havewindow) gobj_unsubscribe(x,manager);
}
--- 643,651 ----
t_symbol *canvas_makebindsym(t_symbol *s) {return symprintf("pd-%s",s->name);}
static void canvas_vis(t_canvas *x, t_floatarg f) {
! int hadwindow = x->havewindow;
! SET(havewindow,!!f);
! if (hadwindow && !x->havewindow) gobj_unsubscribe(x,manager);
! if (!hadwindow && x->havewindow) gobj_subscribe(x,manager);
}
***************
*** 661,666 ****
static void canvas_menu_open(t_canvas *x) {
if (canvas_isvisible(x) && !canvas_istoplevel(x)) {
! if (!x->owner) error("can't open a non-subcanvas");
! else SET(havewindow,1);
}
}
--- 653,658 ----
static void canvas_menu_open(t_canvas *x) {
if (canvas_isvisible(x) && !canvas_istoplevel(x)) {
! if (!x->owner) {error("can't open a non-subcanvas"); return;}
! SET(havewindow,1);
}
}
***************
*** 701,705 ****
obj_disconnect(t.from, t.outlet, t.to, t.inlet);
}
-
void canvas_deletelinesfor(t_canvas *x, t_text *text) {
canvas_wires_each(oc,t,x)
--- 693,696 ----
***************
*** 1978,1997 ****
void canvas_add(t_canvas *x, t_gobj *y) {
- //canvas_add_debug(x,y);
gobj_setcanvas(y,x);
y->g_next = 0;
y->dix->index = x->next_o_index++;
if (!x->list) x->list = y; else {
! //if (x->next_add<0) {
! t_gobj *y2;
! for (y2 = x->list; y2->g_next; y2=y2->g_next) {}
! y2->g_next = y;
! //} else {
! // int i=0;
! // t_gobj *y2;
! // for (y2 = x->list; y2->g_next; y2=y2->g_next, i++) if (i==x->next_add) break;
! // y->g_next = y2->g_next;
! // y2->g_next = y;
! //}
}
gobj_changed(x,"children");
--- 1969,1979 ----
void canvas_add(t_canvas *x, t_gobj *y) {
gobj_setcanvas(y,x);
y->g_next = 0;
y->dix->index = x->next_o_index++;
if (!x->list) x->list = y; else {
! t_gobj *y2;
! for (y2 = x->list; y2->g_next; y2=y2->g_next) {}
! y2->g_next = y;
}
gobj_changed(x,"children");
***************
*** 2005,2010 ****
bool chkdsp = !!zgetfn(y,gensym("dsp"));
int drawcommand = class_isdrawcommand(y->_class);
! /* if we're a drawing command, erase all scalars now, before deleting
! it; we'll redraw them once it's deleted below. */
if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(canvas_getcanvas(x)->name)), 2);
canvas_deletelinesfor(x,(t_text *)y);
--- 1987,1991 ----
bool chkdsp = !!zgetfn(y,gensym("dsp"));
int drawcommand = class_isdrawcommand(y->_class);
! /* if we're a drawing command, erase all scalars now, before deleting it; we'll redraw them once it's deleted below. */
if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(canvas_getcanvas(x)->name)), 2);
canvas_deletelinesfor(x,(t_text *)y);
***************
*** 6658,6666 ****
}
! void canvas_notice(t_gobj *x, struct _gobj *origin, int argc, t_atom *argv) {
t_canvas *self = (t_canvas *)x;
gobj_changed3(self,origin,argc,argv);
}
/* [declare] and canvas_open come from 0.40 */
/* ------------------------------- declare ------------------------ */
--- 6639,6655 ----
}
! void canvas_notice(t_gobj *x, t_gobj *origin, int argc, t_atom *argv) {
t_canvas *self = (t_canvas *)x;
gobj_changed3(self,origin,argc,argv);
}
+ void gobj_onsubscribe(t_gobj *x, t_gobj *observer) {gobj_changed(x,0);}
+
+ void canvas_onsubscribe(t_gobj *x, t_gobj *observer) {
+ t_canvas *self = (t_canvas *)x;
+ gobj_onsubscribe(x,observer);
+ canvas_each(y,self) y->_class->onsubscribe(y,observer);
+ }
+
/* [declare] and canvas_open come from 0.40 */
/* ------------------------------- declare ------------------------ */
***************
*** 6800,6803 ****
--- 6789,6793 ----
class_addcreator2("table",table_new,"SF");
class_addmethod2(c,canvas_close,"close","F");
+ class_addmethod2(c,canvas_redraw,"redraw","");
class_addmethod2(c,canvas_find_parent,"findparent","");
class_addmethod2(c,canvas_arraydialog,"arraydialog","sfff");
***************
*** 6826,6829 ****
--- 6816,6820 ----
class_addmethod2(pd_canvasmaker._class,canvas_with_reply,"with_reply","*");
class_setnotice(c, canvas_notice);
+ class_setonsubscribe(c, canvas_onsubscribe);
}