on master help sign in
More minor fixes to RTS.
commitd97027c1183db53dd5b779a92f1daa051fb5b306 authorevancz <info@elm-lang.org> dateTue 12 Mar 2013, 01:51 (14 years ago) parenta1b890a
2 files changed+13−11
libraries/Graphics/Element.elm+9−9 runtime/Render.js+4−2
libraries/Graphics/Element.elm+9−9
@@ -9,10 +9,10 @@ module Graphics.Element (widthOf, heightOf, sizeOf,
99 midLeft, midRight, midTop, midBottom, middleAt,
1010 topLeftAt, topRightAt, bottomLeftAt, bottomRightAt,
1111 midLeftAt, midRightAt, midTopAt, midBottomAt,
12− spacer
12+ spacer, newElement
1313 ) where
1414
15−import Native.Utils (guid)
15+import Native.Utils (guid, max)
1616import JavaScript as JS
1717import List as List
1818import Graphics.Color as Color
@@ -73,8 +73,8 @@ spacer w h = newElement w h Spacer
7373data Direction = DUp | DDown | DLeft | DRight | DIn | DOut
7474
7575flow dir es =
76− let ws = map widthOf es
77− hs = map heightOf es
76+ let ws = List.map widthOf es
77+ hs = List.map heightOf es
7878 newFlow w h = newElement w h (Flow dir es)
7979 in
8080 case dir of
@@ -85,13 +85,13 @@ flow dir es =
8585 DIn -> newFlow (List.maximum ws) (List.maximum hs)
8686 DOut -> newFlow (List.maximum ws) (List.maximum hs)
8787
88−above hi lo = newElement (max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
89−below lo hi = newElement (max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
90−beside lft rht = newElement (widthOf lft + widthOf rht) (max (heightOf lft) (heightOf rht)) (Flow right [lft,rht])
88+above hi lo = newElement (Utils.max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
89+below lo hi = newElement (Utils.max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
90+beside lft rht = newElement (widthOf lft + widthOf rht) (Utils.max (heightOf lft) (heightOf rht)) (Flow right [lft,rht])
9191
9292layers es =
93− let ws = map widthOf es
94− hs = map heightOf es
93+ let ws = List.map widthOf es
94+ hs = List.map heightOf es
9595 in newElement (List.maximum w) (List.maximum h) (Flow DOut es)
9696
9797
runtime/Render.js+4−2
@@ -3,6 +3,8 @@ var ElmRuntime = ElmRuntime || {};
33ElmRuntime.Render = function() {
44'use strict';
55
6+var fromList = Elm.JavaScript({}).fromList
7+
68function newElement(elementType) {
79 var e = document.createElement(elementType);
810 e.style.padding = "0";
@@ -119,8 +121,8 @@ function flowWith(f, array) {
119121}
120122
121123function flow(dir,elist) {
122− var array = JS.fromList(elist);
123− switch(dir) {
124+ var array = fromList(elist);
125+ switch(dir.ctor) {
124126 case "DDown": array.reverse();
125127 case "DUp": return flowWith(goDown,array);
126128 case "DRight": array.reverse();