diff options
Diffstat (limited to 'externals/grill/flext/source')
-rw-r--r-- | externals/grill/flext/source/flatom.cpp | 13 | ||||
-rw-r--r-- | externals/grill/flext/source/flatom_pr.cpp | 19 | ||||
-rw-r--r-- | externals/grill/flext/source/flattr.cpp | 16 | ||||
-rw-r--r-- | externals/grill/flext/source/flattr_ed.cpp | 126 | ||||
-rw-r--r-- | externals/grill/flext/source/flbase.h | 7 | ||||
-rw-r--r-- | externals/grill/flext/source/flbuf.cpp | 2 | ||||
-rw-r--r-- | externals/grill/flext/source/flclass.h | 5 | ||||
-rw-r--r-- | externals/grill/flext/source/fldefs_attrcb.h | 12 | ||||
-rw-r--r-- | externals/grill/flext/source/fldefs_attrvar.h | 8 | ||||
-rwxr-xr-x | externals/grill/flext/source/flmeth.cpp | 3 | ||||
-rw-r--r-- | externals/grill/flext/source/flstdc.h | 7 | ||||
-rw-r--r-- | externals/grill/flext/source/flsupport.h | 6 |
12 files changed, 171 insertions, 53 deletions
diff --git a/externals/grill/flext/source/flatom.cpp b/externals/grill/flext/source/flatom.cpp index afed8dec..45739e66 100644 --- a/externals/grill/flext/source/flatom.cpp +++ b/externals/grill/flext/source/flatom.cpp @@ -91,19 +91,6 @@ int flext::AtomList::Compare(const AtomList &a) const return Count() < a.Count()?-1:1; } -std::string flext::AtomList::Print() const -{ - char buffer[256]; - std::string ret; - for(int i = 0; i < Count(); ++i) { - char *b = buffer; - if(i) *(b++) = ' '; // prepend space - PrintAtom((*this)[i],b,sizeof buffer-1); - ret += buffer; - } - return ret; -} - #if FLEXT_SYS != FLEXT_SYS_JMAX // not for jmax as long as t_symbol * == char * diff --git a/externals/grill/flext/source/flatom_pr.cpp b/externals/grill/flext/source/flatom_pr.cpp index 639bca63..e700df8a 100644 --- a/externals/grill/flext/source/flatom_pr.cpp +++ b/externals/grill/flext/source/flatom_pr.cpp @@ -19,7 +19,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include <stdio.h> // \TODO take bufsz into account! -void flext::PrintAtom(const t_atom &a,char *buf,int bufsz) +bool flext::PrintAtom(const t_atom &a,char *buf,int bufsz) { if(IsFloat(a)) { sprintf(buf,"%g",GetFloat(a)); @@ -35,8 +35,25 @@ void flext::PrintAtom(const t_atom &a,char *buf,int bufsz) } else ERRINTERNAL(); + return true; } +bool flext::AtomList::Print(char *buffer,int buflen) const +{ + bool ok = true; + for(int i = 0; ok && i < Count(); ++i) { + if(i) { *(buffer++) = ' '; --buflen; } // prepend space + if(PrintAtom((*this)[i],buffer,buflen)) { + int len = strlen(buffer); + buffer += len,buflen -= len; + } + else + ok = false; + } + return ok; +} + + bool flext::ScanAtom(t_atom &a,const char *buf) { // skip whitespace diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp index e754c87b..6a8dafeb 100644 --- a/externals/grill/flext/source/flattr.cpp +++ b/externals/grill/flext/source/flattr.cpp @@ -120,7 +120,8 @@ void flext_base::ListAttrib(AtomList &la) const typedef std::set<AttrItem *,attrless> AttrList; AttrList list[2]; - for(int i = 0; i <= 1; ++i) { + int i; + for(i = 0; i <= 1; ++i) { ItemCont *a = i?attrhead:clattrhead; if(a) { for(int ai = 0; ai < a->Size(); ++ai) { @@ -246,6 +247,13 @@ bool flext_base::SetAttrib(AttrItem *a,int argc,const t_atom *argv) } else ok = false; break; + case a_bool: + if(argc == 1 && CanbeBool(argv[0])) { + any.bt = GetABool(argv[0]); + ((methfun_1)a->fun)(this,any); + } + else ok = false; + break; case a_LIST: any.vt = &(la(argc,argv)); ((methfun_1)a->fun)(this,any); @@ -283,6 +291,12 @@ bool flext_base::GetAttrib(AttrItem *a,AtomList &la) const SetInt(la[0],any.it); break; } + case a_bool: { + ((methfun_1)a->fun)(const_cast<flext_base *>(this),any); + la(1); + SetBool(la[0],any.bt); + break; + } case a_symbol: { ((methfun_1)a->fun)(const_cast<flext_base *>(this),any); la(1); diff --git a/externals/grill/flext/source/flattr_ed.cpp b/externals/grill/flext/source/flattr_ed.cpp index 0722ea10..a52de29f 100644 --- a/externals/grill/flext/source/flattr_ed.cpp +++ b/externals/grill/flext/source/flattr_ed.cpp @@ -16,35 +16,54 @@ WARRANTIES, see the file, "license.txt," in this distribution. #if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT) +#ifdef PD_DEVEL_VERSION +#define FLEXT_CLONEWIDGET +#endif + #ifdef _MSC_VER #pragma warning( disable : 4091 ) #endif +#ifndef FLEXT_CLONEWIDGET // This is problematic... non-public headers! -// compilation may be specific for one version of PD!! +// compilation is specific for a compiled version!! #include <m_imp.h> +#endif + #include <g_canvas.h> #include <string.h> #include <stdio.h> static t_widgetbehavior widgetbehavior; + +#ifndef FLEXT_CLONEWIDGET static void (*ori_vis)(t_gobj *c, t_glist *, int vis) = NULL; +#endif void flext_base::SetAttrEditor(t_classid c) { // widgetbehavior struct MUST be resident... (static is just ok here) - widgetbehavior.w_getrectfn = c->c_wb->w_getrectfn; +#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; - ori_vis = c->c_wb->w_visfn; - widgetbehavior.w_visfn = cb_GfxVis; 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 widgetbehavior.w_propertiesfn = cb_GfxProperties; widgetbehavior.w_savefn = cb_GfxSave; + widgetbehavior.w_visfn = cb_GfxVis; class_setwidget(c, &widgetbehavior); @@ -120,7 +139,7 @@ void flext_base::SetAttrEditor(t_classid c) "proc pdtk_flext_dialog {id title attrlist} {\n" "set vid [string trimleft $id .]\n" - "set alen [expr [llength $attrlist] / 5 ]\n" + "set alen [expr [llength $attrlist] / 6 ]\n" "toplevel $id\n" "wm title $id $title\n" @@ -152,7 +171,7 @@ void flext_base::SetAttrEditor(t_classid c) "incr row\n" "set ix 1\n" - "foreach {an av ai asv afl} $attrlist {\n" + "foreach {an av ai atp asv afl} $attrlist {\n" // get attribute name "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n" "global $var_attr_name\n" @@ -187,13 +206,31 @@ void flext_base::SetAttrEditor(t_classid c) "if { $afl != 0 } {\n" // attribute is puttable + // entry field for initial value // entry field for current value - "entry $id.val-$ix -textvariable $var_attr_val\n" - "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n" - // entry field for initial value - "entry $id.init-$ix -textvariable $var_attr_init\n" + // choose entry field type + "switch $atp {\n" + "0 - 1 {\n" // int or float + "entry $id.init-$ix -textvariable $var_attr_init\n" + "entry $id.val-$ix -textvariable $var_attr_val\n" + "}\n" + "2 {\n" // boolean + "checkbutton $id.init-$ix -variable $var_attr_init\n" + "checkbutton $id.val-$ix -variable $var_attr_val\n" + "}\n" + "3 {\n" // symbol + "entry $id.init-$ix -textvariable $var_attr_init\n" + "entry $id.val-$ix -textvariable $var_attr_val\n" + "}\n" + "4 - 5 {\n" // list or unknown + "entry $id.init-$ix -textvariable $var_attr_init\n" + "entry $id.val-$ix -textvariable $var_attr_val\n" + "}\n" + "}\n" + "grid config $id.init-$ix -column 1 -row $row -padx 5 -sticky {ew}\n" + "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n" "button $id.b2i-$ix -text {<-} -height 1 -command \" flext_copyval $var_attr_init $var_attr_val \"\n" "grid config $id.b2i-$ix -column 2 -row $row -sticky {ew}\n" @@ -212,7 +249,24 @@ void flext_base::SetAttrEditor(t_classid c) // attribute is gettable only // entry field for current value (read-only) - "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + + // choose display field type + "switch $atp {\n" + "0 - 1 {\n" // int or float + "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + "}\n" + "2 {\n" // boolean + "checkbutton $id.val-$ix -variable $var_attr_val -state disabled\n" + "}\n" + "3 {\n" // symbol + "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + "}\n" + "4 - 5 {\n" // list or unknown + "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + "}\n" + "}\n" + +// "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n" "label $id.readonly-$ix -text \"read-only\"\n" @@ -293,6 +347,12 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) for(int i = 0; i < cnt; ++i) { const t_symbol *sym = GetSymbol(la[i]); + const char *bcur = b; + + // get attribute + AttrItem *gattr = th->FindAttrib(sym,true); + // get puttable attribute + AttrItem *pattr = gattr?gattr->Counterpart():th->FindAttrib(sym,false); // get flags int sv; @@ -308,14 +368,25 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) sv = 1; else sv = 0; - initdata = a.IsInitValue()?&a.GetInitValue():NULL; } - STD::sprintf(b,"%s {",GetString(sym)); b += strlen(b); + // get attribute type + int tp; + bool list; + switch((gattr?gattr:pattr)->argtp) { + case a_int: tp = 0; list = false; break; + case a_float: tp = 1; list = false; break; + case a_bool: tp = 2; list = false; break; + case a_symbol: tp = 3; list = true; break; + case a_list: + case a_LIST: tp = 4; list = true; break; + default: + tp = 5; list = true; + FLEXT_ASSERT(false); + } - // get attribute - AttrItem *gattr = th->FindAttrib(sym,true); + STD::sprintf(b,list?"%s {":"%s ",GetString(sym)); b += strlen(b); AtomList lv; if(gattr) { // gettable attribute is present @@ -324,11 +395,11 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) b += PrintList(b,lv.Count(),lv.Atoms()); } + else { + strcpy(b,"{}"); b += strlen(b); + } - STD::sprintf(b, "} {"); b += strlen(b); - - // get puttable attribute - AttrItem *pattr = gattr->Counterpart(); + strcpy(b, list?"} {":" "); b += strlen(b); if(pattr) { // if there is initialization data take this, otherwise take the current data @@ -336,8 +407,12 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) b += PrintList(b,lp.Count(),lp.Atoms()); } + else { + strcpy(b,"{}"); b += strlen(b); + } + - STD::sprintf(b, "} %i %i ", sv,pattr?(pattr->BothExist()?2:1):0); b += strlen(b); + STD::sprintf(b, list?"} %i %i %i ":" %i %i %i ",tp,sv,pattr?(pattr->BothExist()?2:1):0); b += strlen(b); } strcpy(b, " }\n"); @@ -348,8 +423,8 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) //! Strip the attributes off the object command line void flext_base::cb_GfxVis(t_gobj *c, t_glist *gl, int vis) { - flext_base *th = thisObject(c); - t_text *x = (t_text *)th->thisHdr(); + t_text *x = (t_text *)c; + FLEXT_ASSERT(x->te_binbuf); int argc = binbuf_getnatom(x->te_binbuf); @@ -363,7 +438,14 @@ void flext_base::cb_GfxVis(t_gobj *c, t_glist *gl, int vis) x->te_binbuf = nb; } + t_rtext *rt = glist_findrtext(gl,x); + rtext_retext(rt); + +#ifdef FLEXT_CLONEWIDGET + text_widgetbehavior.w_visfn(c,gl,vis); +#else ori_vis(c,gl,vis); +#endif } static void BinbufAdd(t_binbuf *b,const t_atom &at) diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h index eec2e520..795c0673 100644 --- a/externals/grill/flext/source/flbase.h +++ b/externals/grill/flext/source/flbase.h @@ -21,13 +21,6 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flsupport.h" -// ----- disable attribute editor for PD version < devel_0_36 or 0.37 -#ifndef PD_MAJOR_VERSION -#undef FLEXT_NOATTREDIT -#define FLEXT_NOATTREDIT -#endif - - class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj); typedef class FLEXT_CLASSDEF(flext_obj) flext_obj; diff --git a/externals/grill/flext/source/flbuf.cpp b/externals/grill/flext/source/flbuf.cpp index 2a1878d3..bb602779 100644 --- a/externals/grill/flext/source/flbuf.cpp +++ b/externals/grill/flext/source/flbuf.cpp @@ -25,7 +25,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #endif // check if PD API supports buffer dirty time -#if defined(PD_VERSION_DEVEL) && defined(PD_MAJOR_VERSION) && defined(PD_MINOR_VERSION) +#if defined(PD_DEVEL_VERSION) && defined(PD_MAJOR_VERSION) && defined(PD_MINOR_VERSION) #if PD_MINOR_VERSION >= 36 #define FLEXT_PDBUFDIRTYTIME #endif diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index f4328d1e..11661d67 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -314,7 +314,7 @@ public: enum metharg { a_null = 0, - a_float,a_int, + a_float,a_int,a_bool, a_symbol,a_pointer, a_list,a_any, // (t_symbol *) / int / t_atom * a_LIST,a_ANY // AtomList, AtomAnything @@ -505,6 +505,7 @@ protected: void AddAttrib(const char *attr,bool (*get)(flext_base *,float &),bool (*set)(flext_base *,float &)) { AddAttrib(attr,a_float,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,int &),bool (*set)(flext_base *,int &)) { AddAttrib(attr,a_int,(methfun)get,(methfun)set); } + void AddAttrib(const char *attr,bool (*get)(flext_base *,bool &),bool (*set)(flext_base *,bool &)) { AddAttrib(attr,a_bool,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,const t_symbol *&),bool (*set)(flext_base *,const t_symbol *&)) { AddAttrib(attr,a_symbol,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,t_symptr &),bool (*set)(flext_base *,t_symptr &)) { AddAttrib(attr,a_symbol,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,AtomList *&),bool (*set)(flext_base *,AtomList *&)) { AddAttrib(attr,a_LIST,(methfun)get,(methfun)set); } @@ -518,6 +519,7 @@ protected: static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,float &),bool (*set)(flext_base *,float &)) { AddAttrib(c,attr,a_float,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,int &),bool (*set)(flext_base *,int &)) { AddAttrib(c,attr,a_int,(methfun)get,(methfun)set); } + static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,bool &),bool (*set)(flext_base *,bool &)) { AddAttrib(c,attr,a_bool,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,const t_symbol *&),bool (*set)(flext_base *,const t_symbol *&)) { AddAttrib(c,attr,a_symbol,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,t_symptr &),bool (*set)(flext_base *,t_symptr &)) { AddAttrib(c,attr,a_symbol,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,AtomList *&),bool (*set)(flext_base *,AtomList *&)) { AddAttrib(c,attr,a_LIST,(methfun)get,(methfun)set); } @@ -764,6 +766,7 @@ private: union t_any { float ft; int it; + bool bt; t_symbol *st; #if FLEXT_SYS == FLEXT_SYS_PD t_gpointer *pt; diff --git a/externals/grill/flext/source/fldefs_attrcb.h b/externals/grill/flext/source/fldefs_attrcb.h index 4e2fc700..1c147613 100644 --- a/externals/grill/flext/source/fldefs_attrcb.h +++ b/externals/grill/flext/source/fldefs_attrcb.h @@ -49,9 +49,13 @@ FLEXT_CALLSET_(SFUN,float) FLEXT_CALLSET_(SFUN,int) //! Declare a set function for a boolean attribute -#define FLEXT_CALLSET_B(FUN) \ +#define FLEXT_CALLSET_B(SFUN) \ +\ +FLEXT_CALLSET_(SFUN,bool) +/* static bool FLEXT_SET_PRE(FUN)(flext_base *c,int &arg) \ { bool b = arg != 0; FLEXT_CAST<thisType *>(c)->FUN(b); return true; } +*/ //! Declare a set function for an enum attribute #define FLEXT_CALLSET_E(SFUN,TP) \ @@ -85,9 +89,13 @@ FLEXT_CALLGET_(GFUN,float) FLEXT_CALLGET_(GFUN,int) //! Declare a get function for a boolean attribute -#define FLEXT_CALLGET_B(FUN) \ +#define FLEXT_CALLGET_B(GFUN) \ +\ +FLEXT_CALLGET_(GFUN,bool) +/* static bool FLEXT_GET_PRE(FUN)(flext_base *c,int &arg) \ { bool b; FLEXT_CAST<thisType *>(c)->FUN(b); arg = b?1:0; return true; } +*/ //! Declare a get function for an enum attribute #define FLEXT_CALLGET_E(GFUN,TP) \ diff --git a/externals/grill/flext/source/fldefs_attrvar.h b/externals/grill/flext/source/fldefs_attrvar.h index f0a04987..89592c29 100644 --- a/externals/grill/flext/source/fldefs_attrvar.h +++ b/externals/grill/flext/source/fldefs_attrvar.h @@ -54,8 +54,12 @@ FLEXT_ATTRSET_(VAR,const t_symbol *) //! Declare an implicite set function for a boolean attribute #define FLEXT_ATTRSET_B(VAR) \ +\ +FLEXT_ATTRSET_(VAR,bool) +/* static bool FLEXT_SET_PRE(VAR)(flext_base *c,int &arg) \ { FLEXT_CAST<thisType *>(c)->VAR = arg != 0; return true; } +*/ //! Declare an implicite set function for an enum attribute #define FLEXT_ATTRSET_E(VAR,TP) \ @@ -90,8 +94,12 @@ FLEXT_ATTRGET_(VAR,const t_symbol *) //! Declare an implicite get function for a boolean attribute #define FLEXT_ATTRGET_B(VAR) \ +\ +FLEXT_ATTRGET_(VAR,bool) +/* static bool FLEXT_GET_PRE(VAR)(flext_base *c,int &arg) \ { arg = FLEXT_CAST<thisType *>(c)->VAR?1:0; return true; } +*/ //! Declare an implicite get function for an enum attribute #define FLEXT_ATTRGET_E(VAR,TP) \ diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp index e911d563..ce49b5c5 100755 --- a/externals/grill/flext/source/flmeth.cpp +++ b/externals/grill/flext/source/flmeth.cpp @@ -108,7 +108,8 @@ void flext_base::ListMethods(AtomList &la,int inlet) const typedef std::set<MethItem *,methless> MethList; MethList list[2]; - for(int i = 0; i <= 1; ++i) { + int i; + for(i = 0; i <= 1; ++i) { ItemCont *a = i?methhead:clmethhead; if(a) { for(int ai = 0; ai < a->Size(); ++ai) { diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h index e45da76a..36fe8e15 100644 --- a/externals/grill/flext/source/flstdc.h +++ b/externals/grill/flext/source/flstdc.h @@ -229,4 +229,11 @@ typedef t_symbol *t_symptr; #define FLEXT_EXT #endif +// ----- disable attribute editor for PD version < devel_0_36 or 0.37 +#ifndef PD_MAJOR_VERSION +#undef FLEXT_NOATTREDIT +#define FLEXT_NOATTREDIT +#endif + + #endif diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index 60b7db3d..f0b3d34f 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -17,8 +17,6 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flstdc.h" -#include <string> - class FLEXT_SHARE FLEXT_CLASSDEF(flext); typedef class FLEXT_CLASSDEF(flext) flext; @@ -212,7 +210,7 @@ public: static void CopyAtom(t_atom *dst,const t_atom *src) { *dst = *src; } //! Print an atom - static void PrintAtom(const t_atom &a,char *buf,int bufsz = 0); + static bool PrintAtom(const t_atom &a,char *buf,int bufsz); //! Scan an atom static bool ScanAtom(t_atom &a,const char *buf); @@ -526,7 +524,7 @@ public: AtomList &Part(int offs,int len) { return (*this = GetPart(offs,len)); } //! Represent as a string - std::string Print() const; + bool Print(char *buffer,int buflen) const; protected: int cnt; |