diff --git a/README.md b/README.md index e959170..7d72be8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ [![License](//img.shields.io/badge/license-LGPL-blue.svg?style=flat)](https://www.gnu.org/licenses/lgpl-3.0.en.html#content) -[![Clojars](//img.shields.io/badge/clojars-0.0.22-blue.svg?style=flat)](https://clojars.org/clojurefx/versions/0.0.22) +[![Clojars](//img.shields.io/badge/clojars-0.0.23-blue.svg?style=flat)](https://clojars.org/clojurefx/versions/0.0.23) [![Gratipay](//img.shields.io/gratipay/zilti.svg?style=flat)](//gratipay.com/zilti) [![Flattr this](//api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=zilti&url=https%3A%2F%2Fbitbucket.org%2Fzilti%2Fclojurefx) # ClojureFX ```clojure -[clojurefx "0.0.22"] +[clojurefx "0.0.23"] ``` A Clojure extension to make working with [JavaFX](http://download.java.net/jdk8/jfxdocs/index.html) simpler and more idiomatic. It allows you to naturally work with stock JavaFX components through use of extended protocols. Should a feature be missing you can easily extend ClojureFX in your own codebase or just fall back to standard JavaFX methods. diff --git a/project.clj b/project.clj index b06888a..9f6697b 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject clojurefx "0.0.22" +(defproject clojurefx "0.0.23" :description "A Clojure wrapper for JavaFX." :license "Like Clojure." :url "https://www.bitbucket.org/zilti/clojurefx" diff --git a/src/clojurefx/clojurefx.clj b/src/clojurefx/clojurefx.clj index 434df55..0c36489 100644 --- a/src/clojurefx/clojurefx.clj +++ b/src/clojurefx/clojurefx.clj @@ -9,7 +9,7 @@ (javafx.scene.shape Rectangle))) ;; Fuck you, whoever made that API design. -(defonce force-toolkit-init (javafx.embed.swing.JFXPanel.)) +;; (defonce force-toolkit-init (javafx.embed.swing.JFXPanel.)) (timbre/refer-timbre) @@ -32,8 +32,8 @@ javafx.stage.Stage {:style javafx.stage.StageStyle}})) (defn camelcase [kebabcase] - (let [splitted (str/split kebabcase #"-")] - (reduce #(str %1 (str/capitalize %2)) (first splitted) (rest splitted)))) + (let [splitted (str/split (name kebabcase) #"-")] + (reduce #(str %1 (str/capitalize %2)) "" splitted))) ;; ## Threading helpers @@ -91,36 +91,44 @@ first)) (defn invoke-constructor [clazz args] + (info "Constructing" clazz "with" (first args)) (clojure.lang.Reflector/invokeConstructor clazz (into-array args))) ;; ## Properties (defn find-property [obj prop] - (clojure.lang.Reflector/invokeInstanceMethod obj (str (camelcase prop) "Property") [])) + (info obj prop) + (clojure.lang.Reflector/invokeInstanceMethod obj (str (camelcase prop) "Property") (into-array []))) (defn get-property-value ([obj prop] - (.getValue (find-property obj (name prop))))) + (clojure.lang.Reflector/invokeInstanceMethod obj (str "get" (camelcase prop)) (into-array [])))) (defn set-property-value ([obj prop val] - (.setValue (find-property obj (name prop)) val))) + (info obj ": Setting property" prop "to" val) + (clojure.lang.Reflector/invokeInstanceMethod obj (str "set" (camelcase prop)) (into-array [val])))) ;; ## In-code scenegraph (declare compile-o-matic) + (defn- apply-props-to-node [nodeobj propmap] (doseq [[k v] propmap] - (set-property-value nodeobj k v)) + (case k + :children (.add (.getChildren nodeobj) (compile-o-matic v)) + (set-property-value nodeobj k (compile-o-matic v)))) nodeobj) (defn- propmap-splitter [clazz propmap] - (let [constructor-args (get @constructor-args clazz)] + (let [constructor-args (keys (get @constructor-args clazz))] + (info "Constructor args for" clazz "are" constructor-args) [(map propmap constructor-args) (apply dissoc propmap constructor-args)])) (defn- build-node [clazz propmap] (let [[cargs props] (propmap-splitter clazz propmap) - nodeobj (invoke-constructor clazz cargs)] + nodeobj (invoke-constructor clazz (map compile-o-matic cargs))] + (info cargs " " props) (apply-props-to-node nodeobj props) nodeobj))