-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Lays out boxes according to the CSS Box Model. -- -- Computes where to place e.g. images, paragraphs, containers, tables, -- etc onscreen given desired amounts of whitespace. @package cattrap @version 0.3.0.0 -- | (Unused) Parses & evaluates calc() expressions. Implemented using -- The Shunting Yard Algorithm. module Graphics.Layout.Arithmetic -- | Parsed calc() expression. As a postfix arithmatic expression. data Opcode n Seq :: Opcode n Add :: Opcode n Subtract :: Opcode n Multiply :: Opcode n Divide :: Opcode n Func :: Text -> Opcode n Num :: n -> Opcode n -- | Parse a calc() expression. parseCalc :: [Token] -> [Opcode (Float, String)] -> [Opcode (Float, String)] -- | Verify that a parsed math expression can be properly evaluated. verifyCalc :: [Opcode (Float, String)] -> [Bool] -> Bool -- | Evaluate a parsed calc() expression. evalCalc :: [Opcode Float] -> [Float] -> Float -- | Convert all numbers in an expression via the given callback. mapCalc :: (a -> b) -> [Opcode a] -> [Opcode b] instance GHC.Show.Show n => GHC.Show.Show (Graphics.Layout.Arithmetic.Opcode n) -- | Datastructures representing the CSS box model, & utilities for -- operating on them. module Graphics.Layout.Box -- | Amount of space surrounding the box. data Border m n Border :: m -> m -> n -> n -> Border m n [top] :: Border m n -> m [bottom] :: Border m n -> m [left] :: Border m n -> n [right] :: Border m n -> n -- | Convert horizontal spacing via given callback. mapX :: (n -> nn) -> Border m n -> Border m nn -- | Convert vertical spacing via given callback. mapY :: (m -> mm) -> Border m n -> Border mm n -- | 2D size of a box. Typically inline is width & block is height. -- This may change as support for vertical layout is added. data Size m n Size :: n -> m -> Size m n [inline] :: Size m n -> n [block] :: Size m n -> m -- | Convert block size via given callback mapSizeX :: (n -> nn) -> Size m n -> Size m nn -- | Convert inline size via given callback mapSizeY :: (m -> mm) -> Size m n -> Size mm n -- | A box with min & max bounds & surrounding borders. The CSS Box -- Model. data PaddedBox m n PaddedBox :: Size m n -> Size m n -> Size Double Double -> Size m n -> Border m n -> Border m n -> Border m n -> PaddedBox m n -- | The minimum amount of pixels this box should take. [min] :: PaddedBox m n -> Size m n -- | The maximum amount of pixels this box should take. [max] :: PaddedBox m n -> Size m n -- | The ideal number of pixels this box should take. [nat] :: PaddedBox m n -> Size Double Double -- | The amount of pixels this box should take. [size] :: PaddedBox m n -> Size m n -- | The amount of space between the box & the border. [padding] :: PaddedBox m n -> Border m n -- | The amount of space for the border. [border] :: PaddedBox m n -> Border m n -- | The amount of space between the border & anything else. [margin] :: PaddedBox m n -> Border m n -- | An empty box, takes up nospace onscreen. zeroBox :: PaddedBox Double Double -- | A box which takes up all available space with no borders. lengthBox :: PaddedBox Length Length -- | Convert all sizes along the inline axis via given callback. mapX' :: (n -> nn) -> PaddedBox m n -> PaddedBox m nn -- | Convert all sizes along the block axis via given callback. mapY' :: (m -> mm) -> PaddedBox m n -> PaddedBox mm n -- | The total size along the inline axis including borders, etc. width :: Num a => PaddedBox m a -> a -- | The total size along the block axis, including borders, etc. height :: Num a => PaddedBox a n -> a -- | The total minimum size along the inline axis. minWidth :: Num a => PaddedBox m a -> a -- | The total minimum size along the block axis. minHeight :: Num a => PaddedBox a n -> a -- | The total maximum size along the inline axis. maxWidth :: Num a => PaddedBox m a -> a -- | The total maximum size along the block axis. maxHeight :: Num a => PaddedBox a n -> a leftSpace :: Num a => PaddedBox m a -> a rightSpace :: Num a => PaddedBox m a -> a topSpace :: Num a => PaddedBox a n -> a bottomSpace :: Num a => PaddedBox a n -> a hSpace :: Num a => PaddedBox m a -> a vSpace :: Num a => PaddedBox a n -> a -- | A partially-computed length value. data Length -- | Absolute number of device pixels. Pixels :: Double -> Length -- | Multiplier by container width. Percent :: Double -> Length -- | Use normal layout computations. Auto :: Length -- | Use computed preferred width. Preferred :: Length -- | Use minimum legible width. Min :: Length -- | Replace keywords with a given number of pixels. Useful for avoiding -- messing up percentage calculations in later processing. mapAuto :: Double -> Length -> Length -- | Convert a length given the container's width. Filling in 0 for -- keywords. If you wish for keywords to be handled differently, callers -- need to compute that themselves. lowerLength :: Double -> Length -> Double class Zero a -- | Return the empty (or zero) value for a CatTrap geometric type. zero :: Zero a => a class CastDouble a -- | Convert a double to a double or length. fromDouble :: CastDouble a => Double -> a -- | Convert a double or length to a double. toDouble :: CastDouble a => a -> Double instance GHC.Generics.Generic (Graphics.Layout.Box.Border m n) instance (GHC.Show.Show m, GHC.Show.Show n) => GHC.Show.Show (Graphics.Layout.Box.Border m n) instance (GHC.Read.Read m, GHC.Read.Read n) => GHC.Read.Read (Graphics.Layout.Box.Border m n) instance (GHC.Classes.Eq m, GHC.Classes.Eq n) => GHC.Classes.Eq (Graphics.Layout.Box.Border m n) instance GHC.Generics.Generic (Graphics.Layout.Box.Size m n) instance (GHC.Read.Read n, GHC.Read.Read m) => GHC.Read.Read (Graphics.Layout.Box.Size m n) instance (GHC.Show.Show n, GHC.Show.Show m) => GHC.Show.Show (Graphics.Layout.Box.Size m n) instance (GHC.Classes.Eq n, GHC.Classes.Eq m) => GHC.Classes.Eq (Graphics.Layout.Box.Size m n) instance GHC.Generics.Generic (Graphics.Layout.Box.PaddedBox m n) instance (GHC.Show.Show n, GHC.Show.Show m) => GHC.Show.Show (Graphics.Layout.Box.PaddedBox m n) instance (GHC.Read.Read n, GHC.Read.Read m) => GHC.Read.Read (Graphics.Layout.Box.PaddedBox m n) instance (GHC.Classes.Eq n, GHC.Classes.Eq m) => GHC.Classes.Eq (Graphics.Layout.Box.PaddedBox m n) instance GHC.Generics.Generic Graphics.Layout.Box.Length instance GHC.Show.Show Graphics.Layout.Box.Length instance GHC.Read.Read Graphics.Layout.Box.Length instance GHC.Classes.Eq Graphics.Layout.Box.Length instance Graphics.Layout.Box.CastDouble GHC.Types.Double instance Graphics.Layout.Box.CastDouble Graphics.Layout.Box.Length instance Graphics.Layout.Box.Zero GHC.Types.Double instance Graphics.Layout.Box.Zero Graphics.Layout.Box.Length instance (Graphics.Layout.Box.Zero m, Graphics.Layout.Box.Zero n) => Graphics.Layout.Box.Zero (Graphics.Layout.Box.PaddedBox m n) instance Control.DeepSeq.NFData Graphics.Layout.Box.Length instance (Control.DeepSeq.NFData m, Control.DeepSeq.NFData n) => Control.DeepSeq.NFData (Graphics.Layout.Box.PaddedBox m n) instance (Control.DeepSeq.NFData m, Control.DeepSeq.NFData n) => Control.DeepSeq.NFData (Graphics.Layout.Box.Size m n) instance (Control.DeepSeq.NFData m, Control.DeepSeq.NFData n) => Control.DeepSeq.NFData (Graphics.Layout.Box.Border m n) -- | Infrastructure for parsing & desugaring length units & -- keywords, in reference to the selected font. module Graphics.Layout.CSS.Length -- | A number+unit, prior to resolving side units. The unit may alternately -- represent a keyword, in which case the number is ignored & -- typically set to 0. type Unitted = (Double, Text) -- | The CSS auto keyword. auto :: Unitted -- | Parse a pre-tokenized CSS length value. parseLength :: [Token] -> Maybe Unitted -- | Variant of parseLength which supports min-content & -- max-content keywords. parseLength' :: [Token] -> Maybe (Double, Text) -- | Supported length units. units :: [Text] -- | Convert a lexed number to a Double. n2f :: (Fractional x, RealFloat x) => NumericValue -> x -- | Resolve a parsed length according to the sizing parameters in a given -- Font`. finalizeLength :: Unitted -> Font' -> Length -- | Convert any length-units in the given CSS tokens to device pixels finalizeLengths :: Font' -> [Token] -> [Token] -- | Convert from a computed length to the "pt" unit. px2pt :: Font' -> Double -> Double -- | A Harfbuzz font with sizing parameters. data Font' Font' :: Font -> Pattern -> (Char -> Double) -> (Char -> Double) -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Font' -- | The Harfbuzz font used to shape text & query character-size -- information. [hbFont] :: Font' -> Font -- | The FontConfig query result. Useful to incorporate into output -- rendering. [pattern] :: Font' -> Pattern -- | Query the height of a character. Used for cap, ex, or ic units. [fontHeight] :: Font' -> Char -> Double -- | Query the width of a character, used for ch unit. [fontAdvance] :: Font' -> Char -> Double -- | The desired font-size, used for em unit. [fontSize] :: Font' -> Double -- | The root font's size, used for rem unit. [rootEm] :: Font' -> Double -- | The desired line-height, used for lh unit. [lineheight] :: Font' -> Double -- | The root font's line-height, used for rlh unit. [rlh] :: Font' -> Double -- | Scale-factor for vh unit. [vh] :: Font' -> Double -- | Scale-factor for vw unit. [vw] :: Font' -> Double -- | Scale-factor for vmax unit. [vmax] :: Font' -> Double -- | Scale-factor for vmin unit. [vmin] :: Font' -> Double -- | How many device pixels in a CSS px? [scale] :: Font' -> Double instance GHC.Classes.Eq Graphics.Layout.CSS.Length.Font' -- | Infrastructure for parsing & desugaring CSS properties related to -- fonts. module Graphics.Layout.CSS.Font -- | A Harfbuzz font with sizing parameters. data Font' Font' :: Font -> Pattern -> (Char -> Double) -> (Char -> Double) -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Font' -- | The Harfbuzz font used to shape text & query character-size -- information. [hbFont] :: Font' -> Font -- | The FontConfig query result. Useful to incorporate into output -- rendering. [pattern] :: Font' -> Pattern -- | Query the height of a character. Used for cap, ex, or ic units. [fontHeight] :: Font' -> Char -> Double -- | Query the width of a character, used for ch unit. [fontAdvance] :: Font' -> Char -> Double -- | The desired font-size, used for em unit. [fontSize] :: Font' -> Double -- | The root font's size, used for rem unit. [rootEm] :: Font' -> Double -- | The desired line-height, used for lh unit. [lineheight] :: Font' -> Double -- | The root font's line-height, used for rlh unit. [rlh] :: Font' -> Double -- | Scale-factor for vh unit. [vh] :: Font' -> Double -- | Scale-factor for vw unit. [vw] :: Font' -> Double -- | Scale-factor for vmax unit. [vmax] :: Font' -> Double -- | Scale-factor for vmin unit. [vmin] :: Font' -> Double -- | How many device pixels in a CSS px? [scale] :: Font' -> Double -- | zero'd Font` to serve as the root's parent in a font heirarchy. placeholderFont :: Font' -- | Scale-factor for text-shaping APIs. hbUnit :: Double -- | Convert from FontConfig query result to a Harfbuzz font. pattern2hbfont :: Pattern -> Int -> [Variation] -> Font -- | Convert Parsed CSS to a Font`. Includes sizing parameters -- derived from a root & parent Font`. pattern2font :: Pattern -> CSSFont -> Font' -> Font' -> Font' -- | Parsed CSS font properties, excluding the FontConfig query. data CSSFont CSSFont :: Unitted -> Unitted -> [Variation] -> Variation -> Variation -> Variation -> Bool -> CSSFont -- | Parsed CSS font-size. [cssFontSize] :: CSSFont -> Unitted -- | Parsed CSS line-height. [cssLineheight] :: CSSFont -> Unitted -- | Parsed CSS font-variation-settings. [variations] :: CSSFont -> [Variation] -- | Parsed CSS font-weight. [weightVariation] :: CSSFont -> Variation -- | Parsed CSS font-stretch. [widthVariation] :: CSSFont -> Variation -- | Parsed CSS font-style. [slantVariation] :: CSSFont -> Variation -- | Parsed CSS font-optical-sizing. [opticalSize] :: CSSFont -> Bool -- | All font-variations from the parsed CSS properties. | Requires the -- resolved font-size in case font-optical-sizing is set. variations' :: Double -> CSSFont -> [Variation] instance Stylist.PropertyParser Graphics.Layout.CSS.Font.CSSFont -- | Sizes a block element & positions their children. Taking into -- account size bounds. module Graphics.Layout.Flow -- | Compute the minimum width of a block element with children of the -- given sizes. flowMinWidth :: Double -> PaddedBox a Length -> [PaddedBox b Double] -> Double -- | Compute the natural width of a block element with children of the -- given sizes. flowNatWidth :: Double -> PaddedBox a Length -> [PaddedBox b Double] -> Double -- | Compute the maximum width of a block element inside the given parent -- size. flowMaxWidth :: PaddedBox a Double -> PaddedBox b Length -> Double -- | Compute final block element width based on cached width computations -- & parent size. flowWidth :: PaddedBox a Double -> PaddedBox b Length -> Double -- | Compute natural block element height at cached width. flowNatHeight :: Double -> PaddedBox Length Double -> [PaddedBox Double Double] -> Double -- | Compute minimum block height at cached width. flowMinHeight :: Double -> PaddedBox Length Double -> Double -- | Compute maximum block height at cached width. flowMaxHeight :: Double -> PaddedBox Length Double -> Double -- | Compute final block height at cached width. flowHeight :: PaddedBox Double Double -> PaddedBox Length Double -> Double -- | Compute position of all children relative to this block element. positionFlow :: [PaddedBox Double Double] -> [Size Double Double] -- | Compute size given block element in given parent, & position of -- given children. layoutFlow :: PaddedBox Double Double -> PaddedBox Length Length -> [PaddedBox Length Double] -> (PaddedBox Double Double, [(Size Double Double, PaddedBox Double Double)]) -- | Sizes grid cells & positions elements to them. module Graphics.Layout.Grid -- | An element which positions it's children within a grid. type Grid m n = Size (Track m) (Track n) -- | The sizes to which children are alonged on a single axis. data Track x Track :: [Either x Double] -> [Double] -> [Double] -> x -> Track x -- | The desired size of each cell. If Left specifies ratio of excess space -- to use. [cells] :: Track x -> [Either x Double] -- | The minimum amount of space each cell should take. [trackMins] :: Track x -> [Double] -- | The ideal amount of space each cell should take. [trackNats] :: Track x -> [Double] -- | How much space to add between cells. [gap] :: Track x -> x -- | Which cells a child should be aligned to. type GridItem = Size GridItem' GridItem' -- | How a grid child should be aligned per-axis. data GridItem' GridItem :: Int -> Int -> Alignment -> Double -> Double -> GridItem' -- | On which cell should this child start. [cellStart] :: GridItem' -> Int -- | Before which cell should this child end. [cellEnd] :: GridItem' -> Int -- | How to redistribute excess space. [alignment] :: GridItem' -> Alignment -- | The minimum amount of space to allocate to this child. [minSize] :: GridItem' -> Double -- | The maximum aount of space to allocate to this child. [natSize] :: GridItem' -> Double -- | How to redistribute excess space. data Alignment Start :: Alignment Mid :: Alignment End :: Alignment -- | Constructs a track with default (to-be-computed) values & given -- cell sizes. buildTrack :: CastDouble x => [Either x Double] -> Track x -- | Constructs a grid with default (to-be-computed) values & given -- cell sizes. buildGrid :: (CastDouble m, CastDouble n) => [Either m Double] -> [Either n Double] -> Grid m n -- | Sets minimum & natural sizes from the given padded box. setCellBox :: (CastDouble m, CastDouble n) => GridItem -> PaddedBox m n -> GridItem -- | Utility for associate an index with each item in a list. enumerate :: [b] -> [(Int, b)] -- | Compute the maximum size as a PaddedBox of a child, for it to be sized -- to. gridItemBox :: (CastDouble x, CastDouble y) => Grid y x -> GridItem -> PaddedBox Double Double cellSize :: CastDouble x => Track x -> GridItem' -> Double -- | Compute the minimum size for the track given cell sizes. Refers to -- computed min sizes if cached. trackMin :: (n -> Double) -> Track n -> Double -- | Compute the natural size for the track given cell sizes. Refers to -- compute natural sizes if cached. trackNat :: (n -> Double) -> Track n -> Double -- | Estimate grid width to inform proper width calculation. gridEstWidth :: Grid y Length -> [GridItem] -> Double -- | Calculate minimum sizes for all cells in the track. Sized to fit given -- children. sizeTrackMins :: Double -> Track Length -> [GridItem'] -> [Double] -- | Compute natural sizes for all cells in the track. Sized to fit given -- children. sizeTrackNats :: Double -> Track Length -> [GridItem'] -> [Double] -- | Compute maximum sizes for all cells in the track, sized to the parent -- element. sizeTrackMaxs :: Double -> Track Length -> [Double] -- | Compute the position of all children within the grid. trackPosition :: Track Double -> [GridItem'] -> [Double] -- | Compute the position of all children in a grid. gridPosition :: Grid Double Double -> [GridItem] -> [(Double, Double)] -- | Compute the track sizes & child positions along a single axis. trackLayout :: Double -> Double -> Track Length -> [GridItem'] -> (Track Double, [(Double, GridItem')]) -- | Compute the track sizes & child positions along both axes. gridLayout :: Size Double Double -> Grid Length Length -> [GridItem] -> (Grid Double Double, [((Double, Double), GridItem)]) instance GHC.Generics.Generic Graphics.Layout.Grid.Alignment instance GHC.Classes.Eq Graphics.Layout.Grid.Alignment instance GHC.Classes.Ord Graphics.Layout.Grid.Alignment instance GHC.Enum.Enum Graphics.Layout.Grid.Alignment instance GHC.Show.Show Graphics.Layout.Grid.Alignment instance GHC.Read.Read Graphics.Layout.Grid.Alignment instance GHC.Generics.Generic Graphics.Layout.Grid.GridItem' instance GHC.Classes.Eq Graphics.Layout.Grid.GridItem' instance GHC.Classes.Ord Graphics.Layout.Grid.GridItem' instance GHC.Show.Show Graphics.Layout.Grid.GridItem' instance GHC.Read.Read Graphics.Layout.Grid.GridItem' instance Control.DeepSeq.NFData Graphics.Layout.Grid.GridItem' instance Control.DeepSeq.NFData Graphics.Layout.Grid.Alignment -- | Sizes inline text & extracts positioned children, wraps Balkón for -- the actual logic. module Graphics.Layout.Inline -- | Apply an operation to the 2nd field of the paragraph's userdata, for -- it's entire subtree. paragraphMap :: (b -> b') -> Paragraph (a, b, c) -> Paragraph (a, b', c) -- | Apply an operation to the 2nd field of a laid-out paragraph's -- userdata, for it's entire subtree. layoutMap :: (b -> b') -> ParagraphLayout (a, b, c) -> ParagraphLayout (a, b', c) -- | Apply an operation to the 2nd field of the tree extracted from a -- laid-out paragraph, for all nodes. treeMap :: (b -> b') -> FragmentTree (a, b, c) -> FragmentTree (a, b', c) -- | Compute minimum width & height for some richtext. inlineMin :: (CastDouble x, CastDouble y) => Paragraph (a, PaddedBox x y, c) -> Size x y -- | Compute width & height of some richtext at configured width. inlineSize :: (CastDouble x, CastDouble y) => Paragraph (a, PaddedBox x y, c) -> Size x y -- | Retrieve children out of some richtext, associating given userdata -- with them. inlineChildren :: (CastDouble x, CastDouble y, Eq x, Eq y, Eq a, Eq c) => Paragraph (a, PaddedBox x y, c) -> [FragmentTree (a, PaddedBox x y, c)] -- | Retrieve a laid-out paragraph's rect & convert to CatTrap types. layoutSize :: (CastDouble x, CastDouble y) => ParagraphLayout a -> Size x y -- | Retrieve a laid-out paragraph's children & associate with given -- userdata. layoutChildren :: Eq a => ParagraphLayout a -> [FragmentTree a] -- | Compute the paddedbox for a subtree. treeBox :: (CastDouble m, CastDouble n) => FragmentTree (a, PaddedBox m n, c) -> PaddedBox m n positionTree :: (CastDouble m, CastDouble n) => (Double, Double) -> FragmentTree (a, PaddedBox m n, c) -> FragmentTree (a, PaddedBox m n, ((Double, Double), c)) treeInner :: FragmentTree (a, b, c) -> c data FragmentTree x Branch :: AncestorBox x -> [FragmentTree x] -> FragmentTree x Leaf :: Fragment x -> FragmentTree x -- | 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. module Graphics.Layout -- | A tree of different layout algorithms. More to come... data LayoutItem m n x -- | A block element. With margins, borders, & padding. LayoutFlow :: x -> PaddedBox m n -> [LayoutItem m n x] -> LayoutItem m n x -- | A grid or table element. LayoutGrid :: x -> Grid m n -> [GridItem] -> [LayoutItem m n x] -> LayoutItem m n x -- | Some richtext. (Balkón holds children) LayoutInline :: x -> Paragraph (UserData m n x) -> PageOptions -> LayoutItem m n x -- | Results laying out richtext, has fixed width. Generated from -- LayoutInline for the sake of pagination. LayoutInline' :: x -> ParagraphLayout (UserData m n x) -> PageOptions -> LayoutItem m n x -- | A branch with constant bounding box. Generated from -- LayoutInline when attaching position info. LayoutConst :: x -> PaddedBox m n -> [LayoutItem m n x] -> LayoutItem m n x -- | Children of a LayoutInline or LayoutInline`. LayoutSpan :: FragmentTree (UserData m n x) -> LayoutItem m n x -- | Additional data routed through Balkon. type UserData m n x = ((Font', Int), PaddedBox m n, x) layoutGetBox :: (Zero m, Zero n, CastDouble m, CastDouble n) => LayoutItem m n x -> PaddedBox m n -- | Retrieve the subtree under a node. layoutGetChilds :: (CastDouble m, CastDouble n, Eq m, Eq n, Eq x) => LayoutItem m n x -> [LayoutItem m n x] -- | Retrieve the caller-specified data attached to a layout node. layoutGetInner :: LayoutItem m n x -> x -- | Update a (sub)tree to compute & cache minimum legible sizes. boxMinWidth :: (Zero y, CastDouble y, NFData y) => Maybe Double -> LayoutItem y Length x -> LayoutItem y Length x -- | Update a (sub)tree to compute & cache maximum legible width. boxMaxWidth :: (CastDouble y, Zero y, NFData y) => PaddedBox a Double -> LayoutItem y Length x -> LayoutItem y Length x -- | Update a (sub)tree to compute & cache ideal width. boxNatWidth :: (Zero y, CastDouble y, NFData y) => Maybe Double -> LayoutItem y Length x -> LayoutItem y Length x -- | Update a (sub)tree to compute & cache final width. boxWidth :: (Zero y, CastDouble y, NFData y) => PaddedBox b Double -> LayoutItem y Length x -> LayoutItem y Double x -- | Update a (sub)tree to compute & cache ideal legible height. boxNatHeight :: Double -> LayoutItem Length Double x -> LayoutItem Length Double x -- | Update a (sub)tree to compute & cache minimum legible height. boxMinHeight :: Double -> LayoutItem Length Double x -> LayoutItem Length Double x -- | Update a subtree to compute & cache maximum legible height. boxMaxHeight :: PaddedBox Double Double -> LayoutItem Length Double x -> LayoutItem Length Double x -- | Update a (sub)tree to compute & cache final height. boxHeight :: PaddedBox Double Double -> LayoutItem Length Double x -> LayoutItem Double Double x -- | Split a (sub)tree to fit within max-height. May take full page height -- into account. boxSplit :: PropertyParser x => Double -> Double -> LayoutItem Double Double x -> (LayoutItem Double Double x, Maybe (LayoutItem Double Double x)) -- | Generate a list of pages from a node, splitting subtrees where -- necessary. boxPaginate :: PropertyParser x => Double -> LayoutItem Double Double x -> [LayoutItem Double Double x] -- | Compute position of all nodes in the (sub)tree relative to a base -- coordinate. boxPosition :: (PropertyParser x, Eq x) => (Double, Double) -> LayoutItem Double Double x -> LayoutItem Double Double ((Double, Double), x) -- | Compute sizes & position information for all nodes in the -- (sub)tree. boxLayout :: (PropertyParser x, Eq x) => PaddedBox Double Double -> LayoutItem Length Length x -> Bool -> [LayoutItem Double Double ((Double, Double), x)] instance (Graphics.Layout.Box.Zero m, Graphics.Layout.Box.CastDouble m, Control.DeepSeq.NFData m, Graphics.Layout.Box.Zero n, Graphics.Layout.Box.CastDouble n, Control.DeepSeq.NFData n) => Control.DeepSeq.NFData (Graphics.Layout.LayoutItem m n x) -- | Infrastructure for parsing & desugaring grid-layout related CSS -- properties. module Graphics.Layout.Grid.CSS -- | Parsed CSS Grid properties data CSSGrid CSSGrid :: Unitted -> Axis -> Bool -> Unitted -> Areas -> [([Text], Unitted)] -> [([Text], Unitted)] -> Size Unitted Unitted -> Size Alignment Alignment -> CSSGrid -- | Parsed CSS grid-auto-columns [autoColumns] :: CSSGrid -> Unitted -- | Parsed grid-auto-flow [autoFlow] :: CSSGrid -> Axis -- | Whether grid-auto-flow: dense was specified. [autoFlowDense] :: CSSGrid -> Bool -- | Parsed CSS grid-auto-rows [autoRows] :: CSSGrid -> Unitted -- | Parsed CSS grid-template-areas [templateAreas] :: CSSGrid -> Areas -- | Parsed CSS grid-template-columns [templateColumns] :: CSSGrid -> [([Text], Unitted)] -- | Parsed CSS grid-template-rows [templateRows] :: CSSGrid -> [([Text], Unitted)] -- | Parsed CSS row-gap & column-gap [cssGap] :: CSSGrid -> Size Unitted Unitted -- | Parsed CSS justify-items & align-items [alignItems] :: CSSGrid -> Size Alignment Alignment -- | A grid axis. data Axis Row :: Axis Col :: Axis -- | Parsed CSS grid item properties. data CSSCell CSSCell :: Placement -> Placement -> Placement -> Placement -> Size (Maybe Alignment) (Maybe Alignment) -> CSSCell -- | Parsed CSS grid-column-start [columnStart] :: CSSCell -> Placement -- | Parsed CSS grid-column-end [columnEnd] :: CSSCell -> Placement -- | Parsed CSS grid-row-start [rowStart] :: CSSCell -> Placement -- | Parsed CSS grid-row-end [rowEnd] :: CSSCell -> Placement -- | Parsed CSS align-self & justify-self [alignSelf] :: CSSCell -> Size (Maybe Alignment) (Maybe Alignment) -- | Identifies a cell in the CSS grid. data Placement Autoplace :: Placement Named :: Text -> Placement Numbered :: Int -> Maybe Text -> Placement Span :: Int -> Maybe Text -> Placement -- | Desugar grid properties to a grid layout. finalizeGrid :: PropertyParser x => CSSGrid -> Font' -> [CSSCell] -> [LayoutItem Length Length x] -> LayoutItem Length Length x type Areas = HashMap Text ((Int, Int), (Int, Maybe Int)) -- | Converts a grid to lookup table start & indices for row & -- columns. Exported for the sake of testing parseASCIIGrid :: [[Text]] -> Int -> Areas -> Maybe Areas instance GHC.Classes.Eq Graphics.Layout.Grid.CSS.Axis instance Stylist.PropertyParser Graphics.Layout.Grid.CSS.CSSCell instance Stylist.PropertyParser Graphics.Layout.Grid.CSS.CSSGrid -- | Infrastructure for parsing & desugaring text related CSS -- properties. module Graphics.Layout.Inline.CSS -- | Document text with Balkón styling options, CSS stylable. data CSSInline CSSInline :: Text -> TextOptions -> UnicodeBidi -> CSSInline class Default a def :: Default a => a -- | To what degree is the text direction isolated? data UnicodeBidi BdNormal :: UnicodeBidi BdEmbed :: UnicodeBidi BdOverride :: UnicodeBidi BdIsolate :: UnicodeBidi BdIsolateOverride :: UnicodeBidi BdPlainText :: UnicodeBidi applyFontInline :: TextOptions -> Font' -> TextOptions -- | Apply Bidi chars around the inline text. FIXME: Handle the tree! applyBidi :: Default d => CSSInline -> [InnerNode Text d] -> [InnerNode Text d] instance GHC.Show.Show Graphics.Layout.Inline.CSS.UnicodeBidi instance GHC.Read.Read Graphics.Layout.Inline.CSS.UnicodeBidi instance GHC.Enum.Enum Graphics.Layout.Inline.CSS.UnicodeBidi instance GHC.Classes.Ord Graphics.Layout.Inline.CSS.UnicodeBidi instance GHC.Classes.Eq Graphics.Layout.Inline.CSS.UnicodeBidi instance Stylist.PropertyParser Graphics.Layout.Inline.CSS.CSSInline -- | Parses & desugars CSS properties to general CatTrap -- datastructures. module Graphics.Layout.CSS -- | Parsed CSS properties relevant to layout. data CSSBox a CSSBox :: Display -> BoxSizing -> PaddedBox Unitted Unitted -> Pattern -> CSSFont -> a -> [(Text, [Token])] -> a -> CSSGrid -> CSSCell -> CSSInline -> Bool -> PageOptions -> ParagraphOptions -> CSSBox a -- | Which layout formula to use, a.k.a. parsed CSS display property. [display] :: CSSBox a -> Display -- | (Unused) Parsed CSS box-sizing [boxSizing] :: CSSBox a -> BoxSizing -- | sizing, margins, border-width, & padding CSS properties. Stores -- units in case they're needed for font-related units. [cssBox] :: CSSBox a -> PaddedBox Unitted Unitted -- | Query parameters describing desired font. [font] :: CSSBox a -> Pattern -- | Additional font-related CSS properties. [font'] :: CSSBox a -> CSSFont -- | Caller-specified data, to parse additional CSS properties. [inner] :: CSSBox a -> a -- | Properties to lower size units before passing onto to inner [innerProperties] :: CSSBox a -> [(Text, [Token])] -- | Parent to use when parsing length-expanded inner properties. [innerParent] :: CSSBox a -> a -- | Grid-related CSS properties. [gridStyles] :: CSSBox a -> CSSGrid -- | Grid item related CSS properties. [cellStyles] :: CSSBox a -> CSSCell -- | inline-related CSS properties. [inlineStyles] :: CSSBox a -> CSSInline -- | Parsed CSS caption-side. [captionBelow] :: CSSBox a -> Bool -- | Parsed widows & orphans controlling pagination. [pageOptions] :: CSSBox a -> PageOptions -- | Parsed text-alignment & other options which applies per-paragraph. [paragraphOptions] :: CSSBox a -> ParagraphOptions -- | Possible values for CSS box-sizing. data BoxSizing BorderBox :: BoxSizing ContentBox :: BoxSizing -- | Possibly values for CSS display property. data Display Block :: Display Grid :: Display Inline :: Display Table :: Display None :: Display TableRow :: Display TableHeaderGroup :: Display TableRowGroup :: Display TableFooterGroup :: Display TableCell :: Display TableColumn :: Display TableColumnGroup :: Display TableCaption :: Display -- | Desugar parsed CSS into more generic layout parameters. finalizeCSS :: PropertyParser x => Font' -> Font' -> StyleTree (CSSBox x) -> LayoutItem Length Length x finalizeCSS' :: PropertyParser x => Font' -> StyleTree (CSSBox x) -> LayoutItem Length Length x instance (Stylist.PropertyParser x, Graphics.Layout.Box.Zero m, Graphics.Layout.Box.Zero n) => Graphics.Layout.Inline.CSS.Default (Graphics.Layout.UserData m n x)