Go to the first, previous, next, last section, table of contents.

Toggle data types

* Toggle a
the abstract type of a Toggle handle.

* ToggleResources
currently a list of (attribute,value) pairs specifying the default configuration values you want to override when creating a Toggle:

type ToggleResource = [ToggleResource]

data ToggleResource
 =
    {- the feedback to give for the different stages of the interaction. -}
   ToggleFeedback TogFeedback
    {- initial picture to display for toggle -}
 | ToggleInitial  (Picture -> Size -> Int -> Picture)
    {- the labels to use. -}
 | ToggleLabelOn  Picture
 | ToggleLabelOff  Picture
    {-
      How to toggle the state upon completion of interaction,
      i.e., how to map toggle state to new one.
    -}
 | ToggleFunction (Bool -> Bool)
    {- the interaction function -}
 | ToggleIaction  Iaction

* IState
The different interaction states used by the Toggle:

data IState 
 = IIdle
 | ICompleted
 | IFocus
 | IRunning
 | ISuspended
 | IAborted
   deriving Eq

* TogFeedback
a record of feedback functions to use for a Toggle instance.

type TogFeedback =
 (  {- normal/completed feedback -}
  TogFbackFunction,
    {- focus feedback -}
  TogFbackFunction,
    {- running feedback -}
  TogFbackFunction,
    {- suspended feedback -}
  TogFbackFunction)

* TogFbackFunction
a feedback function value, which given a style context (see TogFbackStyle) and a label, returns the picture to display for the Toggle.

type TogFbackFunction =
     {- style to use -}
    TogFbackStyle 
     {- toggle label -}
 -> Picture
     {- on \/ off -}
 -> Bool
 -> ResizeablePicture

* TogFbackStyle
A record of attributes to use for drawing a Toggle:

data TogFbackStyle =
 TogFbackStyle
    {- anchor for the label -}
   CompassDirection
    {- foreground and bground (in idle states) -}
   Colour Colour
    {- active bg&fg -}
   Colour Colour
    {- pen to use when item is selected -}
   Pen
    {- lighter/darker fg&bg colours -}
   Pen Pen
    {- lighter/darker active fg&bg colours -}
   Pen Pen
    {- relief in idle mode -}
   Relief
    {- borderwidths -}
   Int Int

* Iaction
the interaction state function, maps current interaction state and device events to new state:

type Iaction = DeviceEvent -> IState -> Maybe IState

based on a device event and the current interaction state, an Iaction function may return the following two values:
Returns:
* Nothing
event was not of interest, it may be passed on. Interaction stays the same.

* Just newIState
move to interaction state newIState and change the feedback of the Selector to reflect the change in state.

* ToggleName
The ToggleName is used to identify a particular Toggle when merging them together with the combineToggles operator.

type ToggleName = String

combine t1 t2 =
 combineToggles [setToggleName "foo" t1,
                 setToggleName "bar" t2]

Using the ToggleNames, we can selectively disable/enable sub-toggles via the combined Toggle handle.

disable_toggle t1 t2 =
  combineToggles t1 t2            >>= \t ->
  activateToggle t ["bar"] False  >>
  ...

which disables the t2 toggle.

Go to the first, previous, next, last section, table of contents.