Created
January 3, 2019 08:49
-
-
Save micha/4460aa0f425db925607a844ad7ca372a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns hoplonfx.core | |
(:require | |
[hoplonfx.ui :refer [run]] | |
[hoplonfx.util :refer :all]) | |
(:import | |
[hoplonfx ApplicationShim] | |
[javafx.application Application])) | |
(defonce stage | |
(delay | |
(with-promise [q] | |
(Application/launch | |
ApplicationShim | |
(->> (meta (deftmp #(deliver q %))) | |
((juxt :ns :name)) | |
((conxt (comp str ns-name) str)) | |
(into-array String)))))) | |
(defn set-scene! | |
[scene] | |
@stage | |
(run (.setScene @stage scene))) | |
(defn set-title! | |
[title] | |
@stage | |
(run (.setTitle @stage title))) | |
(comment | |
(do (require | |
'[hoplonfx.ui :refer :all] | |
'[javelin.core-clj :refer :all]) | |
(import | |
'[javafx.geometry Insets Pos])) | |
(defonce n (cell 0)) | |
(set-title! "hello world") | |
(set-scene! | |
((scene 800 600) | |
((stackpane) | |
((vbox) | |
:alignment [Pos/CENTER] | |
((label) | |
:padding [(Insets. 12)] | |
:text [(cell= (format "clicks: %d" n))]) | |
((button) | |
:text ["OH SHEEITT!!"] | |
:on-action (fn [_ _] (swap! n inc))))))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment