1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{-# LANGUAGE RecordWildCards #-}
module Graphics.Layout.Box where
data Border n = Border {
top :: n, bottom :: n, left :: n, right :: n
}
data Size n = Size {inline :: n, block :: n}
data PaddedBox n = PaddedBox {
min :: Size n,
max :: Size n,
size :: Size n,
padding :: Border n,
border :: Border n,
margin :: Border n
}
width' PaddedBox {..} = left margin + left border + left padding +
inline size + right padding + right border + right margin
height' PaddedBox {..} = top margin + top border + top padding +
block size + bottom padding + bottom border + bottom margin
data Length = Pixels Double | Percent Double | Auto | Preferred | Min