Created
May 5, 2021 09:22
-
-
Save sogaiu/912914c04e1d1948d45211767334ed14 to your computer and use it in GitHub Desktop.
listview demo with kamisori's jaylib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use ./build/jaylib) | |
(defn- make-window | |
"open window with default values" | |
[] | |
(set-config-flags :msaa-4x-hint) | |
(init-window 800 600 "Place") | |
(set-target-fps 60) | |
(set-exit-key 0)) | |
(defn main | |
[& args] | |
(make-window) | |
(var listview @{:result {:active -1 | |
:scrollindex 0}}) | |
(var show-message-box false) | |
(var exit-window false) | |
(while (not exit-window) | |
(set exit-window | |
(window-should-close)) | |
(when (key-pressed? :escape) | |
(set show-message-box (not show-message-box))) | |
(begin-drawing) | |
(clear-background | |
(get-color | |
(gui-get-style :default :background-color))) | |
(let [result | |
(gui-list-view [165 25 140 240] | |
(string/join ["gui-window-box" | |
"gui-panel" | |
"gui-scroll-panel" | |
"gui-group-box" | |
"gui-label" | |
"gui-button" | |
"gui-label-button" | |
"gui-line"] | |
";") | |
((listview :result) :scrollindex) | |
((listview :result) :active))] | |
(set (listview :result) result)) | |
(when show-message-box | |
(draw-rectangle 0 0 (get-screen-width) (get-screen-height) (fade :ray-white 0.8)) | |
(var result | |
(gui-message-box [(- (/ (get-screen-width) 2) 125) | |
(- (/ (get-screen-height) 2) 50) | |
250 100 ] | |
"Close Window" #(gui-icon-text :ricon-exit "Close Window") | |
"Do you really want to exit?" | |
"Yes;No")) | |
(if (or (= result 0) | |
(= result 2)) | |
(set show-message-box false) | |
(when (= result 1) | |
(set exit-window true)))) | |
(case ((listview :result) :active) | |
0 (gui-window-box [200 10 500 500] "PORTABLE WINDOW") | |
1 (gui-panel [200 10 500 500] ) | |
2 (gui-scroll-panel [200 10 200 200] [0 0 495 495] [0 0]) | |
3 (gui-group-box [200 10 200 200] "GROUP BOX") | |
4 (gui-label [ 200 10 15 15 ] "LABEL") | |
5 (gui-button [ 200 10 75 25 ] "BUTTON") | |
6 (gui-label-button [ 200 10 75 25 ] "LABEL BUTTON") | |
7 (gui-line [ 200 10 150 15 ] "LINE")) | |
(gui-unlock) | |
(end-drawing)) | |
(close-window)) | |
(main) | |
(os/exit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment