cattrap-0.2.0.0: Lays out boxes according to the CSS Box Model.
Safe HaskellNone
LanguageHaskell2010

Graphics.Layout.Grid

Description

Sizes grid cells & positions elements to them.

Synopsis

Documentation

type Grid m n = Size (Track m) (Track n) Source #

An element which positions it's children within a grid.

data Track x Source #

The sizes to which children are alonged on a single axis.

Constructors

Track 

Fields

  • cells :: [Either x Double]

    The desired size of each cell. If Left specifies ratio of excess space to use.

  • trackMins :: [Double]

    The minimum amount of space each cell should take.

  • trackNats :: [Double]

    The ideal amount of space each cell should take.

  • gap :: x

    How much space to add between cells.

type GridItem = Size GridItem' GridItem' Source #

Which cells a child should be aligned to.

data GridItem' Source #

How a grid child should be aligned per-axis.

Constructors

GridItem 

Fields

  • cellStart :: Int

    On which cell should this child start.

  • cellEnd :: Int

    Before which cell should this child end.

  • alignment :: Alignment

    How to redistribute excess space.

  • minSize :: Double

    The minimum amount of space to allocate to this child.

  • natSize :: Double

    The maximum aount of space to allocate to this child.

data Alignment Source #

How to redistribute excess space.

Constructors

Start 
Mid 
End 

buildTrack :: CastDouble x => [Either x Double] -> Track x Source #

Constructs a track with default (to-be-computed) values & given cell sizes.

buildGrid :: (CastDouble m, CastDouble n) => [Either m Double] -> [Either n Double] -> Grid m n Source #

Constructs a grid with default (to-be-computed) values & given cell sizes.

setCellBox :: (CastDouble m, CastDouble n) => GridItem -> PaddedBox m n -> GridItem Source #

Sets minimum & natural sizes from the given padded box.

enumerate :: [b] -> [(Int, b)] Source #

Utility for associate an index with each item in a list.

gridItemBox :: (CastDouble x, CastDouble y) => Grid y x -> GridItem -> PaddedBox Double Double Source #

Compute the maximum size as a PaddedBox of a child, for it to be sized to.

cellSize :: CastDouble x => Track x -> GridItem' -> Double Source #

trackMin :: (n -> Double) -> Track n -> Double Source #

Compute the minimum size for the track given cell sizes. Refers to computed min sizes if cached.

trackNat :: (n -> Double) -> Track n -> Double Source #

Compute the natural size for the track given cell sizes. Refers to compute natural sizes if cached.

gridEstWidth :: Grid y Length -> [GridItem] -> Double Source #

Estimate grid width to inform proper width calculation.

sizeTrackMins :: Double -> Track Length -> [GridItem'] -> [Double] Source #

Calculate minimum sizes for all cells in the track. Sized to fit given children.

sizeTrackNats :: Double -> Track Length -> [GridItem'] -> [Double] Source #

Compute natural sizes for all cells in the track. Sized to fit given children.

sizeTrackMaxs :: Double -> Track Length -> [Double] Source #

Compute maximum sizes for all cells in the track, sized to the parent element.

trackPosition :: Track Double -> [GridItem'] -> [Double] Source #

Compute the position of all children within the grid.

gridPosition :: Grid Double Double -> [GridItem] -> [(Double, Double)] Source #

Compute the position of all children in a grid.

trackLayout :: Double -> Double -> Track Length -> [GridItem'] -> (Track Double, [(Double, GridItem')]) Source #

Compute the track sizes & child positions along a single axis.

gridLayout :: Size Double Double -> Grid Length Length -> [GridItem] -> (Grid Double Double, [((Double, Double), GridItem)]) Source #

Compute the track sizes & child positions along both axes.