~alcinnz/CatTrap

ref: 3dce4d79a99984588660089433a6a7eb78701300 CatTrap/Graphics/Layout/Box.hs -rw-r--r-- 681 bytes
3dce4d79 — Adrian Cochrane Unit test calc() implementation! 1 year, 9 months ago
                                                                                
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