~alcinnz/CatTrap

ref: d0a8a7d61e0a8340adcb597e0c8f94553dbaff81 CatTrap/Graphics/Layout/Box.hs -rw-r--r-- 671 bytes
d0a8a7d6 — Adrian Cochrane Finish drafting shunting yard interpreter for calc(). 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 = {
    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