Proxies for synths, tasks and patterns as implemented in JITLib are extremely flexible. Having guis that represent their changeable states makes it easier to understand what is going on, especially when using multiple proxies together. JITGuis follow a special strategy described below.
Create a new JITGui that will be watching an object and displaying its state.
object |
the object to watch |
numItems |
the number of display items to use, e.g. how many fields for text display, or how many sliders for single-number parameters. |
parent |
a parent view on which to display. If nil, a new window is created; parent can also be an existing window or a composite view. |
bounds |
a desired size and position where to display a JITGui. Can be nil, a Point, or a Rect. JITGuis know their minimum size ( minSize ), and if bounds is nil, minSize is used. if bounds is a point or 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. |
makeSkip |
A flag whether to make a skipjack. (If the gui is on its own window, it typically uses one, if the JITGui is part of a larger gui, that gui may take care of updating.) |
options |
a list of additional information, such as flags about optional buttons. (This is used in some subclasses.) |
the object to watch
the number of display items to use, e.g. how many fields for text display, or how many sliders for single-number parameters.
a parent view on which the gui is displayed.
the size and position of the JITGui
a CompositeView inside the parent that holds the JITGui's views.
a JITGuis calculates its own minimum size based on numItems and options.
the default position where the JITGui is shown if it is in its own window.
(Appearance)
the GUI skin to use. By default this is GUI.skins.jit
.
(Appearance)
the font, also taken from JITGui.skin.
(specific in the JITGui class)
displays the object's key or name if available.
(specific in the JITGui class)
displays the object's compileString.
(common to all JITGuis)
the last observed state which is kept around for comparison.
(common to all JITGuis)
the skipjack that watches the object's state so it can be updated.
(common to all JITGuis)
an EZScroller used for scrolling which of a list of items is shown. see e.g. TdefGui for usage.
(common to all JITGuis)
a flag whether the JITGui has made its own window, and thus owns it.
put an object in the gui - if the gui accepts it.
test whether obj is a valid object to show in a JITGui. In JITGui itself, all objects are accepted, in the subclasses, obj can either be nil or a specific class, such as Tdef, Pdef, Ndef
set the text of the -nameView and the window (if it -hasWindow)
ask the object its name, or return '_anon_'
return a suitable name for a window: "JITGui_objname"
if it has its own window, one can move it to some specific location.
close its window.
A JITGui watches the state of its object by calling its (the gui's) -getState method at appropriate intervals (skipjack.dt). It compares the new state of the object with the previous state stored in -prevState. When something has changed, only the gui elements concerned are updated.
Compare this with model-view-controller (MVC):
You can write your own subclasses to JITGui very efficiently by implementing appropriate variants of the following methods in your class. For examples of these methods, see TdefGui, EnvirGui, NdefGui.
used to calculate the required onscreen size for the jitGui's zone. Should determine zone size based on -numItems and options. also, -defPos (where to show your jitGui by default) can be set here, and possibly modifications to the skin used.
a test whether obj can be shown in the particular kind of JITGui. Subclasses of JITGui are made for special objects, e.g. Pdefs, so they should test whether obj is the right kind.
create all the views of the jitGui inside the zone.
ask the object for all aspects of its current state that will be displayed.
get the object's current state with -prevState, compare it with prevState, update all gui elements that need to be changed, and store the new state as prevState. This method is called in the skipJack.
how to calculate the bounds for the zone in which to display
how to make a window when no parent is given
how to initalize the zone within the parent window or view
a method for generating a name for the object.
a method for generating a name for the JITGui's window.
Some objects may have more elements to display than the gui has slots, e.g. a ProxySpace can have more proxies than the mixer has numItems. Then, only -numItems elements are shown, and the others can be scrolled to with -scroller - an EZScroller next to the slot elements. The makeScroller method should knows where in the zone to put the scroller.