|
Game.LupupuCube.UI.Spring |
|
|
Description |
Calculates the space between widget edges, that are layed out by
Game.LupupuCube.UI.SpringLayout.
A Spring defines a minimum, preferred and maximum distance for each
edge (north, east, south, west) of a component.
However, springs are not static, their actual values are computed
at runtime. That means, if a Spring C is defined as the sum of
Spring A and Spring B, then the values (min, pref and max) are not
calculated at creation of Spring C, but instead always when
getValue is applied. So, when Spring A or Spring B changes, this
is reflected in Spring C.
|
|
Synopsis |
|
|
|
Documentation |
|
data Spring s d |
Spring s d is a data type which is parameterised on state s
and direction d. d is normally either Horizontal or
Vertical, and it is actually a phantom type to do merely type
checking.
| Constructors | forall i . SpringT s i => SP i | This constructor is exported for those who want to
define their own SpringT. It should not be used by
library users.
|
|
|
|
class SpringT s i where |
SpringT s i is a class which is parameterised on state s and
implementation i. It is exported for spring implementors.
| | Methods | minValue :: i -> ST s Int | minValue spr returns the minimum value of spring spr in
the ST monad.
| | prefValue :: i -> ST s Int | prefValue spr returns the preferred value of spring spr
in the ST monad.
| | maxValue :: i -> ST s Int | maxValue spr returns the maximum value of spring spr in
the ST monad.
| | getValue :: i -> ST s Int | getValue spr returns the current value of spring spr in
the ST monad.
| | setValue :: i -> Int -> ST s () | setValue spr val changes the value of spring spr to
val in the ST monad.
|
|
|
|
data Horizontal |
Horizontal is a phantom type whose value is never regarded. It
is used by Spring to parameterise it as a horizontal spring.
|
|
|
data Vertical |
Vertical is a phantom type whose value is never regarded. It is
used by Spring to parameterise it as a vertical spring.
|
|
|
unSP1 :: forall state dir ret. (forall impl. SpringT state impl => impl -> ST state ret) -> Spring state dir -> ST state ret |
|
unSP2 :: forall state dir arg ret. (forall impl. SpringT state impl => impl -> arg -> ST state ret) -> Spring state dir -> arg -> ST state ret |
|
fixed :: Int -> ST s (Spring s d) |
fixed n creates a spring whose min, pref and max values are
all the same n. These kind of springs are struts.
|
|
constant |
:: | | => Int | The minimum value.
| -> Int | The preferred value.
| -> Int | The maximum value.
| -> ST s (Spring s d) | | constant creates a spring which min, pref and max values are
constants.
|
|
|
widgetWidth :: Widget w => w -> ST s (Spring s Horizontal) |
widgetWidth w creates a fixed spring whose value is the
width of minSize w.
|
|
widgetHeight :: Widget w => w -> ST s (Spring s Vertical) |
widgetHeight w creates a fixed spring whose value is the
height of minSize w.
|
|
(|+|) :: ST s (Spring s d) -> ST s (Spring s d) -> ST s (Spring s d) |
a |+| b creates a spring which is always the sum of a and
b.
|
|
(|-|) :: ST s (Spring s d) -> ST s (Spring s d) -> ST s (Spring s d) |
a |-| b creates a spring which is always the subtraction a -
b (i.e. a |+| neg b).
|
|
neg :: ST s (Spring s d) -> ST s (Spring s d) |
neg a creates a spring which is always the negation of a.
|
|
maxSpr :: ST s (Spring s d) -> ST s (Spring s d) -> ST s (Spring s d) |
maxSpr a b creates a spring which always has the maximum
values among a and b.
|
|
Produced by Haddock version 2.1.0 |