EnvirGui display the contents of an environment for editing

Inherits from: Object

EnvirGui displays all keys and values of an environment, so one can change them

flexibly. Single number get displayed with an EZSlider, pairs of numbers with an

EZRanger, and anything else is shown as an EZText (a text field).

See also: EZText, TdefEditor, PdefEditor

Creation / Class Methods

*new (envir, parent, bounds, name, num, makeSkip)

create a new EnvirGui

envir - the envir to display

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

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

name - a name to use for the envir/gui; is used for the auto-created window.

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

makeSkip - flag whether to make a skipjack to manage updates of the envirgui. default is true.

// simple example

g = EnvirGui.new;

g.envir_((a: 1, b: \werty, freq: [500, 2000])); // explanation

g.envir.put(\karl, \otto);

g.parent.close;

Class Variables

labelWidth a classvar that sets how wide the labels will become. Default is 60.

valWidth a classvar that sets how wide the valFields will become. Default is 200.

Instance Variables

parent the envirgui's parent view or window.

bounds the envirgui's bounds

name the name to display one the parent (if it is a window)

num how many envir items to display - if the envir has more,

they can be shown with a scroller (see scrolly)

envir the envir displayed

zone the composite view the envirgui makes for itself

valFields the areas in which the key value pairs are displayed.

widgets the EZGuis that display the values:

Single numbers will have an EZSlider,

pairs if numbers an EZRanger,

all other values are shown as compileStrings in an EZText.

skin the GUI skin to be used in displaying.

specs 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 getSpec method) and kept in these (local) specs.

skip the SkipJack used for updating the gui.

If there are more keys/values than valFields to display them,

the follwing vars play a role:

currKeys the keys currently displayed

scrolly the EZScroller used to access different keys/values

keysRotation

the amount of rotation of the keys displayed;

e.g. with 10 keys displayed on 5 valFields,

keysRotation 0 means show keys (0..4),

keysRotation 2 means show keys (2..6), etc.

Some Methods

envir_ (invir) set the environment to show

invir - Explanation of invir. Default value is nil. Other information.

// inline example

g = EnvirGui.new;

g.envir_((a: 1, b: [2, 3], c: \symbol, d: [4, 5, 6], f: { "boing".postln }))

getSpec (key, value)

Short prose description of method.

key - Explanation of key. Default value is nil. Other information.

value - Explanation of value. Default value is nil. Other information.

// inline example

g = EnvirGui.new;

g.getSpec(\freq, 400); // \freq exists as global spec, so use that

g.envir_((freq: 150));

g.getSpec(\myFreak, 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(\myFreak, 500);

putSpec (key, obj) add a spec for a given key,

or (if it is a global key) override a global spec with a local one:

g.putSpec(\myFreak, [10, 1000, \exp]);

g.putSpec(\freq, [100, 1000, \exp]);

g.envir_((freq: 200, myFreak: 20));

Some internal methods:

checkUpdate update the gui display (called regularly by skip)

setField (index, key, value, sameKey)

set a field by index, with the new key, value;

sameKey means the field had the same key already.

setByKeys update the widgets for the current keys

clearField (index) remove the EZGui at this index

clearFields remove all unused EZGuis

Examples

// 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;

TdefEditor(Tdef(\text), 0, w: w);

EnvirGui(Tdef(\text).envir, 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;

)