(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"))))