Mercurial > hg > indyvon
changeset 148:613bd4ac1bc0
Panel has background color argument.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Thu, 25 Apr 2013 04:01:33 +0400 |
parents | 7c982d2ee9f3 |
children | 79bd47e3120a |
files | src/net/kryshen/indyvon/core.clj src/net/kryshen/indyvon/layers.clj |
diffstat | 2 files changed, 20 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/net/kryshen/indyvon/core.clj Thu Apr 25 04:01:31 2013 +0400 +++ b/src/net/kryshen/indyvon/core.clj Thu Apr 25 04:01:33 2013 +0400 @@ -438,19 +438,16 @@ `(binding [*theme* (merge *theme* ~theme)] ~@body)) -(defmacro with-color - [color-or-keyword & body] - (let [color-form (if (keyword? color-or-keyword) - `(~color-or-keyword *theme*) - color-or-keyword)] - `(let [color# ~color-form - g# *graphics* - old-color# (.getColor g#)] - (try - (.setColor g# color#) - ~@body - (finally - (.setColor g# old-color#)))))) +(defmacro with-color [color-or-key & body] + `(let [color# ~color-or-key + color# (get *theme* color# color#) + g# *graphics* + old-color# (.getColor g#)] + (try + (.setColor g# color#) + ~@body + (finally + (.setColor g# old-color#))))) (defmacro with-stroke [stroke & body] `(let [g# *graphics*
--- a/src/net/kryshen/indyvon/layers.clj Thu Apr 25 04:01:31 2013 +0400 +++ b/src/net/kryshen/indyvon/layers.clj Thu Apr 25 04:01:33 2013 +0400 @@ -47,6 +47,9 @@ (def empty-layer (->Empty)) +;; TODO: change argument order for decorators, content should be the +;; last. + (defn padding "Decorates layer adding padding." ([content pad] @@ -109,17 +112,14 @@ y x shadow-y shadow-x)))))) (defn panel - "Opaque layer using theme's alt-back-color." + "Opaque layer using theme's alt-back-color or a custom background color." ([content] - (panel content 0)) - ([content gap] - (panel content gap gap gap gap)) - ([content top left bottom right] - (let [layer (padding content top left bottom right)] - (decorate-layer layer [_] - (with-color :alt-back-color - (.fill *graphics* (Rectangle2D$Double. 0.0 0.0 *width* *height*))) - (render! layer))))) + (panel :alt-back-color content)) + ([back-color content] + (decorate-layer content [_] + (with-color back-color + (.fill *graphics* (Rectangle2D$Double. 0.0 0.0 *width* *height*))) + (render! content)))) (defn hbox "Creates layer that draws the specified content layers placing them