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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
(ns jvui.showcase
"Every widget jvui has, on one page, so a change to any of them can be looked
at rather than reasoned about.
jolt showcase a window
jolt showcase --shot three frames and a BMP in /tmp"
(:require [jvui.app :as app]
[jvui.core :as c]
[jvui.theme :as theme]
[jvui.widgets :as w]))
(def state
(atom {:count 0
:name ""
:volume 0.35
:agreed? false
:dark? true
:rows 24}))
(defn- controls []
(w/card {}
(w/title "Controls")
(w/hbox {:spacing 8}
(w/label (str "Count: " (:count @state)) {:expand :horizontal})
(when (w/button "-") (swap! state update :count dec))
(when (w/button "+" {:kind :primary}) (swap! state update :count inc)))
(w/separator)
(w/label "Name" {:colour (c/th :text-dim)})
(swap! state assoc :name
(w/text-entry (:name @state) {:placeholder "type here"}))
(w/dim-label (if (= "" (:name @state))
"nobody yet"
(str "hello, " (:name @state))))
(w/separator)
(w/hbox {:spacing 8}
(w/label "Volume" {:expand :none})
(swap! state assoc :volume
(w/slider (:volume @state) {:expand :horizontal :min 0.0 :max 1.0}))
(w/label (format "%3d%%" (int (* 100 (:volume @state)))) {:expand :none}))
(w/progress (:volume @state))
(w/separator)
(swap! state assoc :agreed? (w/checkbox (:agreed? @state) "I agree to nothing"))
(swap! state assoc :dark? (w/checkbox (:dark? @state) "Dark theme"))))
(defn- feed []
(w/card {}
(w/title "A viewport")
(w/dim-label "the wheel scrolls it; the bar says where you are")
(w/scroll {:height 160}
(doseq [i (range (:rows @state))]
(w/hbox {:spacing 8}
(w/label (format "%02d" i) {:expand :none :colour (c/th :text-dim)})
(w/label (str "row " i " — clipped by the viewport, not by luck")
{:expand :horizontal}))))))
(defn render []
(swap! c/*ui* assoc :theme (if (:dark? @state) theme/dark theme/light))
(w/page {:max-width 560}
(controls)
(feed)
(w/spacer {:expand :vertical})
(w/dim-label "jvui — dvui's shape, in jolt, on SDL3" {:align :center})))
(defn -main [& args]
(app/run! render (cond-> {:title "jvui showcase" :width 720 :height 620}
(some #{"--shot"} args)
(assoc :frames 3 :shot "/tmp/jvui-showcase.bmp"))))
|