1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
(ns jvui.counter
"The smallest thing that shows the calling convention: state is an atom the
caller owns, and a widget answers what the person did to it."
(:require [jvui.app :as app]
[jvui.core :as c]
[jvui.widgets :as w]))
(def n (atom 0))
(def loud? (atom false))
(defn render []
(w/page {:max-width 420}
(w/card {}
(w/title "Counter")
(w/label (str "Count: " @n (when @loud? "!")))
(w/hbox {:spacing 8}
(when (w/button "- 1") (swap! n dec))
(when (w/button "+ 1" {:kind :primary}) (swap! n inc))
(when (w/button "reset") (reset! n 0)))
(w/separator)
(reset! loud? (w/checkbox @loud? "Exclaim")))))
(defn -main [& args]
(app/run! render (cond-> {:title "counter"}
(some #{"--shot"} args) (assoc :frames 3 :shot "/tmp/jvui-counter.bmp"))))
|