# HG changeset patch # User Mikhail Kryshen <mikhail@kryshen.net> # Date 1283190974 -14400 # Node ID dafd4ff9d3137f01cd9958d26724cbf6335000b7 # Parent ddfde9cce39aedaad73fdfe6ab0ab4b82e0e358d Added hbox. diff -r ddfde9cce39a -r dafd4ff9d313 src/net/kryshen/indyvon/layers.clj --- a/src/net/kryshen/indyvon/layers.clj Mon Aug 30 20:44:23 2010 +0400 +++ b/src/net/kryshen/indyvon/layers.clj Mon Aug 30 21:56:14 2010 +0400 @@ -98,6 +98,23 @@ (.fillRect *graphics* 0 0 *width* *height*)) (render! layer))))) +(defn hbox + "Creates layer that draws the specified content layers placing them + horizontally." + [& contents] + (reify + Layer + (render! [_] + ;; TODO: distribute space proportionally. + (let [w (/ *width* (count contents))] + (doseq [[i c] (map-indexed vector contents)] + (draw! c (* i w) 0 w *height*)))) + (layer-size [_] + (reduce #(Size. (+ (:width %1) (:width %2)) + (max (:height %1) (:height %2))) + (Size. 0 0) + (map layer-size contents))))) + (defn- re-split [^java.util.regex.Pattern re s] (seq (.split re s)))