on master help sign in
More minor fixes to RTS.
d97027cevancz
libraries/Graphics/Element.elm+9−9
@@ -9,10 +9,10 @@ module Graphics.Element (widthOf, heightOf, sizeOf,
9 midLeft, midRight, midTop, midBottom, middleAt,
9 midLeft, midRight, midTop, midBottom, middleAt,
10 topLeftAt, topRightAt, bottomLeftAt, bottomRightAt,
10 topLeftAt, topRightAt, bottomLeftAt, bottomRightAt,
11 midLeftAt, midRightAt, midTopAt, midBottomAt,
11 midLeftAt, midRightAt, midTopAt, midBottomAt,
12− spacer
12+ spacer, newElement
13 ) where
13 ) where
14
14
15−import Native.Utils (guid)
15+import Native.Utils (guid, max)
16import JavaScript as JS
16import JavaScript as JS
17import List as List
17import List as List
18import Graphics.Color as Color
18import Graphics.Color as Color
@@ -73,8 +73,8 @@ spacer w h = newElement w h Spacer
73data Direction = DUp | DDown | DLeft | DRight | DIn | DOut
73data Direction = DUp | DDown | DLeft | DRight | DIn | DOut
74
74
75flow dir es =
75flow dir es =
76− let ws = map widthOf es
76+ let ws = List.map widthOf es
77− hs = map heightOf es
77+ hs = List.map heightOf es
78 newFlow w h = newElement w h (Flow dir es)
78 newFlow w h = newElement w h (Flow dir es)
79 in
79 in
80 case dir of
80 case dir of
@@ -85,13 +85,13 @@ flow dir es =
85 DIn -> newFlow (List.maximum ws) (List.maximum hs)
85 DIn -> newFlow (List.maximum ws) (List.maximum hs)
86 DOut -> newFlow (List.maximum ws) (List.maximum hs)
86 DOut -> newFlow (List.maximum ws) (List.maximum hs)
87
87
88−above hi lo = newElement (max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
88+above hi lo = newElement (Utils.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])
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) (max (heightOf lft) (heightOf rht)) (Flow right [lft,rht])
90+beside lft rht = newElement (widthOf lft + widthOf rht) (Utils.max (heightOf lft) (heightOf rht)) (Flow right [lft,rht])
91
91
92layers es =
92layers es =
93− let ws = map widthOf es
93+ let ws = List.map widthOf es
94− hs = map heightOf es
94+ hs = List.map heightOf es
95 in newElement (List.maximum w) (List.maximum h) (Flow DOut es)
95 in newElement (List.maximum w) (List.maximum h) (Flow DOut es)
96
96
97
97
runtime/Render.js+4−2
@@ -3,6 +3,8 @@ var ElmRuntime = ElmRuntime || {};
3ElmRuntime.Render = function() {
3ElmRuntime.Render = function() {
4'use strict';
4'use strict';
5
5
6+var fromList = Elm.JavaScript({}).fromList
7+
6function newElement(elementType) {
8function newElement(elementType) {
7 var e = document.createElement(elementType);
9 var e = document.createElement(elementType);
8 e.style.padding = "0";
10 e.style.padding = "0";
@@ -119,8 +121,8 @@ function flowWith(f, array) {
119}
121}
120
122
121function flow(dir,elist) {
123function flow(dir,elist) {
122− var array = JS.fromList(elist);
124+ var array = fromList(elist);
123− switch(dir) {
125+ switch(dir.ctor) {
124 case "DDown": array.reverse();
126 case "DDown": array.reverse();
125 case "DUp": return flowWith(goDown,array);
127 case "DUp": return flowWith(goDown,array);
126 case "DRight": array.reverse();
128 case "DRight": array.reverse();