| 12
 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
 
 | class:: PdefGui
summary:: a line of editing controls for a Pdef, and optionally its envir
categories:: JITLib>GUI, Live Coding
related:: Classes/PdefAllGui, Classes/TdefGui, Classes/TdefAllGui, Classes/EnvirGui
description::
A gui showing the link::Classes/Pdef::'s name, playing state, source state, and envir state. Optionally, its envir can also be edited.
subsection::First example
code::
g = PdefGui();			// make a PdefGui
g.object = Pdef(\a);		// show when a Pdef is put in
Pdef(\a, Pbind(\note, 12)); 	// show whether it has a source
Pdef(\a).play; 			// show whether playing, stopped, or ended, and pausable
Pdef(\a).set(\dur, 0.25); 	// show whether the Pdef has an envir
g.close;
g = PdefGui(Pdef(\a), 3);	// with an envirgui for 3 items
Pdef(\a).set(\lofreq, [1, 10], \str, "someString", \oops, \oneSymbolTooMany);
Pdef(\a).clear;
Pdef(\a).envir.clear;
g.close;
(				// put it in an existing window - margin is 0@0
w = Window("my win", Rect(200, 200, 300, 200)).front;
w.addFlowLayout;
PdefGui(Pdef(\a), 0, w);
PdefGui(Pdef(\a), 3, w);
)
::
subsection::Details on the GUI elements
definitionList::
## name button
|| when selected, typing the delete key will delete its Pdef.
## play/stop button
|| indicates whether the Pdef is playing:
table::
## " >" || if stopped,
## " _" || if playing and active,
## " |" || if it is playing, but the stream has ended.
::
## pause/resume button
|| only visible if one can pause or resume the Pdef, i.e. while it is playing.
table::
## "paus" || shown when you can pause it,
## "rsum" || shown when you can resume it.
::
## src button
|| opens a document to edit the source (function) of the Pdef.
table::
## green || a source exists,
## white || the source is nil.
::
## env button
|| opens a document to edit the environment of the Pdef, which is where one can keep all variables the Pdef uses for easy access.
table::
## green || the Pdef has an envir,
## white || the envir is nil.
::
::
ClassMethods::
subsection::Creation Methods
method::new
Create a new link::Classes/JITGui:: that will be watching an object and display its state.
argument::object
the object to watch
argument::numItems
the number of display items to use, e.g. how many fields for text, or how many EZSliders for single-number parameters.
argument::parent
a parent view on which to display. If nil, a new window is created; strong::parent:: can also be an existing window or a composite view.
argument::bounds
a desired size and position where to display a JITGui. can be nil, a link::Classes/Point::, or a link::Classes/Rect::. JITGuis know their minimum size ( strong::minSize:: ), and if bounds is nil, minSize is used. if bounds is a link::Classes/Point:: or link::Classes/Rect::, it will be set to at least minSize. With a rect one can also supply a position where to display. If a point,shown size is the maximum of bounds and minSize.
argument::makeSkip
A flag whether to make a skipjack.
argument::options
a list of additional information, e.g. flags about optional buttons. (this is used is some subclasses)
InstanceMethods::
method::object
a link::Classes/Pdef::, or nil
method::numItems
the number of items in the envirGui
method::parent
the parent view
method::bounds
the bounds of the link::#-zone::
method::zone
the link::Classes/CompositeView:: within which the PdefGui is shown
method::nameBut, playBut, pauseBut, srcBut, envBut
the buttons
method::envirGui
the gui for the Pdef's envir - nil if numItems is 0.
method::object
put an object in the gui.
method::moveTo
(if the jitGui is in its own window)
move it to some specific location.
method::clear
(if the jitGui is in its own window)
set the PdefGui's object to nil
method::close
(if the jitGui is in its own window)
and close its window.
subsection::Internal methods
method::srcString
a compileString that recreates the Pdef.
code::
// assume g from above is still there
g.srcString;
::
method::editString
a compileString that recreates the Pdef's envir at edKey.
method::editStrings
a compileString that recreates the Pdef's envir at edKeys.
argument::edKeys
Default value is nil.
code::
// assume g from above is still there
g.editString;
Pdef(\a).set(\foo, \bar);
g.editString(\foo);
g.editStrings;
::
method::getUsedKeys
the keys in use in the envir
code::
g.getUsedKeys;
::
method::openDoc
open a document with some strings at some location
code::
g.openDoc(g.editStrings);
::
method::makeEnvirGui
make an envirGui within zone - called internally.
Examples::
code::
Pdef(\a, Pbind(\freq, Prand((1..16) * 55, inf)));
Pdef(\a).play;
t = PdefGui(Pdef(\a), 4);
Pdef(\a).set(\dur, 0.125, \amp, 0.05);
Pdef(\a).stop;
Pdef(\a).play;
Pdef(\a).pause;
Pdef(\a).resume;
t.object_(nil);
t.object_(Pdef(\a));
(
w = Window("put it in a selfmade window").front;
w.addFlowLayout;
w.view.decorator.shift(50, 50);
PdefGui(Pdef(\a), 12, w);
)
Pdef(\b, Pbind(\note, Pxrand((0..7), inf), \dur, 0.125));
Pdef(\b).play;
PdefGui(Pdef(\b));
	// see all Pdefs:
PdefAllGui(16);
::
 |