@@ -12,7 +12,7 @@ module Graphics.Element (widthOf, heightOf, sizeOf,
12 spacer, newElement
12 spacer, newElement
15−import Native.Utils (guid, max)
15+import Native.Utils (guid, max, htmlHeight)
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
@@ -34,8 +34,17 @@ widthOf e = e.props.width
34heightOf e = e.props.height
34heightOf e = e.props.height
35sizeOf e = (e.props.width, e.props.height)
35sizeOf e = (e.props.width, e.props.height)
37+width nw e = let p = e.props
38+ props = case e.element of
39+ Image _ w h _ -> {p| height <- h/w*nw }
40+ RawHtml html -> {p| height <- htmlHeight nw html }
37−width w e = let p = e.props in { element=e.element, props={p| width <- w} }
42+ in { element=e.element, props={props| width <- nw} }
43+height nh e = let p = e.props
44+ props = case e.element of
45+ Image _ w h _ -> {p| width <- w/h*nh }
38−height h e = let p = e.props in { element=e.element, props={p| height <- h} }
47+ in { element=e.element, props={p| height <- nh} }
39opacity o e = let p = e.props in { element=e.element, props={p| opacity <- o} }
48opacity o e = let p = e.props in { element=e.element, props={p| opacity <- o} }
40color c e = let p = e.props in
49color c e = let p = e.props in
41 { element=e.element, props={p| color <- Just c} }
50 { element=e.element, props={p| color <- Just c} }
@@ -85,9 +94,9 @@ flow dir es =
85 DIn -> newFlow (List.maximum ws) (List.maximum hs)
94 DIn -> newFlow (List.maximum ws) (List.maximum hs)
86 DOut -> newFlow (List.maximum ws) (List.maximum hs)
95 DOut -> newFlow (List.maximum ws) (List.maximum hs)
88−above hi lo = newElement (Utils.max (widthOf hi) (widthOf lo)) (heightOf hi + heightOf lo) (Flow DDown [hi,lo])
97+above hi lo = 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])
98+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) (Utils.max (heightOf lft) (heightOf rht)) (Flow right [lft,rht])
99+beside lft rht = newElement (widthOf lft + widthOf rht) (max (heightOf lft) (heightOf rht)) (Flow right [lft,rht])
92layers es =
101layers es =
93 let ws = List.map widthOf es
102 let ws = List.map widthOf es