cattrap-0.6.0.0: Lays out boxes according to the CSS Box Model.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Graphics.Layout

Description

Generic layout logic, handling a hierarchy of varying formulas. Unless callers have more specific needs they probably wish to use this abstraction. Attempts to follow the CSS specs. See boxLayout for a main entrypoint, & CSS to receive CSS input.

Synopsis

Documentation

data LayoutItem m n x Source #

A tree of different layout algorithms. More to come...

Constructors

LayoutFlow x (PaddedBox m n) [LayoutItem m n x]

A block element. With margins, borders, & padding.

LayoutGrid x (Grid m n) [GridItem] [LayoutItem m n x]

A grid or table element.

LayoutInline x (Paragraph (UserData m n x)) PageOptions

Some richtext. (Balkón holds children)

LayoutInline' x (ParagraphLayout (UserData m n x)) PageOptions

Results laying out richtext, has fixed width. Generated from LayoutInline for the sake of pagination.

LayoutConst x (PaddedBox m n) [LayoutItem m n x]

A branch with constant bounding box. Generated from LayoutInline when attaching position info.

LayoutSpan (FragmentTree (UserData m n x))

Children of a LayoutInline or LayoutInline'.

LayoutFlex x (Flex (LayoutItem m n x) m) 

Instances

Instances details
(Show n, Show m, Show x) => Show (LayoutItem m n x) Source # 
Instance details

Defined in Graphics.Layout

Methods

showsPrec :: Int -> LayoutItem m n x -> ShowS #

show :: LayoutItem m n x -> String #

showList :: [LayoutItem m n x] -> ShowS #

(PropertyParser x, Zero m, Zero n) => Default (UserData m n x) Source # 
Instance details

Defined in Graphics.Layout.CSS

Methods

def :: UserData m n x Source #

(Zero m, CastDouble m, NFData m, Zero n, CastDouble n, NFData n) => NFData (LayoutItem m n x) Source # 
Instance details

Defined in Graphics.Layout

Methods

rnf :: LayoutItem m n x -> () #

(Eq n, Eq m, Eq x) => Eq (LayoutItem m n x) Source # 
Instance details

Defined in Graphics.Layout

Methods

(==) :: LayoutItem m n x -> LayoutItem m n x -> Bool #

(/=) :: LayoutItem m n x -> LayoutItem m n x -> Bool #

type UserData m n x = ((Font', Int), Either (PaddedBox m n) (LayoutItem m n x), x) Source #

Additional data routed through Balkon.

layoutGetBox :: (Zero m, Zero n, CastDouble m, CastDouble n) => LayoutItem m n x -> PaddedBox m n Source #

Retrieve the surrounding box for a layout item.

layoutGetChilds :: (CastDouble b, CastDouble n, Eq b, Eq n, Eq x, Zero b, Zero n) => LayoutItem b n x -> [LayoutItem b n x] Source #

Retrieve the subtree under a node.

layoutGetInner :: LayoutItem m n x -> x Source #

Retrieve the caller-specified data attached to a layout node.

boxMinWidth :: (Zero y, CastDouble y, NFData y) => Maybe Double -> LayoutItem y Length x -> LayoutItem y Length x Source #

Update a (sub)tree to compute & cache minimum legible sizes.

boxMaxWidth :: (CastDouble y, Zero y, NFData y) => PaddedBox a Double -> LayoutItem y Length x -> LayoutItem y Length x Source #

Update a (sub)tree to compute & cache maximum legible width.

boxNatWidth :: (Zero y, CastDouble y, NFData y) => Maybe Double -> LayoutItem y Length x -> LayoutItem y Length x Source #

Update a (sub)tree to compute & cache ideal width.

boxWidth :: (Zero y, CastDouble y, NFData y) => PaddedBox b Double -> LayoutItem y Length x -> LayoutItem y Double x Source #

Update a (sub)tree to compute & cache final width.

boxNatHeight :: Double -> LayoutItem Length Double x -> LayoutItem Length Double x Source #

Update a (sub)tree to compute & cache ideal legible height.

boxMinHeight :: Double -> LayoutItem Length Double x -> LayoutItem Length Double x Source #

Update a (sub)tree to compute & cache minimum legible height.

boxMaxHeight :: PaddedBox Double Double -> LayoutItem Length Double x -> LayoutItem Length Double x Source #

Update a subtree to compute & cache maximum legible height.

boxHeight :: PaddedBox Double Double -> LayoutItem Length Double x -> LayoutItem Double Double x Source #

Update a (sub)tree to compute & cache final height.

boxSplit :: PropertyParser x => Double -> Double -> LayoutItem Double Double x -> (LayoutItem Double Double x, Maybe (LayoutItem Double Double x)) Source #

Split a (sub)tree to fit within max-height. May take full page height into account.

boxPaginate :: PropertyParser x => Double -> LayoutItem Double Double x -> [LayoutItem Double Double x] Source #

Generate a list of pages from a node, splitting subtrees where necessary.

boxPosition :: (PropertyParser x, Eq x) => (Double, Double) -> LayoutItem Double Double x -> LayoutItem Double Double ((Double, Double), x) Source #

Compute position of all nodes in the (sub)tree relative to a base coordinate.

boxLayout :: (PropertyParser x, Eq x) => PaddedBox Double Double -> LayoutItem Length Length x -> Bool -> [LayoutItem Double Double ((Double, Double), x)] Source #

Compute sizes & position information for all nodes in the (sub)tree.

glyphs :: FragmentTree x -> [(GlyphInfo, GlyphPos)] Source #

Retrieve Harfbuzz data out of the tree extracted from Balkón.

codepoints :: FragmentTree x -> [Word32] Source #

Retrieve the Unicode codepoints out of the tree extracted from Balkón.

fragmentFont :: FragmentTree (a, b, c) -> a Source #

Retrieve the font associated with inline layout.

glyphsPerFont :: (CastDouble x, CastDouble y, Eq x, Eq y, Eq z, Zero x, Zero y) => LayoutItem x y z -> Map (Pattern, Double) IntSet Source #

Compute a mapping from a layout tree indicating which glyphs for which fonts are required. Useful for assembling glyph atlases.

Orphan instances

Show PageOptions Source # 
Instance details

Eq PageOptions Source # 
Instance details

Show (Paragraph x) Source # 
Instance details

Eq (Paragraph x) Source # 
Instance details

Methods

(==) :: Paragraph x -> Paragraph x -> Bool #

(/=) :: Paragraph x -> Paragraph x -> Bool #