Next: 6.12.3 The Image class Up: 6.12 Controlling the interface Previous: 6.12.1.2 Dynamic menu items Contents

##
6.12.2 Workspaces

Definitions in workspaces are displayed with `nip2`'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.4.

Figure 6.4: Components of a workspace row

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 manipulate the graphic representation (dragging a slider, or moving a region). These can be contradictory, so `nip2` resolves conflicts by always applying changes in the order text, then graphic, then member.

When it applies a graphic change, `nip2` 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, `nip2` searches for a member called `Colour_edit`, fails to find it, and so picks the `Colour` member instead (the default constructor generated by `nip2`). It then replaces the value of A1 with

[needs finishing]

Table 6.5: `nip2` built in graphic classes
Class | Description
`Slider from to value` | A slider
`Toggle caption value` | A toggle switch
`Option caption labels value` | Select one item from a list
`Pathname caption value` | Displays a file browser
`Fontname caption value` | Displays a font browser
`String caption value` | Displays an editable string
`Number caption value` | Displays an editable number
`Expression caption expr` | Displays an editable expression
`Image value` | An image
`Colour colour_space value` | A patch of colour
`Matrix_vips value scale offset filename display` | A matrix
`Mark 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

Next: 6.12.3 The Image class Up: 6.12 Controlling the interface Previous: 6.12.1.2 Dynamic menu items Contents