Skip to content

Instantly share code, notes, and snippets.

@micha
Created January 3, 2019 08:49
Show Gist options
  • Save micha/4460aa0f425db925607a844ad7ca372a to your computer and use it in GitHub Desktop.
Save micha/4460aa0f425db925607a844ad7ca372a to your computer and use it in GitHub Desktop.
(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