Bugfixes
This commit is contained in:
parent
78b93eee35
commit
f828198639
3 changed files with 20 additions and 12 deletions
|
@ -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)
|
[![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)
|
[![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)
|
[![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
|
# ClojureFX
|
||||||
|
|
||||||
```clojure
|
```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.
|
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.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject clojurefx "0.0.22"
|
(defproject clojurefx "0.0.23"
|
||||||
:description "A Clojure wrapper for JavaFX."
|
:description "A Clojure wrapper for JavaFX."
|
||||||
:license "Like Clojure."
|
:license "Like Clojure."
|
||||||
:url "https://www.bitbucket.org/zilti/clojurefx"
|
:url "https://www.bitbucket.org/zilti/clojurefx"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
(javafx.scene.shape Rectangle)))
|
(javafx.scene.shape Rectangle)))
|
||||||
|
|
||||||
;; Fuck you, whoever made that API design.
|
;; 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)
|
(timbre/refer-timbre)
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
javafx.stage.Stage {:style javafx.stage.StageStyle}}))
|
javafx.stage.Stage {:style javafx.stage.StageStyle}}))
|
||||||
|
|
||||||
(defn camelcase [kebabcase]
|
(defn camelcase [kebabcase]
|
||||||
(let [splitted (str/split kebabcase #"-")]
|
(let [splitted (str/split (name kebabcase) #"-")]
|
||||||
(reduce #(str %1 (str/capitalize %2)) (first splitted) (rest splitted))))
|
(reduce #(str %1 (str/capitalize %2)) "" splitted)))
|
||||||
|
|
||||||
;; ## Threading helpers
|
;; ## Threading helpers
|
||||||
|
|
||||||
|
@ -91,36 +91,44 @@
|
||||||
first))
|
first))
|
||||||
|
|
||||||
(defn invoke-constructor [clazz args]
|
(defn invoke-constructor [clazz args]
|
||||||
|
(info "Constructing" clazz "with" (first args))
|
||||||
(clojure.lang.Reflector/invokeConstructor clazz (into-array args)))
|
(clojure.lang.Reflector/invokeConstructor clazz (into-array args)))
|
||||||
|
|
||||||
;; ## Properties
|
;; ## Properties
|
||||||
|
|
||||||
(defn find-property [obj prop]
|
(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
|
(defn get-property-value
|
||||||
([obj prop]
|
([obj prop]
|
||||||
(.getValue (find-property obj (name prop)))))
|
(clojure.lang.Reflector/invokeInstanceMethod obj (str "get" (camelcase prop)) (into-array []))))
|
||||||
|
|
||||||
(defn set-property-value
|
(defn set-property-value
|
||||||
([obj prop val]
|
([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
|
;; ## In-code scenegraph
|
||||||
|
|
||||||
(declare compile-o-matic)
|
(declare compile-o-matic)
|
||||||
|
|
||||||
(defn- apply-props-to-node [nodeobj propmap]
|
(defn- apply-props-to-node [nodeobj propmap]
|
||||||
(doseq [[k v] 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)
|
nodeobj)
|
||||||
|
|
||||||
(defn- propmap-splitter [clazz propmap]
|
(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)]))
|
[(map propmap constructor-args) (apply dissoc propmap constructor-args)]))
|
||||||
|
|
||||||
(defn- build-node [clazz propmap]
|
(defn- build-node [clazz propmap]
|
||||||
(let [[cargs props] (propmap-splitter 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)
|
(apply-props-to-node nodeobj props)
|
||||||
nodeobj))
|
nodeobj))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue