sneathlane-haste-1: A compositional web UI library, which draws to a Canvas element

Safe HaskellNone
LanguageHaskell2010

SneathLane

Contents

Synopsis

Widgets

data Widget z Source

Atom of a sneath lane application

Constructors

Finish z 
Continue (Output (Widget z)) (Maybe (MouseOut (Widget z))) (Maybe (Animate (Widget z))) (WidgetFocus z) 

data WidgetFocus z Source

Determines the focus behavior of the widget

Constructors

NotFocusable

Widget can not take keyboard focus

Focusable (Widget z) (Widget z)

Widget can take keyboard focus, but does not have it now

Focused (Widget z) (Widget z, Bool) (Widget z, Bool) (HandleKey (Widget z))

Widget has keyboard focus

zipW :: CombineGraphics ((Point, MouseButton) -> Widget z) -> Widget z -> Widget z -> Widget z Source

Combine two widgets to run in parallel as a single widget

Build Widgets

graphicWidget :: GraphicTree () -> Widget a Source

A widget which just shows a constant graphic output.

above :: Widget z -> Widget z -> Widget z Source

Combine two widgets one above the other

beside :: Widget z -> Widget z -> Widget z Source

Combine two widgets side by side

Run Widgets

runOnCanvas :: String -> Double -> Double -> (forall z. Widget z) -> IO () Source

Run the widget on the canvas element with ID "canvas"

Graphics

data GraphicTree :: * -> * where Source

A tree of graphics, used as widget output type. FMap functions are stored in the tree instead of being mapped over the leaves, so that tree reconstruction is fast when a widget changes. This is why GraphicTree is a GADT.

Offset: a sub-tree translated by a point

Branch: Two sub-trees; graphicTreeBounds are cached for each

Leaf: A leaf, consisting of a single graphic element

FMap: A graphic tree composed with a function.

Constructors

Offset :: Point -> GraphicTree a -> GraphicTree a 
Branch :: Rect -> GraphicTree a -> Rect -> GraphicTree a -> GraphicTree a 
Leaf :: Graphic -> GraphicTree () 
FMap :: (a -> b) -> GraphicTree a -> GraphicTree b 

Instances

graphicList :: [Graphic] -> GraphicTree () Source

Construct a graphic tree from a nonempty list of graphics.

graphicTreeBounds :: GraphicTree a -> Rect Source

Find a rectangle containing the entire contents of the graphic tree

Events

data MouseButton Source

Which mouse button (if any) was being pressed

Constructors

NoButton 
LeftButton 

type Key = Int Source

Utility

balancedFold :: (a -> a -> a) -> [a] -> a Source

Apply a fold in a balanced fashion over a list. Recommended for combining lists of widgets, so that the widget tree has logarithmic depth.

Type synonyms

type MouseOut a = a Source

type HandleKey a = Key -> a Source