Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Boxes are rectangular shapes used for layouting. They are consisting of several quads having a relative position to each other:
- "inner boxes" are used for aligning several boxes together
- "outer boxes" describe the logical extent
- "bounding boxes" are the bounding boxes of the actual content abstracted by the box
- "gap boxes" control the gap between boxes placed next to each other.
Relative boxes has their origin at the top-left corner of their inner box. Absolute boxes has an absolute offset.
We use screen-space coordinate system (Y increase downwards).
In case of font glyphs, the inner box has height 0, and it coincides with the base line of the glyph; while the outer box is defined by the ascent and the descent. Both have horizontal dimensions equal to the advance width.
Synopsis
- data Quad = Quad {
- quadTopLeft :: !(Double, Double)
- quadBotRight :: !(Double, Double)
- quadTopRight :: Quad -> (Double, Double)
- quadBotLeft :: Quad -> (Double, Double)
- quadL :: Quad -> Double
- quadR :: Quad -> Double
- quadT :: Quad -> Double
- quadB :: Quad -> Double
- quadWidth :: Quad -> Double
- quadHeight :: Quad -> Double
- quadSize :: Quad -> (Double, Double)
- zeroQuad :: Quad
- quadLUB :: Quad -> Quad -> Quad
- quadsLUB :: [Quad] -> Quad
- ofsLUB :: (Pos, Quad) -> (Pos, Quad) -> Quad
- marginQuad :: Margin -> Quad -> Quad
- data Box = Box {
- boxInnerSize :: !(Double, Double)
- boxOuterQuad :: !Quad
- boxBoundingQuad :: !Quad
- boxGapQuad :: !Quad
- boxInnerQuad :: Box -> Quad
- boxInnerWidth :: Box -> Double
- boxInnerHeight :: Box -> Double
- emptyBox :: Box
- shiftBox :: Pos -> Box -> Box
- boxSelectQuad :: WhichQuad -> Box -> Quad
- data WhichQuad
- realignBox :: WhichQuad -> Box -> (Pos, Box)
- trimBox :: Box -> Box
- data AbsBox = AbsBox {
- _aboxOffset :: !Pos
- _aboxRelBox :: !Box
- absboxInnerQuad :: AbsBox -> Quad
- absboxOuterQuad :: AbsBox -> Quad
- absboxBoundingQuad :: AbsBox -> Quad
- absboxGapQuad :: AbsBox -> Quad
- absboxSelectQuad :: WhichQuad -> AbsBox -> Quad
- hcatBox :: VAlign -> Box -> Box -> (Box, (Pos, Pos))
- vcatBox :: HAlign -> Box -> Box -> (Box, (Pos, Pos))
- hcatBox2 :: VAlign -> Box -> Box -> (Box, (AbsBox, AbsBox))
- vcatBox2 :: HAlign -> Box -> Box -> (Box, (AbsBox, AbsBox))
- hcatBoxes :: VAlign -> [Box] -> (Box, [AbsBox])
- vcatBoxes :: HAlign -> [Box] -> (Box, [AbsBox])
- overlayBox :: HAlign -> VAlign -> Box -> Box -> (Box, (Pos, Pos))
- overlayBox2 :: HAlign -> VAlign -> Box -> Box -> (Box, (AbsBox, AbsBox))
- overlayBoxes :: HAlign -> VAlign -> [Box] -> (Box, [AbsBox])
- subSupScriptBox :: Box -> (Double, Box) -> (Double, Box) -> (Box, (Pos, Pos))
- aboveBelowBox :: Box -> (Pos, Box) -> (Pos, Box) -> (Box, (Pos, Pos))
- fractionBox :: Double -> Box -> Box -> (Box, (Pos, Pos))
- delimiterBox :: (Box, Box, Box) -> [Box] -> (Box, [Pos])
- interleave :: [a] -> [a] -> [a]
- odds :: [a] -> [a]
- evens :: [a] -> [a]
Quads
A quad is a rectangular region, defined by its top-left and bottom-right corner
Quad | |
|
quadHeight :: Quad -> Double Source #
quadsLUB :: [Quad] -> Quad Source #
Because it really should be a semigroup and not a monoid, it's important that it's not implemented with foldl..
Boxes
A (relative) box
Box | |
|
boxInnerQuad :: Box -> Quad Source #
boxInnerWidth :: Box -> Double Source #
boxInnerHeight :: Box -> Double Source #
Enumerating the four different quads in a Box
realignBox :: WhichQuad -> Box -> (Pos, Box) Source #
Replace the inner box by the given box. Since the inner box is used for alignment, this amounts to changing the alignment
Absolute boxes
An absolute box
AbsBox | |
|
absboxInnerQuad :: AbsBox -> Quad Source #
absboxOuterQuad :: AbsBox -> Quad Source #
absboxBoundingQuad :: AbsBox -> Quad Source #
absboxGapQuad :: AbsBox -> Quad Source #
Concatenating boxes
hcatBox :: VAlign -> Box -> Box -> (Box, (Pos, Pos)) Source #
Concatantes two boxes horizontally, using the inner boxes to align them. The two positions we return are relative positions of the two boxes from the origin (top-left inner corner) of the concatenated box.
vcatBox :: HAlign -> Box -> Box -> (Box, (Pos, Pos)) Source #
Concatantes two boxes vertically, using the inner boxes to align them. The two positions we return are relative positions of the two boxes from the origin (top-left inner corner) of the concatenated box.
Overlay boxes
overlayBox :: HAlign -> VAlign -> Box -> Box -> (Box, (Pos, Pos)) Source #
Overlay two boxes (so the corners given by the alignments coincide)
Subscripts and superscripts
subSupScriptBox :: Box -> (Double, Box) -> (Double, Box) -> (Box, (Pos, Pos)) Source #
Subscripts/superscripts are special enough that it seems simpler to just add a specific combinator for them.
Above and below
aboveBelowBox :: Box -> (Pos, Box) -> (Pos, Box) -> (Box, (Pos, Pos)) Source #
Positions are relative!
Fraction
delimiters
interleave :: [a] -> [a] -> [a] Source #