~alcinnz/CatTrap

ref: 272852e8b518fb81dcd92d785f8284a713df0e2b CatTrap/Graphics/Layout/Box.hs -rw-r--r-- 957 bytes
272852e8 — Adrian Cochrane Draft new CatTrap API which hopefully is easier to implement. 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{-# LANGUAGE RecordWildCards #-}
module Graphics.Layout.Box where

data Border m n = Border {
    top :: m, bottom :: m, left :: n, right :: n
}
data Size m n = Size {inline :: n, block :: m}

data PaddedBox m n = PaddedBox {
    min :: Size m n,
    max :: Size m n,
    size :: Size m n,
    padding :: Border m n,
    border :: Border m n,
    margin :: Border m 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
minWidth PaddedBox {..} = left margin + left border + left padding +
    inline min + right padding + right border + right margin
minHeight PaddedBox {..} = top margin + top border + top padding +
    block min + bottom padding + bottom border + bottom margin

data Length = Pixels Double | Percent Double | Auto | Preferred | Min