aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/flext')
-rw-r--r--externals/grill/flext/changes.txt10
-rw-r--r--externals/grill/flext/flext.vcproj18
-rw-r--r--externals/grill/flext/source/flattr.cpp8
-rw-r--r--externals/grill/flext/source/flattr_ed.cpp178
-rw-r--r--externals/grill/flext/source/flext.cpp5
5 files changed, 120 insertions, 99 deletions
diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt
index 1a910d4b..d39e882e 100644
--- a/externals/grill/flext/changes.txt
+++ b/externals/grill/flext/changes.txt
@@ -23,6 +23,11 @@ Version history:
- removed Mach-O/CFM glue stuff again and added makefiles for Max/MachO
- in flext::StopThread don't wait for thread to have stopped!
- support PD tooltips (only in devel branch at the moment)
+- attribute editor: added individual apply buttons
+- attribute editor: added escaping for , and ;
+- attribute editor: zoomed editor accepts , as newline separator
+- attribute editor: close editor window on object destruction
+- fixed $0-arguments in attribute saving
0.4.6:
- added a text edit window for list attributes
@@ -302,15 +307,12 @@ TODO list:
for 0.4.7:
- SIMD for gcc
-- individual apply buttons for each attribute in the attribute editor
- Max/MSP MachO support
bugs:
- recreation of object with different argument line forgets about eventually present attributes
-- deletion of object with open attribute editor: press apply -> crash
-
-- attributes and attribute editor saving with patcher arguments (like $0-gugu )
+TEST:
- PD: problems with timed buffer redrawing (takes a lot of cpu time)
- hard thread termination upon object destruction doesn't seem to work properly -> crash
- Max rounding bug ... buffer resize could be one sample less!
diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj
index 92f76c1b..1d31e557 100644
--- a/externals/grill/flext/flext.vcproj
+++ b/externals/grill/flext/flext.vcproj
@@ -347,13 +347,14 @@
AdditionalLibraryDirectories="f:\prog\pd\pd-cvs\bin;f:\prog\packs\pthreads;F:\prog\audio\stk\lib;F:\prog\audio\sndobj\lib"
GenerateDebugInformation="TRUE"
OptimizeReferences="1"
- ImportLibrary="./pd-msvc/flext_ld.lib"/>
+ ImportLibrary="./pd-msvc/flext_ld.lib"
+ TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
- Description="copy flext to maestra"
- CommandLine="copy F:\prog\max\flext\pd-msvc\flext_d.dll f:\prog\maestra\dev\debug"/>
+ Description="copy flext to vibrez"
+ CommandLine="copy F:\prog\max\flext\pd-msvc\flext_d.dll f:\prog\vibrez\debug"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
@@ -410,15 +411,16 @@
AdditionalLibraryDirectories="f:\prog\packs\pthreads;&quot;f:\prog\pd\pd-cvs\bin&quot;;F:\prog\audio\stk\lib;F:\prog\audio\sndobj\lib"
GenerateDebugInformation="FALSE"
OptimizeReferences="1"
- ImportLibrary="./pd-msvc/flext_l.lib"/>
+ ImportLibrary="./pd-msvc/flext_l.lib"
+ TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
- Description="copy flext to maestra"
- CommandLine="copy F:\prog\max\flext\source\*.h f:\prog\maestra\dev\api\include
-copy F:\prog\max\flext\pd-msvc\flext_l.lib f:\prog\maestra\dev\api\lib
-copy F:\prog\max\flext\pd-msvc\flext.dll f:\prog\maestra\dev\release
+ Description="copy flext to vibrez"
+ CommandLine="copy F:\prog\max\flext\source\*.h f:\prog\vibrez\api\include
+copy F:\prog\max\flext\pd-msvc\flext_l.lib f:\prog\vibrez\api\lib
+copy F:\prog\max\flext\pd-msvc\flext.dll f:\prog\vibrez\release
copy F:\prog\max\flext\pd-msvc\flext.dll f:\prog\dll
"/>
<Tool
diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp
index 30b8fea1..b40a5807 100644
--- a/externals/grill/flext/source/flattr.cpp
+++ b/externals/grill/flext/source/flattr.cpp
@@ -48,6 +48,8 @@ void flext_base::AddAttrib(ItemCont *aa,ItemCont *ma,const char *attr,metharg tp
const t_symbol *asym = MakeSymbol(attr);
AttrItem *a,*b;
+ FLEXT_ASSERT(asym != sym__ && asym != sym_list && asym != sym_float && asym != sym_symbol && asym != sym_anything);
+
if(sfun) // if commented out, there will be a warning at run-time (more user-friendly)
{
a = new AttrItem(asym,tp,sfun,AttrItem::afl_set);
@@ -238,9 +240,9 @@ bool flext_base::SetAttrib(const t_symbol *tag,AttrItem *a,int argc,const t_atom
break;
case a_symbol:
if(argc == 1 && IsSymbol(argv[0])) {
- // \todo shall we analyze the patcher args????
-// any.st = const_cast<t_symbol *>(GetParamSym(GetSymbol(argv[0]),thisCanvas()));
- any.st = GetSymbol(argv[0]);
+ t_atom at;
+ GetParamSym(at,GetSymbol(argv[0]),thisCanvas());
+ any.st = const_cast<t_symbol *>(GetSymbol(at));
((methfun_1)a->fun)(this,any);
}
else ok = false;
diff --git a/externals/grill/flext/source/flattr_ed.cpp b/externals/grill/flext/source/flattr_ed.cpp
index 8a4b98f5..ff922897 100644
--- a/externals/grill/flext/source/flattr_ed.cpp
+++ b/externals/grill/flext/source/flattr_ed.cpp
@@ -78,72 +78,75 @@ void flext_base::SetAttrEditor(t_classid c)
// generate the script for the property dialog
sys_gui(
- "proc flext_apply {id alen} {\n"
+ "proc flext_escatoms {lst} {\n"
+ "set tmp {}\n"
+ "foreach a $lst {\n"
+ "set a [regsub {\\$} $a \\\\$]\n" // replace $ with \$
+ "set a [regsub {,} $a \\\\,]\n" // replace , with \,
+ "set a [regsub {;} $a \\\\\\;]\n" // replace ; with \;
+ "lappend tmp $a\n"
+ "}\n"
+ "return $tmp\n"
+ "}\n"
+
+ "proc flext_makevalue {id ix} {\n"
// strip "." from the TK id to make a variable name suffix
"set vid [string trimleft $id .]\n"
- // make a list of the attribute values (including save flags)
+ "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n"
+ "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n"
+ "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n"
+ "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n"
+ "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n"
+
+ "global $var_attr_name $var_attr_init $var_attr_val $var_attr_save $var_attr_type\n"
"set lst {}\n"
- "for {set ix 1} {$ix <= $alen} {incr ix} {\n"
- "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n"
- "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n"
- "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n"
- "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n"
- "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n"
-
- "global $var_attr_name $var_attr_init $var_attr_val $var_attr_save $var_attr_type\n"
-
- "if { [expr $$var_attr_type] != 0 } {\n"
- // attribute is puttable
-
- "lappend lst [eval concat $$var_attr_name]\n"
-
- // process current value
- "set tmp [eval concat $$var_attr_val]\n"
- "set len [llength $tmp]\n"
- "if { $len == 1 } {\n"
- // it's an atom
- // if atom starts with $, replace it by # ($ can't be passed by TCL)
- "if { [string index $tmp 0] == \"$\" } {\n"
- "set tmp [string replace $tmp 0 0 #]\n"
- "}\n"
- "lappend lst $tmp\n"
- "} else {\n"
- // it's a list
- "set lst [concat $lst {list} $len $tmp]\n"
- "}\n"
- // process init value
- "set tmp [eval concat $$var_attr_init]\n"
- "set len [llength $tmp]\n"
- "if { $len == 1 } {\n"
- // it's an atom
- // if atom starts with $, replace it by # ($ can't be passed by TCL)
- "if { [string index $tmp 0] == \"$\" } {\n"
- "set tmp [string replace $tmp 0 0 #]\n"
- "}\n"
- "lappend lst $tmp\n"
- "} else {\n"
- // it's a list
- "set lst [concat $lst {list} $len $tmp]\n"
- "}\n"
+ "if { [expr $$var_attr_type] != 0 } {\n"
+ // attribute is puttable
- "lappend lst [eval concat $$var_attr_save]\n"
- "}\n"
+ "lappend lst [eval concat $$var_attr_name]\n"
+
+ // process current value
+ "set tmp [flext_escatoms [eval concat $$var_attr_val]]\n"
+ "set lst [concat $lst [llength $tmp] $tmp]\n"
+
+ // process init value
+ "set tmp [flext_escatoms [eval concat $$var_attr_init]]\n"
+ "set lst [concat $lst [llength $tmp] $tmp]\n"
+
+ "lappend lst [eval concat $$var_attr_save]\n"
"}\n"
- "set cmd [concat $id attributedialog $lst \\;]\n"
- "pd $cmd\n"
+ // return list
+ "return $lst\n"
+ "}\n"
+
+ "proc flext_apply {id ix} {\n"
+ "set lst [flext_makevalue $id $ix]\n"
+ "set lst [eval concat $lst]\n" // remove curly braces from character escaping
+ "pd [concat $id attributedialog $lst \\;]\n"
+ "}\n"
+
+ "proc flext_applyall {id alen} {\n"
+ // make a list of the attribute values (including save flags)
+
+ "set lst {}\n"
+ "for {set ix 1} {$ix <= $alen} {incr ix} {\n"
+ "set lst [concat $lst [flext_makevalue $id $ix]]\n"
+ "}\n"
+ "set lst [eval concat $lst]\n" // remove curly braces from character escaping
+
+ "pd [concat $id attributedialog $lst \\;]\n"
"}\n"
"proc flext_cancel {id} {\n"
- "set cmd [concat $id cancel \\;]\n"
- "pd $cmd\n"
+ "pd [concat $id cancel \\;]\n"
"}\n"
"proc flext_ok {id alen} {\n"
- "flext_apply $id $alen\n"
+ "flext_applyall $id $alen\n"
"flext_cancel $id\n"
"}\n"
@@ -181,7 +184,11 @@ void flext_base::SetAttrEditor(t_classid c)
"proc flext_textcopy {id idtxt var} {\n"
"global $var\n"
- "set $var [eval $idtxt get 0.0 end]\n"
+ "set txt [eval $idtxt get 0.0 end]\n"
+ // strip newline characters
+ "set tmp {}\n"
+ "foreach t $txt { lappend tmp [string trim $t] }\n"
+ "set $var $tmp\n"
"destroy $id\n"
"}\n"
@@ -200,7 +207,15 @@ void flext_base::SetAttrEditor(t_classid c)
"pack $id.w.scroll -side right -fill y\n"
"pack $id.w.text -expand yes -fill both\n"
- "$id.w.text insert 0.0 [expr $$var]\n"
+ // insert text with newlines
+ "set txt [split [expr $$var] ,]\n"
+ "set lines [llength $txt]\n"
+ "for {set ix 0} {$ix < ($lines-1)} {incr ix} {\n"
+ "$id.w.text insert end [string trim [lindex $txt $ix] ]\n"
+ "$id.w.text insert end \" ,\\n\"\n"
+ "}\n"
+ "$id.w.text insert end [string trim [lindex $txt end] ]\n"
+
"$id.w.text mark set insert 0.0\n"
"if { $edit != 0 } then {\n"
@@ -229,7 +244,8 @@ void flext_base::SetAttrEditor(t_classid c)
"grid columnconfigure $id 0 -weight 1\n" // label
"grid columnconfigure $id {1 4} -weight 3\n" // value entry
"grid columnconfigure $id {2 3} -weight 0\n" // copy buttons
- "grid columnconfigure $id {5 6 7} -weight 0\n" // radio buttons
+ "grid columnconfigure $id 5 -weight 1\n" // apply button
+ "grid columnconfigure $id {6 7 8} -weight 0\n" // radio buttons
// "grid rowconfigure $id {0 1 2} -weight 0\n"
@@ -238,6 +254,7 @@ void flext_base::SetAttrEditor(t_classid c)
"label $id.init -text {initial value} -height 2 -font {Helvetica 9 bold}\n"
"label $id.copy -text {copy} -height 2 -font {Helvetica 9 bold}\n"
"label $id.val -text {current value} -height 2 -font {Helvetica 9 bold}\n"
+ "label $id.apply -text {} -height 2 -font {Helvetica 9 bold}\n" // why must this be empty?
"foreach {i txt} {0 {don't\rsave} 1 {do\rinit} 2 {always\rsave} } {\n"
"label $id.b$i -text $txt -height 2 -font {Helvetica 9 bold}\n"
"}\n"
@@ -247,13 +264,14 @@ void flext_base::SetAttrEditor(t_classid c)
"grid config $id.init -column 1 -row $row \n"
"grid config $id.copy -column 2 -columnspan 2 -row $row \n"
"grid config $id.val -column 4 -row $row \n"
- "foreach i {0 1 2} { grid config $id.b$i -column [expr $i + 5] -row $row }\n"
+ "grid config $id.apply -column 5 -row $row \n"
+ "foreach i {0 1 2} { grid config $id.b$i -column [expr $i + 6] -row $row }\n"
// "grid config $id.options -column 3 -row 0 \n"
"incr row\n"
// Separator
"frame $id.sep -relief ridge -bd 1 -height 2\n"
- "grid config $id.sep -column 0 -columnspan 8 -row $row -pady 2 -sticky {snew}\n"
+ "grid config $id.sep -column 0 -columnspan 9 -row $row -pady 2 -sticky {snew}\n"
"incr row\n"
"set ix 1\n"
@@ -322,18 +340,23 @@ void flext_base::SetAttrEditor(t_classid c)
"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"
+ // copy buttons
"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"
"button $id.b2c-$ix -text {->} -height 1 -command \" flext_copyval $var_attr_val $var_attr_init \"\n"
"grid config $id.b2c-$ix -column 3 -row $row -sticky {ew}\n"
+ // apply button
+ "button $id.apply-$ix -text {Apply} -height 1 -command \" flext_apply $id $ix \"\n"
+ "grid config $id.apply-$ix -column 5 -row $row -sticky {ew}\n"
+
// "tk_optionMenu $id.opt-$ix $var_attr_save {don't save} {initialize} {always save}\n"
// "grid config $id.opt-$ix -column 5 -row $ix \n"
// radiobuttons
"foreach {i c} {0 black 1 blue 2 red} {\n"
"radiobutton $id.b$i-$ix -value $i -foreground $c -variable $var_attr_save \n"
- "grid config $id.b$i-$ix -column [expr $i + 5] -row $row \n"
+ "grid config $id.b$i-$ix -column [expr $i + 6] -row $row \n"
"}\n"
"} else {\n"
// attribute is gettable only
@@ -361,7 +384,7 @@ void flext_base::SetAttrEditor(t_classid c)
"grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
"label $id.readonly-$ix -text \"read-only\"\n"
- "grid config $id.readonly-$ix -column 5 -columnspan 3 -row $row -padx 5 -sticky {ew}\n"
+ "grid config $id.readonly-$ix -column 6 -columnspan 3 -row $row -padx 5 -sticky {ew}\n"
"}\n"
// increase counter
@@ -372,16 +395,16 @@ void flext_base::SetAttrEditor(t_classid c)
// Separator
"frame $id.sep2 -relief ridge -bd 1 -height 2\n"
// "grid rowconfigure $id $row -weight 0\n"
- "grid config $id.sep2 -column 0 -columnspan 8 -row $row -pady 5 -sticky {snew}\n"
+ "grid config $id.sep2 -column 0 -columnspan 9 -row $row -pady 5 -sticky {snew}\n"
"incr row\n"
// Buttons
"frame $id.buttonframe\n"
"pack $id.buttonframe -side bottom -fill x\n"
- "button $id.buttonframe.cancel -text {Cancel} -width 20 -command \" flext_cancel $id \"\n"
- "button $id.buttonframe.apply -text {Apply} -width 20 -command \" flext_apply $id $alen \"\n"
- "button $id.buttonframe.ok -text {OK} -width 20 -command \" flext_ok $id $alen \"\n"
+ "button $id.buttonframe.cancel -text {Leave} -width 20 -command \" flext_cancel $id \"\n"
+ "button $id.buttonframe.apply -text {Apply all} -width 20 -command \" flext_applyall $id $alen \"\n"
+ "button $id.buttonframe.ok -text {Apply & Leave} -width 20 -command \" flext_ok $id $alen \"\n"
"button $id.buttonframe.help -text {Help} -width 10 -command \" flext_help $id \"\n"
"pack $id.buttonframe.cancel -side left -expand 1\n"
@@ -390,12 +413,12 @@ void flext_base::SetAttrEditor(t_classid c)
"pack $id.buttonframe.help -side left -expand 1\n"
// "grid rowconfigure $id $row -weight 0\n"
- "grid config $id.buttonframe -column 0 -columnspan 8 -row $row -pady 5 -sticky {ew}\n"
+ "grid config $id.buttonframe -column 0 -columnspan 9 -row $row -pady 5 -sticky {ew}\n"
// Key bindings
"bind $id {<KeyPress-Escape>} \" flext_cancel $id \"\n"
"bind $id {<KeyPress-Return>} \" flext_ok $id $alen \"\n"
- "bind $id {<Shift-KeyPress-Return>} \" flext_apply $id $alen \"\n"
+ "bind $id {<Shift-KeyPress-Return>} \" flext_applyall $id $alen \"\n"
"}\n"
);
}
@@ -621,10 +644,7 @@ void flext_base::cb_GfxSave(t_gobj *c, t_binbuf *b)
bool flext_base::cb_AttrDialog(flext_base *th,int argc,const t_atom *argv)
{
- int i = 0;
- if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) ++i;
-
- for(; i < argc; ) {
+ for(int i = 0; i < argc; ) {
FLEXT_ASSERT(IsSymbol(argv[i]));
// get name
@@ -632,27 +652,17 @@ bool flext_base::cb_AttrDialog(flext_base *th,int argc,const t_atom *argv)
i++;
// get current value
+ FLEXT_ASSERT(CanbeInt(argv[i]));
int ccnt,coffs;
- if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) {
- i++;
- FLEXT_ASSERT(CanbeInt(argv[i]));
- ccnt = GetAInt(argv[i]);
- coffs = ++i;
- }
- else
- coffs = i,ccnt = 1;
+ ccnt = GetAInt(argv[i]);
+ coffs = ++i;
i += ccnt;
// get init value
+ FLEXT_ASSERT(CanbeInt(argv[i]));
int icnt,ioffs;
- if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) {
- i++;
- FLEXT_ASSERT(CanbeInt(argv[i]));
- icnt = GetAInt(argv[i]);
- ioffs = ++i;
- }
- else
- ioffs = i,icnt = 1;
+ icnt = GetAInt(argv[i]);
+ ioffs = ++i;
i += icnt;
FLEXT_ASSERT(i < argc);
diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp
index eb3f2a35..e2ace494 100644
--- a/externals/grill/flext/source/flext.cpp
+++ b/externals/grill/flext/source/flext.cpp
@@ -54,6 +54,11 @@ flext_base::FLEXT_CLASSDEF(flext_base)():
flext_base::~FLEXT_CLASSDEF(flext_base)()
{
+#if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT)
+ // attribute editor window may still be open -> close it
+ gfxstub_deleteforkey(thisHdr());
+#endif
+
#if FLEXT_SYS == FLEXT_SYS_MAX
// according to David Z. one should do that first...
// if(insigs) dsp_free(thisHdr());