File: EnvirGui.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (251 lines) | stat: -rw-r--r-- 6,726 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
class:: EnvirGui
summary:: display the contents of an environment for editing
categories:: JITLib>GUI, Live Coding
related:: Classes/EZText, Classes/TdefGui, Classes/PdefGui

description::
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).

ClassMethods::

subsection::Creation

method::new
create a new EnvirGui
NdefParamGui
code::
// simple example
g = EnvirGui.new(nil, 5);    // empty with 5 slots
g.parent.alwaysOnTop_(true);
g.object_((a: 1, b: \werty, freq: [500, 2000]));	// put some things in
g.envir.put(\karl1, \otto1);				// one more
g.envir.put(\caesar, \julius);				// one more

g.envir.putAll((b: -12, r: 1, s: 2, t: 3, u: 4, v: 5))

g.object_((x: 2));	// put another object in

g.envir.putAll((b: -12, r: 1, s: 2, t: 3, u: 4, v: 5))

g.envir.removeAt(\b)
g.envir.removeAt(\r)
g.envir.removeAt(\s)
g.envir.removeAt(\t)
g.envir.removeAt(\u)
g.envir.removeAt(\v)
g.close;
::

argument::object
the envir to display

argument::numItems
the number of items to display. If an envir is given, and no num, num is envir.size.

argument::parent
the parent view to display in; if none is given, a new window is created.

argument::bounds
the bounds within which to display; if none is given, bounds are calculated.

argument::makeSkip
flag whether to make a skipjack to manage updates of the envirgui.

argument::options
configuration options

InstanceMethods::

subsection::Instance Variables

method::numItems
how many envir items to display

method::envir
the envir displayed - actually an alias for object.

method::zone
the composite view the envirgui makes for itself


method::paramViews
the paramViews that display the values:
list::
## Single numbers appear in an link::Classes/EZSlider::,
## pairs of numbers will be shown in an link::Classes/EZRanger::,
## all other values are shown as compileStrings in an link::Classes/EZText::.
::
See link::Classes/ParamView:: for details.

method::specs
a local dictionary of the specs used for display ranges of numerical parameters by the paramViews of this envirgui. See the link::#-getSpec:: method for details.

method::editKeys
the keys of the currently displayed items in the dict.

method::keysRotation
if the size of envir exceeds numItems, the keys displayed can be rotated: e.g. with 10 keys displayed on 5 paramViews, keysRotation 0 means show keys (0..4), keysRotation 2 means show keys (2..6), etc.

strong::gui elements present if requested in options::
method:: docBut, knowBut, parentBut, protoBut

subsection::Some Methods

method::object
set the environment to show

argument::obj
can be nil, a dictionary, an environment, or an event.

code::
g = EnvirGui((freq: 120, \amp: 0.2, \pan: -0.5), 12, nil, bounds: Rect(20, 400, 220, 100));
g.object_((a: 1, b: [2, 3], c: \symbol, d: [4, 5, 6], f: { "boing".postln }))
::

method::envir
same as object_(obj)

method::name
if in its own window, set the window's name

code::
g.name_("Yoohoo");
::

method::getSpec
For editing, numerical parameters need control specs for the ranges on the gui. 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. (With JITLibExtensions, one can also look up specs attached to an object such as a proxy.)

code::
// inline example
g = EnvirGui.new; g.parent.alwaysOnTop_(true);
g.getSpec(\freq, 400);		// \freq exists as global spec, so use that
g.object_((freq: 150));

g.getSpec(\iFrek, 500);		// no global spec, so make a new one:
				// exponential from val * 0.05 to val * 20;
g.specs;			// and keep it here
g.envir.put(\iFrek, 500);
::

argument::key
the parameter name for which to find a spec

argument::value
the current value of that param, which is used when guessing specs.

method::putSpec
add a spec for a given key, or (if it is a global key) override a global spec with a local one:

code::
// set a desired range and warp:
g.putSpec(\iFrek, [10, 1000, \exp]);
g.putSpec(\freq, [10, 1000, \exp]);
g.specs;
g.putSpec(\freq, \freq);

// specs are remembered when object changes
g.putSpec(\freq, [10, 1000, \exp]);
g.object_((freq: 200, iFrek: 20));

// if needed, clear specs by hand when switching objects
g.specs.clear; g.object_((freq: 200, iFrek: 20));

g.close
::

strong:: Keys with technical names can be replaced in the display with clearer names:
method:: replaceKeys
the current list of keys to replace
method:: addReplaceKey
add a key to replace and its replacer key
method:: removeReplaceKey
remove a replacer key
method:: showKeyFor
show

code::
e = (longFreq: 123, amp: 0.25);
g = EnvirGui(e); g.parent.alwaysOnTop_(true);

g.editKeys;
g.addReplaceKey(\longFreq, \freq1, [50, 500, \exp]);
g.viewForParam(\longFreq).visible_(false);
g.viewForParam(\freq1).visible_(true);

e.put(\z, 345);
e.put(\a, 34);

g.replaceKeys
g.removeReplaceKey(\longFreq)
::

method::highlight
highlight the paramview at a given index, by color and optional prefix
code::
g.highlight(0);
g.highlight(0, ">>_");
g.highlight(0, ">>_", Color.green(1, 0.6));
::

method::unhighlight
remove highlighting at an index
g.unhighlight(0);


subsection::Some internal methods

method::setByKeys
update the widgets for the current keys


method::showFields
show (num) active fields, make others invisible.

method::useRanger
set and get whether arrays of 2 number values should be displayed with EZRangers.


strong::methods that make gui elements: ::
method:: makeViews
method:: makeOptionalViews
the method that makes all views specified in the options
method:: makeNameView, makeKnowBut, makeDocBut, makeClrBut, makeProtoBut, makeParentBut
the methods that make the individual elements as specified

strong::standard JITGui methods: ::
method::accepts, setDefaults, getState, checkUpdate, updateButtons

private:: clearFields, updateViewSpecs, viewForParam

Examples::

code::
	// Setting envir variables in a Tdef:
(
Tdef(\text).set(\note, [0, 2, 7], \dur, { [0.1, 0.2, 0.4].choose }, \pan, 0, \amp, 0.1);

w = Window("EZTexts", Rect(200, 400, 304, 120)).front;
w.addFlowLayout;

TdefGui(Tdef(\text), 0, parent: w);

e = EnvirGui(Tdef(\text).envir, 4, parent: w);

Tdef(\text, { |ev|
	var mydur;
	loop {
		mydur = ev.dur;
		(note: ev.note, dur: mydur, amp: ev.amp, pan: ev.pan).postln.play;
		mydur.wait;
	}
}).play;
)

	// or equivalently, use the built-in EnvirGui in TdefGui:
TdefGui(Tdef(\text), 8);

Tdef(\text).set(\yuhu, Prand([2, 3, 5, 8, 13], inf), \magic, [\abra, \cadabra]);

Tdef(\text).clear;
Tdef(\text).envir.clear;
::