Thank you, very much appreciated.
As a minor point, I see that VarGui can do also global Spec
lookup, but the syntax to make it do that is slightly surprising, i.e. the key needs to be duplicated as in:
Spec.add(\foo, [0, 10, \lin, 1, 1])
Spec.add(\bar, [20, 30, \lin, 2, 22])
// one 'foo' and one 'bar' slider
v = VarGui([\foo, \foo, \bar, \bar], envir: ~d).gui;
I.e., the first \foo
in that parameter array is a lookup in ~d
, whereas the second is a lookup in Spec.specs
.
I do have one more basic question though: in all the examples you gave the initial value displayed in the GUI is the spec-default, not what was in the environment (EnvirGui makes the opposite choice). Is there a way change this initialization behavior (i.e. to be like EnvirGui’s), short of passing in modified specs with an environment lookup-up value? I.e. I can obviously do something like
(
Spec.add(\foo, [0, 10, \lin, 1, 1]);
Spec.add(\bar, [20, 30, \lin, 2, 22]);
~hackspecs = { |d ... xa| flatten ( xa collect: { |x|
[x, Spec.specs[x].copy.default_(d[x])] } ) };
~d = (foo: 3, bar: 27);
v = VarGui(~hackspecs.(~d, \foo, \bar), envir: ~d).gui;
~d // -> ( 'foo': 3.0, 'bar': 28.0 ) because it applied spec's rounding
)
But this seems a bit complicated… especially for the dict array use
[\x, \y, \z] do: Spec.add(_, [0, 30, \lin, 1, 22])
~da = [0, 10, 20] collect: { |i| (x: i+1, y: i+2, z: i+3) };
~va = ~da collect: ~hackspecs.(_, \x, \y, \z)
v = VarGui(~va, envir: ~da).gui;
The feature of EnvirGui that I don’t know how to replicate in VarGui is the auto-update with new controls/sliders, i.e.
~d = (foo: 3, bar: 27);
EnvirGui(~d)
~d[\zap] = 66 // gui updates automatically with new slider
I haven’t even discovered how manually/explicitly add sliders after a VarGui is instantiated…
(By the way, that one can double-click on the ctrl name in VarGui to edit the spec in the GUI itself is quite cool, although the feature seems not mentioned in documentation.)