2. ColorSchemeViewer.mesa
The Create procedure makes a new instance of the viewer class, formatted as a function of size. The labels are the short labels on the slider (R, G, B above). The title is the longer title over the sliders (Red, Green, Blue above). The slider width and height is controlled by sw and sh. The label fonts are picked to coordinate with these sizes. The fields parent, wx, wy are of interest for nested viewers (the usual case), and wx, wy is the lower left corner of the lower slider. The viewer width and height is controlled by the size of the contents. The NotifyProc will be called each time one of the values changes.
The Changes type indicates which values have changed. The top slider is "v1", the bottom one "v3". The value "paintViewer" is used to refresh the viewer without changing the values. The value "none" is only there for semantic purity and is currently not used.
Create: PROC [labels: ARRAY [1..3] OF ROPE, sw, sh: INT, notify: NotifyProc, title: ROPE ← NIL, clientData: REF ← NIL, parent: Viewer ← NIL, wx, wy: INTEGER ← 0] RETURNS [Viewer];
Changes: TYPE = {none, v1, v2, v3, allValues, paintViewer};
NotifyProc: TYPE = PROC [values: ARRAY [1..3] OF REAL, changes: Changes, client: REF];
The client will be notified everytime a value in the viewer changes. The viewer will have been repainted to reflect the change by the time the NotifyProc is called.
The viewer values can be set and read through the ColorSchemeViewer interface.
SetValues: PROC [viewer: Viewer, values: ARRAY [1..3] OF REAL, notify: BOOLEAN ← FALSE] RETURNS [Changes];
SetValues only paints the slider and text viewer contents, leaving the labels alone .
GetValues: PROC[viewer: Viewer] RETURNS[v1, v2, v3: REAL];
While under normal operation the viewer will update itself, clients may need to force a paint, which can be accomplished using the Paint procedure.
Paint: PROC[viewer: Viewer, context: Imager.Context, whatChanged: Changes];