yoga-0.0.0.1: Bindings to Facebook's Yoga layout library

Yoga

Description

This module holds a high-level interface to the bindings associated with this library that are maintained in Bindings.Yoga. Application developers will likely want to use this module to interface with the library, but are available to use the C-level bindings if more control is desired.

These bindings are not affiliated with Facebook in any way, and have been developed separately for the sole purpose of interfacing with their open source library.

Full documentation can be found at http://facebook.github.io/yoga

Synopsis

## Main datatype

data Layout a Source #

The main datatype in the high level bindings is a Layout. Layouts are used to store a tree of nodes that represent the different components of a layout. Layouts can be composed by adding one as a sub-tree to another. The parent-child relationship dictates different parameters such as width, height and position. This type is opaque to the user in order to facilitate updates to the library. For more control, use the C-level bindings in Yoga.Bindings.

Instances

## Rendering

Stores the calculated layout information for a given node. During rendering, the rendering function will take the payload and layout info to facilitate the renderer to do whatever it needs to with the given layout calculations.

Constructors

 LayoutInfo FieldsnodeTop :: FloatThe y-coordinate of this nodenodeLeft :: FloatThe x-coordinate of this nodenodeWidth :: FloatThe width of this nodenodeHeight :: FloatThe height of this node

Instances

 Source # Methods Source # MethodsshowList :: [LayoutInfo] -> ShowS #

type RenderFn m a b = LayoutInfo -> a -> m b Source #

A RenderFn takes a top-left position and a width and height of a node with the given payload. The function is expected to perform some monadic action in the Monad m, and return a new payload of type b. This function is called on each node in order during a call to render.

render :: (Functor m, Applicative m, Monad m) => Layout a -> RenderFn m a b -> m (Layout b) Source #

Renders a layout with the user-supplied function. The renderer traverses the tree from root node to children and transforms each payload using the user-supplied function.

foldRender :: (Functor m, Applicative m, Monad m, Monoid b) => Layout a -> RenderFn m a (b, c) -> m (b, Layout c) Source #

Renders a layout with the user-supplied function. For each return value of type '(b, c)', we append the first result to the output of the previous node. The second result is stored as the new payload for the given node. Hence, the resulting monadic action produces a mappend-ed set of bs and a new layout with payloads of type c.