Skip to content

Instantly share code, notes, and snippets.

@micha
Last active January 2, 2019 17:04
Show Gist options
  • Save micha/a458e0b4cc8dc4d5963c30935929a92f to your computer and use it in GitHub Desktop.
Save micha/a458e0b4cc8dc4d5963c30935929a92f 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])
(defc n 0)
(set-title! "hello world")
(set-scene!
((Scene 800 600)
((StackPane)
((VBox)
:setAlignment [Pos/CENTER]
((Label)
:setPadding [(Insets. 12)]
:setText [(cell= (format "clicks: %d" n))])
((Button)
:setText ["OH SHEEITT!!"]
:setOnAction (fn [_ _] (swap! n inc)))))))
)
)
@micha
Copy link
Author

micha commented Jan 2, 2019

2019-01-01-232001_800x600_scrot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment