Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11762
Modified Files:
Tag: devel_0_39
desire.c
Log Message:
introducing glist_wire_each.
fix to canvas_vis and canvas_map.
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.147
retrieving revision 1.1.2.148
diff -C2 -d -r1.1.2.147 -r1.1.2.148
*** desire.c 4 Sep 2006 02:01:12 -0000 1.1.2.147
--- desire.c 5 Sep 2006 23:35:13 -0000 1.1.2.148
***************
*** 48,54 ****
#define template templaet
#define glist_each(CHILD,GLIST) for(CHILD=(GLIST)->gl_list; CHILD; CHILD=CHILD->g_next)
#define glists_each(GLIST,GLISTS) for(GLIST=GLISTS; GLIST; GLIST=GLIST->gl_next)
! #define class_addmethod3(_cl,_ptr,_str,_sig) class_addmethod2(_cl,(t_method)_ptr,gensym(_str),_sig)
--- 48,56 ----
#define template templaet
+ #define class_addmethod3(_cl,_ptr,_str,_sig) class_addmethod2(_cl,(t_method)_ptr,gensym(_str),_sig)
#define glist_each(CHILD,GLIST) for(CHILD=(GLIST)->gl_list; CHILD; CHILD=CHILD->g_next)
#define glists_each(GLIST,GLISTS) for(GLIST=GLISTS; GLIST; GLIST=GLIST->gl_next)
! #define glist_wire_each(WIRE,TRAV,GLIST) \
! for(linetraverser_start(&TRAV,GLIST); WIRE; WIRE=linetraverser_next(&TRAV))
***************
*** 576,582 ****
x->gl_x2 = x2; x->gl_y2 = y2; x->gl_obj.te_ypix = py1; x->gl_pixheight = py2-py1;
x->gl_font = (canvas_getcurrent() ? 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((t_pd *)x, canvas_makebindsym(x->gl_name));
x->gl_owner = g;
--- 578,582 ----
x->gl_x2 = x2; x->gl_y2 = y2; x->gl_obj.te_ypix = py1; x->gl_pixheight = py2-py1;
x->gl_font = (canvas_getcurrent() ? 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((t_pd *)x, canvas_makebindsym(x->gl_name));
x->gl_owner = g;
***************
*** 641,656 ****
called from the GUI after the fact to "notify" us that we're mapped. */
void canvas_map(t_canvas *x, t_floatarg f) {
! if (f!=0) {
! if (!glist_isvisible(x)) {
! t_gobj *y;
! if (!x->gl_havewindow) {bug("canvas_map"); canvas_vis(x,1);}
! glist_each(y,x) gobj_changed(y,0);
! x->gl_mapped = 1;
! canvas_drawlines(x);
! if (x->gl_isgraph && x->gl_goprect) canvas_drawredrect(x, 1);
! sys_mgui(x,"getscroll","");
! }
! } else {
! if (glist_isvisible(x)) {sys_mgui(x,"erase",""); x->gl_mapped=0;}
}
}
--- 641,656 ----
called from the GUI after the fact to "notify" us that we're mapped. */
void canvas_map(t_canvas *x, t_floatarg f) {
! if (f!=0 && !glist_isvisible(x)) {
! t_gobj *y;
! if (!x->gl_havewindow) {bug("canvas_map"); canvas_vis(x,1);}
! glist_each(y,x) gobj_changed(y,0);
! x->gl_mapped = 1;
! canvas_drawlines(x);
! if (x->gl_isgraph && x->gl_goprect) canvas_drawredrect(x, 1);
! }
! if (f==0 && glist_isvisible(x)) {
! sys_mgui(x,"delete_window","");
! x->gl_mapped = 0;
! gobj_unsubscribe((t_gobj *)x,(t_gobj *)manager);
}
}
***************
*** 711,741 ****
in front of all windows; or with "f" zero, when we want to get rid of the window. */
static void canvas_vis(t_canvas *x, t_floatarg f) {
! if (!!f) {
! if (x->gl_editor) { /* already visible, so just raise window */
! sys_mgui(x,"raise","");
! } else {
canvas_create_editor(x, 1);
x->gl_havewindow = 1;
gobj_subscribe((t_gobj *)x,(t_gobj *)manager);
gobj_changed(x,0);
! }
! } else { /* make invisible */
! 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;
! }
! if (glist_isvisible(x)) canvas_map(x, 0);
canvas_create_editor(x, 0);
! /* if we're a graph on our parent, and if the parent exists
! and is visible, show ourselves on parent. */
if (x->gl_isgraph && x->gl_owner) {
canvas_create_editor(x, 1);
x->gl_havewindow = 0;
- gobj_unsubscribe((t_gobj *)x,(t_gobj *)manager);
} else {
x->gl_havewindow = 0;
--- 711,728 ----
in front of all windows; or with "f" zero, when we want to get rid of the window. */
static void canvas_vis(t_canvas *x, t_floatarg f) {
! if (f && x->gl_editor) sys_mgui(x,"raise","");
! if (f && !x->gl_editor) {
canvas_create_editor(x, 1);
x->gl_havewindow = 1;
gobj_subscribe((t_gobj *)x,(t_gobj *)manager);
gobj_changed(x,0);
! }
! if (!f && x->gl_editor) {
canvas_create_editor(x, 0);
! if (glist_isvisible(x)) canvas_map(x, 0);
! /* if we're a graph on our parent and the parent exists and is visible, show ourselves on parent. */
if (x->gl_isgraph && x->gl_owner) {
canvas_create_editor(x, 1);
x->gl_havewindow = 0;
} else {
x->gl_havewindow = 0;
***************
*** 795,810 ****
static void canvas_drawlines(t_canvas *x) {
! t_linetraverser t;
! t_outconnect *oc;
! linetraverser_start(&t, x);
! while ((oc = linetraverser_next(&t))) 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) {
! t_linetraverser t;
! t_outconnect *oc;
! 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))
--- 782,793 ----
static void canvas_drawlines(t_canvas *x) {
! t_linetraverser t; t_outconnect *oc;
! glist_wire_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) {
! t_linetraverser t; t_outconnect *oc;
! glist_wire_each(oc,t,x)
if ((t.tr_ob == text && t.tr_outlet == outp) ||
(t.tr_ob2 == text && t.tr_inlet == inp))
***************
*** 813,820 ****
void canvas_deletelinesfor(t_canvas *x, t_text *text) {
! t_linetraverser t;
! t_outconnect *oc;
! linetraverser_start(&t, x);
! while ((oc = linetraverser_next(&t)))
if (t.tr_ob == text || t.tr_ob2 == text)
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
--- 796,801 ----
void canvas_deletelinesfor(t_canvas *x, t_text *text) {
! t_linetraverser t; t_outconnect *oc;
! glist_wire_each(oc,t,x)
if (t.tr_ob == text || t.tr_ob2 == text)
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
***************
*** 1040,1045 ****
static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp) {
! t_linetraverser t;
! t_outconnect *oc;
t_gobj *y;
t_object *ob;
--- 1021,1025 ----
static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp) {
! t_linetraverser t; t_outconnect *oc;
t_gobj *y;
t_object *ob;
***************
*** 1059,1064 ****
/* ... 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);
--- 1039,1043 ----
/* ... and all dsp interconnections */
! glist_wire_each(oc,t,x)
if (obj_issignaloutlet(t.tr_ob, t.tr_outno))
ugen_connect(dc, t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
***************
*** 1228,1240 ****
}
! void canvas_disconnect(t_canvas *x, float index1, float outno, float index2, float inno) {
! t_linetraverser t;
! t_outconnect *oc;
! linetraverser_start(&t, x);
! while ((oc = linetraverser_next(&t))) {
! int srcno = canvas_getindex(x, &t.tr_ob->ob_g);
! int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g);
! if (srcno == index1 && t.tr_outno == outno &&
! sinkno == index2 && t.tr_inno == inno) {
//sys_mgui(oc,"delete","");
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
--- 1207,1217 ----
}
! void canvas_disconnect(t_canvas *x, float from_, float outlet, float to_, float inlet) {
! t_linetraverser t; t_outconnect *oc;
! glist_wire_each(oc,t,x) {
! int from = canvas_getindex(x, &t.tr_ob->ob_g);
! int to = canvas_getindex(x, &t.tr_ob2->ob_g);
! if (from == from_ && t.tr_outno == outlet &&
! to == to_ && t.tr_inno == inlet) {
//sys_mgui(oc,"delete","");
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
***************
*** 1305,1314 ****
if (x->gl_pixwidth <= 0) x->gl_pixwidth = GLIST_DEFGRAPHWIDTH;
if (x->gl_pixheight <= 0) x->gl_pixheight = GLIST_DEFGRAPHHEIGHT;
- /*if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
- gobj_vis((t_gobj *)x, x->gl_owner, 0);*/
x->gl_isgraph = 1;
if (!nogoprect && !x->gl_goprect) {
t_gobj *g;
! for (g = x->gl_list; g; g = g->g_next) if (pd_checkobject(&g->g_pd)) {
x->gl_goprect = 1;
break;
--- 1282,1289 ----
if (x->gl_pixwidth <= 0) x->gl_pixwidth = GLIST_DEFGRAPHWIDTH;
if (x->gl_pixheight <= 0) x->gl_pixheight = GLIST_DEFGRAPHHEIGHT;
x->gl_isgraph = 1;
if (!nogoprect && !x->gl_goprect) {
t_gobj *g;
! glist_each(g,x) if (pd_checkobject(&g->g_pd)) {
x->gl_goprect = 1;
break;
***************
*** 1368,1375 ****
/* keep me */
static int canvas_isconnected (t_canvas *x, t_text *ob1, int n1, t_text *ob2, int n2) {
! t_linetraverser t;
! t_outconnect *oc;
! linetraverser_start(&t, x);
! while ((oc = linetraverser_next(&t)))
if (t.tr_ob == ob1 && t.tr_outno == n1 &&
t.tr_ob2 == ob2 && t.tr_inno == n2)
--- 1343,1348 ----
/* keep me */
static int canvas_isconnected (t_canvas *x, t_text *ob1, int n1, t_text *ob2, int n2) {
! t_linetraverser t; t_outconnect *oc;
! glist_wire_each(oc,t,x)
if (t.tr_ob == ob1 && t.tr_outno == n1 &&
t.tr_ob2 == ob2 && t.tr_inno == n2)
***************
*** 1478,1483 ****
static void canvas_stowconnections(t_canvas *x, t_gobj *o) {
t_gobj *selhead = 0, *seltail = 0, *nonhead = 0, *nontail = 0, *y, *y2;
! t_linetraverser t;
! t_outconnect *oc;
t_binbuf *b;
if (!x->gl_editor) {error("canvas_stowconnections without editor"); return;}
--- 1451,1455 ----
static void canvas_stowconnections(t_canvas *x, t_gobj *o) {
t_gobj *selhead = 0, *seltail = 0, *nonhead = 0, *nontail = 0, *y, *y2;
! t_linetraverser t; t_outconnect *oc;
t_binbuf *b;
if (!x->gl_editor) {error("canvas_stowconnections without editor"); return;}
***************
*** 1500,1505 ****
/* add connections to binbuf */
binbuf_clear(b);
! linetraverser_start(&t, x);
! while ((oc = linetraverser_next(&t))) {
/*int s1 = glist_isselected(x, &t.tr_ob->ob_g);*/
/*int s2 = glist_isselected(x, &t.tr_ob2->ob_g);*/
--- 1472,1476 ----
/* add connections to binbuf */
binbuf_clear(b);
! glist_wire_each(oc,t,x) {
/*int s1 = glist_isselected(x, &t.tr_ob->ob_g);*/
/*int s2 = glist_isselected(x, &t.tr_ob2->ob_g);*/
***************
*** 3619,3629 ****
static void canvas_saveto(t_canvas *x, t_binbuf *b) {
t_gobj *y;
- t_linetraverser t;
- t_outconnect *oc;
canvas_savecontainerto(x,b);
glist_each(y,x) gobj_save(y, b);
! linetraverser_start(&t, x);
! while ((oc = linetraverser_next(&t))) {
int from = canvas_getindex(x, &t.tr_ob->ob_g);
int to = canvas_getindex(x, &t.tr_ob2->ob_g);
--- 3590,3598 ----
static void canvas_saveto(t_canvas *x, t_binbuf *b) {
+ t_linetraverser t; t_outconnect *oc;
t_gobj *y;
canvas_savecontainerto(x,b);
glist_each(y,x) gobj_save(y, b);
! glist_wire_each(oc,t,x) {
int from = canvas_getindex(x, &t.tr_ob->ob_g);
int to = canvas_getindex(x, &t.tr_ob2->ob_g);
***************
*** 7759,7771 ****
char *bar;
t_canvas *can = (t_canvas *)self;
! t_linetraverser t;
! t_outconnect *oc;
t_gobj *y;
bar=foo; *foo=0;
- linetraverser_start(&t,can);
glist_each(y,can) bar+=sprintf(bar,"x%lx ",(long)y);
sys_mgui((t_gobj *)self,"children=","S",foo);
bar=foo; *foo=0;
! while((oc = linetraverser_next(&t))) bar+=sprintf(bar,"{%ld %ld %ld %ld} ",
(long)canvas_getindex(can,(t_gobj *)t.tr_ob), (long)t.tr_outno,
(long)canvas_getindex(can,(t_gobj *)t.tr_ob2), (long)t.tr_inno);
--- 7728,7738 ----
char *bar;
t_canvas *can = (t_canvas *)self;
! t_linetraverser t; t_outconnect *oc;
t_gobj *y;
bar=foo; *foo=0;
glist_each(y,can) bar+=sprintf(bar,"x%lx ",(long)y);
sys_mgui((t_gobj *)self,"children=","S",foo);
bar=foo; *foo=0;
! glist_wire_each(oc,t,can) bar+=sprintf(bar,"{%ld %ld %ld %ld} ",
(long)canvas_getindex(can,(t_gobj *)t.tr_ob), (long)t.tr_outno,
(long)canvas_getindex(can,(t_gobj *)t.tr_ob2), (long)t.tr_inno);
***************
*** 8704,8709 ****
void canvas_notice(t_gobj *x, struct _gobj *origin, int argc, t_atom *argv) {
t_canvas *self = (t_canvas *)x;
- /*post("canvas_notice(%p,%p,%d,...): havewindow=%d mapped=%d",
- x,origin,argc,self->gl_havewindow,self->gl_mapped);*/
gobj_changed3(self,origin,argc,argv);
}
--- 8671,8674 ----
***************
*** 8737,8741 ****
class_addmethod3(c,canvas_mycnv,"mycnv","*");
class_addmethod3(c,canvas_numbox,"numbox","*");
- //class_addmethod3(c,canvas_wire,"wire","*");
class_addmethod3(c,canvas_pop,"pop","F");
--- 8702,8705 ----
***************
*** 8747,8752 ****
class_addmethod3(c,glist_clear,"clear","");
! class_addcreator((t_newmethod)subcanvas_new,gensym("pd"), A_DEFSYMBOL, 0);
! class_addcreator((t_newmethod)subcanvas_new, gensym("page"), A_DEFSYMBOL, 0);
class_addmethod3(c,canvas_dsp,"dsp","");
class_addmethod3(c,canvas_rename_method,"rename","*");
--- 8711,8716 ----
class_addmethod3(c,glist_clear,"clear","");
! class_addcreator((t_newmethod)subcanvas_new, gensym("pd"), A_DEFSYMBOL, 0);
! class_addcreator((t_newmethod)subcanvas_new, gensym("page"), A_DEFSYMBOL, 0);
class_addmethod3(c,canvas_dsp,"dsp","");
class_addmethod3(c,canvas_rename_method,"rename","*");
***************
*** 8979,8980 ****
--- 8943,8945 ----
}
}
+