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

Graphics.Layout.Box

Description

Datastructures representing the CSS box model, & utilities for operating on them.

Synopsis

Documentation

data Border m n Source #

Amount of space surrounding the box.

Constructors

Border 

Fields

Instances

Instances details
Generic (Border m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Associated Types

type Rep (Border m n) :: Type -> Type #

Methods

from :: Border m n -> Rep (Border m n) x #

to :: Rep (Border m n) x -> Border m n #

(Read m, Read n) => Read (Border m n) Source # 
Instance details

Defined in Graphics.Layout.Box

(Show m, Show n) => Show (Border m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

showsPrec :: Int -> Border m n -> ShowS #

show :: Border m n -> String #

showList :: [Border m n] -> ShowS #

(Zero m, Zero n) => Zero (Border m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

zero :: Border m n Source #

(NFData m, NFData n) => NFData (Border m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

rnf :: Border m n -> () #

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

Defined in Graphics.Layout.Box

Methods

(==) :: Border m n -> Border m n -> Bool #

(/=) :: Border m n -> Border m n -> Bool #

type Rep (Border m n) Source # 
Instance details

Defined in Graphics.Layout.Box

type Rep (Border m n) = D1 ('MetaData "Border" "Graphics.Layout.Box" "cattrap-0.6.0.0-inplace" 'False) (C1 ('MetaCons "Border" 'PrefixI 'True) ((S1 ('MetaSel ('Just "top") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 m) :*: S1 ('MetaSel ('Just "bottom") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 m)) :*: (S1 ('MetaSel ('Just "left") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 n) :*: S1 ('MetaSel ('Just "right") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 n))))

mapX :: (n -> nn) -> Border m n -> Border m nn Source #

Convert horizontal spacing via given callback.

mapY :: (m -> mm) -> Border m n -> Border mm n Source #

Convert vertical spacing via given callback.

data Size m n Source #

2D size of a box. Typically inline is width & block is height. This may change as support for vertical layout is added.

Constructors

Size 

Fields

Instances

Instances details
Generic (Size m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Associated Types

type Rep (Size m n) :: Type -> Type #

Methods

from :: Size m n -> Rep (Size m n) x #

to :: Rep (Size m n) x -> Size m n #

(Read n, Read m) => Read (Size m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

readsPrec :: Int -> ReadS (Size m n) #

readList :: ReadS [Size m n] #

readPrec :: ReadPrec (Size m n) #

readListPrec :: ReadPrec [Size m n] #

(Show n, Show m) => Show (Size m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

showsPrec :: Int -> Size m n -> ShowS #

show :: Size m n -> String #

showList :: [Size m n] -> ShowS #

(NFData m, NFData n) => NFData (Size m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

rnf :: Size m n -> () #

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

Defined in Graphics.Layout.Box

Methods

(==) :: Size m n -> Size m n -> Bool #

(/=) :: Size m n -> Size m n -> Bool #

type Rep (Size m n) Source # 
Instance details

Defined in Graphics.Layout.Box

type Rep (Size m n) = D1 ('MetaData "Size" "Graphics.Layout.Box" "cattrap-0.6.0.0-inplace" 'False) (C1 ('MetaCons "Size" 'PrefixI 'True) (S1 ('MetaSel ('Just "inline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 n) :*: S1 ('MetaSel ('Just "block") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 m)))

mapSizeX :: (n -> nn) -> Size m n -> Size m nn Source #

Convert block size via given callback

mapSizeY :: (m -> mm) -> Size m n -> Size mm n Source #

Convert inline size via given callback

data PaddedBox m n Source #

A box with min & max bounds & surrounding borders. The CSS Box Model.

Constructors

PaddedBox 

Fields

  • min :: Size m n

    The minimum amount of pixels this box should take.

  • max :: Size m n

    The maximum amount of pixels this box should take.

  • nat :: Size Double Double

    The ideal number of pixels this box should take.

  • size :: Size m n

    The amount of pixels this box should take.

  • padding :: Border m n

    The amount of space between the box & the border.

  • border :: Border m n

    The amount of space for the border.

  • margin :: Border m n

    The amount of space between the border & anything else.

Instances

Instances details
Generic (PaddedBox m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Associated Types

type Rep (PaddedBox m n) :: Type -> Type #

Methods

from :: PaddedBox m n -> Rep (PaddedBox m n) x #

to :: Rep (PaddedBox m n) x -> PaddedBox m n #

(Read n, Read m) => Read (PaddedBox m n) Source # 
Instance details

Defined in Graphics.Layout.Box

(Show n, Show m) => Show (PaddedBox m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

showsPrec :: Int -> PaddedBox m n -> ShowS #

show :: PaddedBox m n -> String #

showList :: [PaddedBox m n] -> ShowS #

(Zero m, Zero n) => Zero (PaddedBox m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

zero :: PaddedBox m n Source #

(NFData m, NFData n) => NFData (PaddedBox m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

rnf :: PaddedBox m n -> () #

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

Defined in Graphics.Layout.Box

Methods

(==) :: PaddedBox m n -> PaddedBox m n -> Bool #

(/=) :: PaddedBox m n -> PaddedBox m n -> Bool #

(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 #

type Rep (PaddedBox m n) Source # 
Instance details

Defined in Graphics.Layout.Box

zeroBox :: PaddedBox Double Double Source #

An empty box, takes up nospace onscreen.

lengthBox :: PaddedBox Length Length Source #

A box which takes up all available space with no borders.

mapX' :: (n -> nn) -> PaddedBox m n -> PaddedBox m nn Source #

Convert all sizes along the inline axis via given callback.

mapY' :: (m -> mm) -> PaddedBox m n -> PaddedBox mm n Source #

Convert all sizes along the block axis via given callback.

width :: Num a => PaddedBox m a -> a Source #

The total size along the inline axis including borders, etc.

height :: Num a => PaddedBox a n -> a Source #

The total size along the block axis, including borders, etc.

minWidth :: Num a => PaddedBox m a -> a Source #

The total minimum size along the inline axis.

minHeight :: Num a => PaddedBox a n -> a Source #

The total minimum size along the block axis.

maxWidth :: Num a => PaddedBox m a -> a Source #

The total maximum size along the inline axis.

maxHeight :: Num a => PaddedBox a n -> a Source #

The total maximum size along the block axis.

leftSpace :: Num a => PaddedBox m a -> a Source #

Amount of whitespace to the left, summing margins, borders, & padding.

rightSpace :: Num a => PaddedBox m a -> a Source #

Amount of whitespace to the right, summing margins, borders, & padding.

topSpace :: Num a => PaddedBox a n -> a Source #

Amount of whitespace to the top, summing margins, borders, & padding.

bottomSpace :: Num a => PaddedBox a n -> a Source #

Amount of whitespace to the bottom, summing margins, borders, & padding.

hSpace :: Num a => PaddedBox m a -> a Source #

Amount of whitespace along the x axis, summing margins, borders, & padding.

vSpace :: Num a => PaddedBox a n -> a Source #

Amount of whitespace along the y axis, summing margins, borders, & padding.

data Length Source #

A partially-computed length value.

Constructors

Pixels Double

Absolute number of device pixels.

Percent Double

Multiplier by container width.

Auto

Use normal layout computations.

Preferred

Use computed preferred width.

Min

Use minimum legible width.

Instances

Instances details
Generic Length Source # 
Instance details

Defined in Graphics.Layout.Box

Associated Types

type Rep Length :: Type -> Type #

Methods

from :: Length -> Rep Length x #

to :: Rep Length x -> Length #

Read Length Source # 
Instance details

Defined in Graphics.Layout.Box

Show Length Source # 
Instance details

Defined in Graphics.Layout.Box

CastDouble Length Source # 
Instance details

Defined in Graphics.Layout.Box

Zero Length Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

zero :: Length Source #

NFData Length Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

rnf :: Length -> () #

Eq Length Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

(==) :: Length -> Length -> Bool #

(/=) :: Length -> Length -> Bool #

type Rep Length Source # 
Instance details

Defined in Graphics.Layout.Box

type Rep Length = D1 ('MetaData "Length" "Graphics.Layout.Box" "cattrap-0.6.0.0-inplace" 'False) ((C1 ('MetaCons "Pixels" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)) :+: C1 ('MetaCons "Percent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))) :+: (C1 ('MetaCons "Auto" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Preferred" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Min" 'PrefixI 'False) (U1 :: Type -> Type))))

mapAuto :: Double -> Length -> Length Source #

Replace keywords with a given number of pixels. Useful for avoiding messing up percentage calculations in later processing.

lowerLength :: Double -> Length -> Double Source #

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.

class Zero a where Source #

Typeclass for zeroing out fields, so layout primitives can be more reusable.

Methods

zero :: a Source #

Return the empty (or zero) value for a CatTrap geometric type.

Instances

Instances details
Zero Length Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

zero :: Length Source #

Zero Unitted Source # 
Instance details

Defined in Graphics.Layout.CSS.Length

Methods

zero :: Unitted Source #

Zero Double Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

zero :: Double Source #

(Zero m, Zero n) => Zero (Border m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

zero :: Border m n Source #

(Zero m, Zero n) => Zero (PaddedBox m n) Source # 
Instance details

Defined in Graphics.Layout.Box

Methods

zero :: PaddedBox m n Source #

class CastDouble a where Source #

Typeclass for converting between doubles & layout types, approximately if needs be. So layout primitives can be more reusable.

Minimal complete definition

fromDouble

Methods

fromDouble :: Double -> a Source #

Convert a double to a double or length.

toDouble :: a -> Double Source #

Convert a double or length to a double.

toDoubleWithin :: Double -> a -> Double Source #

toDoubleWithinAuto :: Double -> Double -> a -> Double Source #