Update of /cvsroot/pure-data/externals/grill/flext/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24128/source
Modified Files: flattr_ed.cpp flbase.cpp flclass.h flsimd.cpp Log Message: fix for showing attributes on select (and recreate the object on edit)
Index: flattr_ed.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flattr_ed.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** flattr_ed.cpp 9 Nov 2004 03:31:34 -0000 1.25 --- flattr_ed.cpp 13 Nov 2004 03:30:49 -0000 1.26 *************** *** 42,45 **** --- 42,46 ---- #ifndef FLEXT_CLONEWIDGET static void (*ori_vis)(t_gobj *c, t_glist *, int vis) = NULL; + static void (*ori_select)(t_gobj *c, t_glist *, int state) = NULL; #endif
*************** *** 414,430 **** #ifndef FLEXT_CLONEWIDGET ori_vis = c->c_wb->w_visfn; widgetbehavior.w_getrectfn = c->c_wb->w_getrectfn; widgetbehavior.w_displacefn = c->c_wb->w_displacefn; - widgetbehavior.w_selectfn = c->c_wb->w_selectfn; widgetbehavior.w_activatefn = c->c_wb->w_activatefn; widgetbehavior.w_deletefn = c->c_wb->w_deletefn; widgetbehavior.w_clickfn = c->c_wb->w_clickfn; #else widgetbehavior.w_getrectfn = text_widgetbehavior.w_getrectfn; widgetbehavior.w_displacefn = text_widgetbehavior.w_displacefn; - widgetbehavior.w_selectfn = text_widgetbehavior.w_selectfn; widgetbehavior.w_activatefn = text_widgetbehavior.w_activatefn; widgetbehavior.w_deletefn = text_widgetbehavior.w_deletefn; widgetbehavior.w_clickfn = text_widgetbehavior.w_clickfn; #endif
--- 415,432 ---- #ifndef FLEXT_CLONEWIDGET ori_vis = c->c_wb->w_visfn; + ori_select = c->c_wb->w_selectfn; widgetbehavior.w_getrectfn = c->c_wb->w_getrectfn; widgetbehavior.w_displacefn = c->c_wb->w_displacefn; widgetbehavior.w_activatefn = c->c_wb->w_activatefn; widgetbehavior.w_deletefn = c->c_wb->w_deletefn; widgetbehavior.w_clickfn = c->c_wb->w_clickfn; + widgetbehavior.w_selectfn = c->c_wb->w_selectfn; #else widgetbehavior.w_getrectfn = text_widgetbehavior.w_getrectfn; widgetbehavior.w_displacefn = text_widgetbehavior.w_displacefn; widgetbehavior.w_activatefn = text_widgetbehavior.w_activatefn; widgetbehavior.w_deletefn = text_widgetbehavior.w_deletefn; widgetbehavior.w_clickfn = text_widgetbehavior.w_clickfn; + widgetbehavior.w_selectfn = text_widgetbehavior.w_selectfn; #endif
*************** *** 438,441 **** --- 440,444 ----
widgetbehavior.w_visfn = cb_GfxVis; + widgetbehavior.w_selectfn = cb_GfxSelect; class_setwidget(c, &widgetbehavior);
*************** *** 567,584 **** // show object if it's not a GOP if(!gl->gl_isgraph || gl->gl_havewindow) { ! t_text *x = (t_text *)c; FLEXT_ASSERT(x->te_binbuf);
! int argc = binbuf_getnatom(x->te_binbuf); ! t_atom *argv = binbuf_getvec(x->te_binbuf); ! int cnt = CheckAttrib(argc,argv);
! if(cnt) { ! t_binbuf *nb = binbuf_new(); ! binbuf_restore(nb,cnt,argv); ! binbuf_free(x->te_binbuf); ! x->te_binbuf = nb; ! }
t_rtext *rt = glist_findrtext(gl,x); --- 570,584 ---- // show object if it's not a GOP if(!gl->gl_isgraph || gl->gl_havewindow) { ! flext_base *th = thisObject(c); t_text *x = (t_text *)c; FLEXT_ASSERT(x->te_binbuf);
! t_binbuf *b = binbuf_new(); ! th->BinbufArgs(b,x->te_binbuf,true);
! // delete old object box text ! binbuf_free(x->te_binbuf); ! // set new one ! x->te_binbuf = b;
t_rtext *rt = glist_findrtext(gl,x); *************** *** 594,616 **** }
! static void BinbufAdd(t_binbuf *b,const t_atom &at) { ! char tbuf[MAXPDSTRING]; ! if(flext::IsString(at)) ! binbuf_addv(b,"s",flext::GetSymbol(at)); ! else if(flext::IsFloat(at)) ! binbuf_addv(b,"f",flext::GetFloat(at)); ! else if(flext::IsInt(at)) ! binbuf_addv(b,"i",flext::GetInt(at)); ! else if(at.a_type == A_DOLLAR) { ! sprintf(tbuf, "$%d", at.a_w.w_index); ! binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); ! } ! else if(at.a_type == A_DOLLSYM) { ! sprintf(tbuf, "$%s", at.a_w.w_symbol->s_name); ! binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); } - else - FLEXT_ASSERT(false); }
--- 594,631 ---- }
! void flext_base::cb_GfxSelect(t_gobj *c, struct _glist *gl, int state) { ! // show object if it's not a GOP ! if(!gl->gl_isgraph || gl->gl_havewindow) { ! if(state || !gl->gl_editor->e_textdirty) { ! // change text only on selection ! // OR if text has _not_ been changed ! // -> since object will not be recreated we have to get rid ! // of the attribute text ! ! flext_base *th = thisObject(c); ! t_text *x = (t_text *)c; ! FLEXT_ASSERT(x->te_binbuf); ! ! t_binbuf *b = binbuf_new(); ! th->BinbufArgs(b,x->te_binbuf,true); ! if(state) th->BinbufAttr(b); ! ! // delete old object box text ! binbuf_free(x->te_binbuf); ! // set new one ! x->te_binbuf = b; ! ! t_rtext *rt = glist_findrtext(gl,x); ! rtext_retext(rt); ! } ! ! // call original function ! #ifdef FLEXT_CLONEWIDGET ! text_widgetbehavior.w_selectfn(c,gl,state); ! #else ! ori_select(c,gl,state); ! #endif } }
*************** *** 621,686 **** binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"), t->te_xpix, t->te_ypix,MakeSymbol(th->thisName()));
! int argc = binbuf_getnatom(t->te_binbuf); ! t_atom *argv = binbuf_getvec(t->te_binbuf); ! int i,cnt = CheckAttrib(argc,argv); ! ! // process the creation arguments ! for(i = 1; i < cnt; ++i) BinbufAdd(b,argv[i]); ! // process the attributes ! AtomList la; ! th->ListAttrib(la); ! cnt = la.Count(); ! ! for(i = 0; i < cnt; ++i) { ! const t_symbol *sym = GetSymbol(la[i]); ! AtomList lv; ! const AtomList *lref = NULL; ! AttrDataCont::iterator it = th->attrdata->find(sym); ! ! if(it != th->attrdata->end()) { ! const AttrData &a = *it.data(); ! if(a.IsInit() && a.IsInitValue()) { ! lref = &a.GetInitValue(); ! /* ! // check for $-parameters ! lv = lref->Count(); ! for(int j = 0; j < lref->Count(); ++j) { ! const char *s = IsSymbol((*lref)[j])?GetString((*lref)[j]):NULL; ! if(s && s[0] == '$') { // TODO: More refined checking? ! // prepend a "" ! char tmp[256]; *tmp = '\'; ! strcpy(tmp+1,s); ! SetString(lv[j],tmp); ! } ! else ! lv[i] = (*lref)[j]; ! } ! ! lref = &lv; ! */ ! } ! else if(a.IsSaved()) { ! AttrItem *attr = th->FindAttrib(sym,true); ! ! // attribute must be gettable (so that the data can be retrieved) and puttable (so that the data can be inited) ! if(attr && attr->BothExist()) { ! th->GetAttrib(sym,attr,lv); ! lref = &lv; ! } ! } ! } ! ! if(lref) { ! char attrname[256]; *attrname= '@'; ! // store name ! strcpy(attrname+1,GetString(sym)); ! binbuf_addv(b,"s",MakeSymbol(attrname)); ! ! // store value ! for(int j = 0; j < lref->Count(); ++j) BinbufAdd(b,(*lref)[j]); ! } ! } ! binbuf_addv(b, ";"); } --- 636,644 ---- binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"), t->te_xpix, t->te_ypix,MakeSymbol(th->thisName()));
! // process the object arguments ! th->BinbufArgs(b,t->te_binbuf,false); // process the attributes ! th->BinbufAttr(b); ! // add end sign binbuf_addv(b, ";"); } *************** *** 753,755 **** --- 711,803 ---- }
+ + static void BinbufAdd(t_binbuf *b,const t_atom &at) + { + char tbuf[MAXPDSTRING]; + if(flext::IsString(at)) + binbuf_addv(b,"s",flext::GetSymbol(at)); + else if(flext::IsFloat(at)) + binbuf_addv(b,"f",flext::GetFloat(at)); + else if(flext::IsInt(at)) + binbuf_addv(b,"i",flext::GetInt(at)); + else if(at.a_type == A_DOLLAR) { + sprintf(tbuf, "$%d", at.a_w.w_index); + binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); + } + else if(at.a_type == A_DOLLSYM) { + sprintf(tbuf, "$%s", at.a_w.w_symbol->s_name); + binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); + } + else + FLEXT_ASSERT(false); + } + + void flext_base::BinbufArgs(t_binbuf *b,t_binbuf *args,bool withname) + { + int argc = binbuf_getnatom(args); + t_atom *argv = binbuf_getvec(args); + int i,cnt = CheckAttrib(argc,argv); + // process the creation arguments + for(i = withname?0:1; i < cnt; ++i) BinbufAdd(b,argv[i]); + } + + void flext_base::BinbufAttr(t_binbuf *b) + { + // process the attributes + AtomList la; + ListAttrib(la); + int i,cnt = la.Count(); + + for(i = 0; i < cnt; ++i) { + const t_symbol *sym = GetSymbol(la[i]); + AtomList lv; + const AtomList *lref = NULL; + AttrDataCont::iterator it = attrdata->find(sym); + + if(it != attrdata->end()) { + const AttrData &a = *it.data(); + if(a.IsInit() && a.IsInitValue()) { + lref = &a.GetInitValue(); + /* + // check for $-parameters + lv = lref->Count(); + for(int j = 0; j < lref->Count(); ++j) { + const char *s = IsSymbol((*lref)[j])?GetString((*lref)[j]):NULL; + if(s && s[0] == '$') { // TODO: More refined checking? + // prepend a "" + char tmp[256]; *tmp = '\'; + strcpy(tmp+1,s); + SetString(lv[j],tmp); + } + else + lv[i] = (*lref)[j]; + } + + lref = &lv; + */ + } + else if(a.IsSaved()) { + AttrItem *attr = FindAttrib(sym,true); + + // attribute must be gettable (so that the data can be retrieved) and puttable (so that the data can be inited) + if(attr && attr->BothExist()) { + GetAttrib(sym,attr,lv); + lref = &lv; + } + } + } + + if(lref) { + char attrname[256]; *attrname= '@'; + // store name + strcpy(attrname+1,GetString(sym)); + binbuf_addv(b,"s",MakeSymbol(attrname)); + + // store value + for(int j = 0; j < lref->Count(); ++j) BinbufAdd(b,(*lref)[j]); + } + } + } + #endif // FLEXT_SYS_PD +
Index: flsimd.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsimd.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** flsimd.cpp 26 Oct 2004 20:03:37 -0000 1.14 --- flsimd.cpp 13 Nov 2004 03:30:49 -0000 1.15 *************** *** 13,17 ****
If FLEXT_USE_SIMD is defined at compilation, SIMD instructions are used wherever feasible. ! If used with MSVC++ the "Processor Pack" must be installed.
If FLEXT_USE_IPP is defined the Intel Performance Package is used. --- 13,17 ----
If FLEXT_USE_SIMD is defined at compilation, SIMD instructions are used wherever feasible. ! If used with MSVC++ 6 the "Processor Pack" must be installed.
If FLEXT_USE_IPP is defined the Intel Performance Package is used.
Index: flbase.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbase.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** flbase.cpp 11 Aug 2004 04:04:25 -0000 1.18 --- flbase.cpp 13 Nov 2004 03:30:49 -0000 1.19 *************** *** 99,103 **** bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c) { ! #if FLEXT_SYS == FLEXT_SYS_PD if(!c) c = canvas_getcurrent();
--- 99,103 ---- bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c) { ! #if FLEXT_SYS == FLEXT_SYS_PD && defined(PD_MINOR_VERSION) && PD_MINOR_VERSION >= 37 if(!c) c = canvas_getcurrent();
Index: flclass.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flclass.h,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** flclass.h 11 Sep 2004 04:00:41 -0000 1.45 --- flclass.h 13 Nov 2004 03:30:49 -0000 1.46 *************** *** 862,865 **** --- 862,869 ---- static void cb_GfxVis(t_gobj *c, t_glist *gl, int vis); static void cb_GfxSave(t_gobj *c, t_binbuf *b); + static void cb_GfxSelect(t_gobj *x, struct _glist *glist, int state); + + void BinbufArgs(t_binbuf *b,t_binbuf *args,bool withname); + void BinbufAttr(t_binbuf *b); #endif