0.0.30-SNAPSHOT
This commit is contained in:
parent
df28a1c96b
commit
60273fc665
5 changed files with 18 additions and 8 deletions
10
README.md
10
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)
|
[![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.21--SNAPSHOT-blue.svg?style=flat)](https://clojars.org/clojurefx/versions/0.0.21-SNAPSHOT)
|
[![Clojars](//img.shields.io/badge/clojars-0.0.30--SNAPSHOT-blue.svg?style=flat)](https://clojars.org/clojurefx/versions/0.0.30-SNAPSHOT)
|
||||||
[![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.21-SNAPSHOT"]
|
[clojurefx "0.0.30-SNAPSHOT"]
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note: This is a complete rewrite, no code has been taken over from the old version on GitHub, and I'm taking a radically different approach.**
|
**Note: This is a complete rewrite, no code has been taken over from the old version on GitHub, and I'm taking a radically different approach.**
|
||||||
|
@ -24,9 +24,13 @@ This is in a very early state, so there isn't much yet. Take a look at the [Cloj
|
||||||
### Declarative UI programming
|
### Declarative UI programming
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
|
(def superbutton (compile [Button {:text "Close"
|
||||||
|
:action #'close-handler}]))
|
||||||
|
|
||||||
(compile [VBox {:id "TopLevelVBox"
|
(compile [VBox {:id "TopLevelVBox"
|
||||||
:children [Label {:text "Hi!"}
|
:children [Label {:text "Hi!"}
|
||||||
Label {:text "I'm ClojureFX!"}
|
Label {:text "I'm ClojureFX!"}
|
||||||
HBox {:id "HorizontalBox"
|
HBox {:id "HorizontalBox"
|
||||||
:children [Button {:text "Alright."}]}]}])
|
:children [Button {:text "OK"}
|
||||||
|
superbutton]}]}])
|
||||||
```
|
```
|
|
@ -190,9 +190,11 @@ nil)
|
||||||
(tc-ignore
|
(tc-ignore
|
||||||
(extend-protocol p/FXOnAction
|
(extend-protocol p/FXOnAction
|
||||||
ButtonBase
|
ButtonBase
|
||||||
|
(get-action [this] (.getOnAction ^ButtonBase this))
|
||||||
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
|
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
|
||||||
(fire! [this] (.fire this))
|
(fire! [this] (.fire this))
|
||||||
MenuItem
|
MenuItem
|
||||||
|
(get-action [this] (.getOnAction ^MenuItem this))
|
||||||
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
|
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
|
||||||
(fire! [this] (.fire this))))
|
(fire! [this] (.fire this))))
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
:children (with-meta [#'get-subnodes #'set-subnodes!] {:argument java.util.List :parent FXParent})
|
:children (with-meta [#'get-subnodes #'set-subnodes!] {:argument java.util.List :parent FXParent})
|
||||||
;;; FXStyleSetter / FXStyleable
|
;;; FXStyleSetter / FXStyleable
|
||||||
:style (with-meta [#'get-style #'set-style!] {:argument String :parent FXStyleable})
|
:style (with-meta [#'get-style #'set-style!] {:argument String :parent FXStyleable})
|
||||||
|
;;; FXOnAction
|
||||||
|
:action (with-meta [#'get-action #'set-action!] {:argument clojure.lang.IFn :parent FXOnAction})
|
||||||
;;; FXStage
|
;;; FXStage
|
||||||
:title (with-meta [#'get-title #'set-title!] {:argument String :parent FXStage})
|
:title (with-meta [#'get-title #'set-title!] {:argument String :parent FXStage})
|
||||||
:scene (with-meta [#'get-scene #'set-scene!] {:argument Scene :parent FXStage})
|
:scene (with-meta [#'get-scene #'set-scene!] {:argument Scene :parent FXStage})
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
|
|
||||||
(defprotocol [[A :variance :covariant]]
|
(defprotocol [[A :variance :covariant]]
|
||||||
FXOnAction
|
FXOnAction
|
||||||
|
(get-action [this :- A] :- [javafx.event.EventHandler -> Any])
|
||||||
(set-action! [this :- A action :- [javafx.event.EventHandler -> Any]] :- A)
|
(set-action! [this :- A action :- [javafx.event.EventHandler -> Any]] :- A)
|
||||||
(fire! [this :- A] :- nil))
|
(fire! [this :- A] :- nil))
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,14 @@
|
||||||
;;## Element testing
|
;;## Element testing
|
||||||
|
|
||||||
;;## Event testing
|
;;## Event testing
|
||||||
(def button (new Button))
|
;;(def button (new Button))
|
||||||
|
(def button (atom nil))
|
||||||
(def fired? (atom false))
|
(def fired? (atom false))
|
||||||
(facts "Events"
|
(facts "Events"
|
||||||
(fact "Adding an event handler"
|
(fact "Creating button with event handler"
|
||||||
(set-action! button (fn [event] (reset! fired? true))) => button)
|
(class (reset! button (factory/compile [Button {:action (fn [_] (reset! fired? true))}]))) => javafx.scene.control.Button)
|
||||||
(fact "Firing the event and checking the result"
|
(fact "Firing the event and checking the result"
|
||||||
(do (fire! button)
|
(do (fire! @button)
|
||||||
@fired?) => true))
|
@fired?) => true))
|
||||||
|
|
||||||
;;## IdMapper
|
;;## IdMapper
|
||||||
|
|
Loading…
Reference in a new issue