RoRo-0.1: Lupupu Cube Stage SolverContentsIndex
Game.LupupuCube.UI.SpringLayout
Description
A very flexible layout manager. Widgets are laid out by defining the relationships between them. The relationships are expressed as Springs. You can attach a Spring for each edge of a widget and link it to an edge of a different widget. For example, you can say, the northern edge of widget A should be attached to the southern edge of widget B, and the space between them should be something between x and y pixels, and preferably z pixels.
Synopsis
data SpringLayoutWidget
type Adder s = forall w. Widget w => w -> ST s (Constraints s)
createSpringLayout :: (forall s. Constraints s -> Adder s -> ST s ()) -> SpringLayoutWidget
module Game.LupupuCube.UI.Constraints
module Game.LupupuCube.UI.Spring
Documentation
data SpringLayoutWidget
This is a widget containing number of other widgets and their relationships.
show/hide Instances
type Adder s = forall w. Widget w => w -> ST s (Constraints s)
adder w inserts the widget w into the SpringLayoutWidget of the current context, and then it returns a new Constraints for the widget w in the ST monad.
createSpringLayout :: (forall s. Constraints s -> Adder s -> ST s ()) -> SpringLayoutWidget

Oh no, this function is malciously designed to destroy your sanity. What's the heck is this?

createSpringLayout creates a SpringLayoutWidget using a given function which takes the constraints of the SpringLayoutWidget itself, and an Adder function, and returns () in the ST monad.

The initial Constraints for the SpringLayoutWidget itself is as follows:

west
fixed 0
north
fixed 0
width
constant 0 0 maxBound
height
constant 0 0 maxBound

The initial Constraints for each new widgets are as follows:

west
fixed 0
north
fixed 0
width
widgetWidth w
height
widgetHeight w

Example:

  mkMainWidget :: SpringLayoutWidget
  mkMainWidget = createSpringLayout $ \ frame add ->
                 do widget1 <- add mkWidget1
                    widget2 <- add mkWidget2

                    setEast widget2 =<< getEast frame
                    setX    widget2 =<< getEast widget1

  mkWidget1 :: SomeWidget
  mkWidget2 :: SomeWidget
module Game.LupupuCube.UI.Constraints
module Game.LupupuCube.UI.Spring
Produced by Haddock version 2.1.0