next up previous contents
Next: 6.12.3 The Image class Up: 6.12 Controlling the interface Previous: 6.12.1 Tools and toolkits   Contents


6.12.2 Workspaces

Definitions in workspaces are displayed with nip's class browser. Each row is displayed in four main parts: a button for the row name, a line of text, a set of sub-rows for the members of the row's class, and a graphic display representing the row's value. See Figure 6.2.

Figure 6.2: Components of a workspace row
\includegraphics[width=4in]{figs/row.eps}

The text part of the right-hand-side of each row is always displayed, but the sub-rows are only displayed if the row represents a class, and the graphic is only displayed if the class is an instance of one of the classes in Table 6.5. You can subclass these if you want to use the graphic display in your own widgets.

There are three separate ways to set the value for a row. You can edit the line of program text, you can edit one of the members, or you can manipluate the graphic representation (dragging a slider, or moving a region). These can be contradictory, so nip resolves conflicts by always applying changes in the order text, graphic, member.

When it applies a graphic change, nip rebuilds the class using a class member called class-name_edit, or if that is not defined, the class's constructor member. For example, the Colour class can be defined as:

                                                             
  Colour colour_space value = class {}
  A1 = Colour "sRGB" [255,0,0];

There are two ways to change A1. You can open A1 and change colour_space to "Lab", or you can double-click on the swatch and drag the disc. When you click OK on the colour edit dialog, nip searches for a member called Colour_edit, fails to find it, and so picks the Colour member instead (the default constructor generated by nip). It then replaces the value of A1 with


Table 6.5: nip built in graphic classes
Class Description
Filename value Displays a file browser
Toggle caption value A toggle switch
Image value An image
Slider from to value A slider
Colour colour_space value A patch of colour
Option caption labels value Select one item from a list
Matrix_vips value scale offset filename display A matrix
Point image left top A point on an image
HGuide image top A horizontal line on an image
VGuide image left A vertical line on an image
Arrow image left top width height Two points joined by a line on an image
Region image left top width height A sub-area of an image
Area image left top width height A sub-area of an image, fixed in size
Real value A real number



next up previous contents
Next: 6.12.3 The Image class Up: 6.12 Controlling the interface Previous: 6.12.1 Tools and toolkits   Contents
John Cupitt 2003-07-21