2 summary:: display the contents of an environment for editing
3 categories:: Libraries>JITLib>GUI
4 related:: Classes/EZText, Classes/TdefGui, Classes/PdefGui
7 EnvirGui displays all keys and values of an environment, so one can change them flexibly. Single number get displayed with an link::Classes/EZSlider::, pairs of numbers with an link::Classes/EZRanger::, and anything else is shown as an link::Classes/EZText:: (a text field).
18 g = EnvirGui.new(nil, 5); // empty with 5 slots
19 g.object_((a: 1, b: \werty, freq: [500, 2000])); // put some things in
20 g.envir.put(\karl, \otto1); // one more
21 g.envir.putAll((b: -12, r: 1, s: 2, t: 3, u: 4, v: 5))
23 g.object_((x: 2)); // put something else in
25 g.envir.putAll((b: -12, r: 1, s: 2, t: 3, u: 4, v: 5))
41 the number of items to display. If an envir is given, and no num, num is envir.size.
44 the parent view to display in; if none is given, a new window is created.
47 the bounds within which to display; if none is given, bounds are calculated.
50 flag whether to make a skipjack to manage updates of the envirgui.
54 subsection::Instance Variables
57 how many envir items to display
60 the envir displayed - actually an alias for object.
63 the composite view the envirgui makes for itself
66 the areas in which the key-value pairs are displayed.
69 the EZGuis that display the values:
71 ## Single numbers will have an link::Classes/EZSlider::,
72 ## pairs of numbers will be shown as an link::Classes/EZRanger::,
73 ## all other values are shown as compileStrings in an link::Classes/EZText::.
77 EZSlider and EZRanger needs specs for their display ranges; if there is a global spec for that key (key.asSpec), it will be used. If not, a spec is generated (see the link::#-getSpec:: method) and kept in these (local) specs.
80 if the size of envir exceeds numItems, the keys displayed can be rotated: e.g. with 10 keys displayed on 5 valFields, keysRotation 0 means show keys (0..4), keysRotation 2 means show keys (2..6), etc.
82 subsection::Some Methods
85 set the environment to show
88 can be nil, a dictionary, an environment, or an event.
91 g = EnvirGui((freq: 120, \amp: 0.2, \pan: -0.5), 12, nil, bounds: Rect(20, 400, 220, 100));
92 g.object_((a: 1, b: [2, 3], c: \symbol, d: [4, 5, 6], f: { "boing".postln }))
99 if in its own window, set the window's name
106 For editing, specs for the parameter ranges are needed. These can be set locally in the EnvirGui, or global specs will be looked up. If no local or global specs exist for that parameter name, getSpec makes a usable guess for them.
111 g.getSpec(\freq, 400); // \freq exists as global spec, so use that
112 g.object_((freq: 150));
114 g.getSpec(\iFrek, 500); // no global spec, so make a new one:
115 // exponential from val * 0.05 to val * 20;
116 g.specs; // and keep it here
117 g.envir.put(\iFrek, 500);
121 the parameter name for which to find a spec
124 the current value of that param, which may be used for guessing specs.
127 add a spec for a given key, or (if it is a global key) override a global spec with a local one:
130 g.putSpec(\iFrek, [10, 1000, \exp]);
131 g.putSpec(\freq, [100, 1000, \exp]);
132 g.object_((freq: 200, iFrek: 20));
135 subsection::Some internal methods
138 set a field by index, with the new key, value;
141 means the field had the same key already.
144 update the widgets for the current keys
147 remove the link::Classes/EZGui:: at this index
150 remove all unused EZGuis
155 // Setting envir variables in a Tdef:
157 Tdef(\text).set(\note, [0, 2, 7], \dur, { [0.1, 0.2, 0.4].choose }, \pan, 0, \amp, 0.1);
159 w = Window("EZTexts", Rect(200, 400, 304, 120)).front;
162 TdefGui(Tdef(\text), 0, parent: w);
164 e = EnvirGui(Tdef(\text).envir, 4, parent: w);
170 (note: ev.note, dur: mydur, amp: ev.amp, pan: ev.pan).postln.play;
176 // or equivalently, use the built-in EnvirGui in TdefGui:
177 TdefGui(Tdef(\text), 4);
179 Tdef(\text).set(\yuhu, Prand([2, 3, 5, 8, 13], inf), \magic, [\abra, \cadabra]);