2module Grapics.Element where
4import Native.Guid (guid)
7import Graphics.FillStyle
19data Element = Element Properties ElementPrim
21getProp get e = let (Element props _) = e in get props
22widthOf e = getProp .width e
23heightOf e = getProp .height e
24sizeOf e = getProp (\p -> (p.width, p.height)) e
28 Element props prim -> Element {props| width <- w} prim
31 Element props prim -> Element {props| height <- h} prim
34 Element props prim -> Element {props| opacity <- o} prim
37 Element props prim -> Element {props| filling <- c} prim
40 Element props prim -> Element {props| filling <- f} prim
43 Element props prim -> Element {props| tag <- JS.fromString name } prim
46 Element props prim -> Element {props| href <- JS.fromString href } prim
48emptyStr = JS.fromString ""
50 Element (Properties (guid ()) w h 1 NoFill emptyStr emptyStr) e
53 = Image ImageStyle String
54 | Container Position Element
55 | Flow Direction [Element]
60data ImageStyle = Plain | Fitted | Cropped (Int,Int) Int Int
61data Direction = DUp | DDown | DLeft | DRight | DIn | DOut
63image w h src = newElement w h (Image Plain src)
64fittedImage w h src = newElement w h (Image Fitted src)
65croppedImage w h pos src = newElement w h (Image (Cropped pos w h) src)
67container w h pos e = newElement w h (Container pos e)
68spacer w h = newElement w h Spacer
71 let ws = map widthOf es
73 newFlow w h = newElement w h (Flow dir es)
76 DUp -> newFlow (List.maximum ws) (List.sum hs)
77 DDown -> newFlow (List.maximum ws) (List.sum hs)
78 DLeft -> newFlow (List.sum ws) (List.maximum hs)
79 DRight -> newFlow (List.sum ws) (List.maximum hs)
80 DIn -> newFlow (List.maximum ws) (List.maximum hs)
81 DOut -> newFlow (List.maximum ws) (List.maximum hs)
83above hi lo = newElement (max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
84below lo hi = newElement (max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
85beside lft rht = newElement (widthOf lft + widthOf rht) (max (heightOf lft) (heightOf rht)) (Flow right [lft,rht])
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list