jaylib
jaylib copied to clipboard
Raygui ?
Thank you for jaylib it works like a charm !
https://github.com/raysan5/raygui
Do you know if I can use raygui with jaylib ? if yes how ?
raygui looks like a set of .h files.
Regards
You would need to wrap raygui to be accesible from the Janet, like this lib is wrapped around raylib.
I think it is good idea, even if we have janetui.
HI pepe, thank you, yes I think it can be a quick win.
My problem is I don't have the knowledge to handle the mapping. I don't even understand raygui : just a set of .h files (not a c programmer)
Well, I am not C programmer at all (25 years ago I was kind of it in the high school) and I still managed to wrap LevelDB for Janet.
I will take look at the raygui and maybe we can make it (by copying jaylib :-).
It would be great if you can have a look, I'm not sure I can help .C .H mechanisms are very far behind me
Working on it: https://github.com/kamisori/jaylib
Oh. I was not able to compile with musl stdlib. Great @kamisori!
sorry, at the moment im working on windows. there are some bugs I found but at least it compiled when I commited :D
I'd also like to see this (I'm on GNU/Linux).
@kamisori oh, that's awesome! Where you planning on creating a PR here for your work?
A fair bit seems to be working in kamisori's fork:
That is based on this test file: https://github.com/kamisori/jaylib/blob/master/test/test5.janet
The following file seems to be related to the implementation: https://github.com/kamisori/jaylib/blob/master/src/gui.h
@sogaiu @kamisori this is great ! I hope I can use this very soon !
FWIW, I went through kamisori's test5.janet
and made a simplified version of it to just demo a list view. I think it might be an easier starting point (well, it would have been for me anyway :) ).
The following is the resulting script -- it's meant to work from the project directory:
(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)
Thanks, @sogaiu !
I also appreciate the simplified example here. Personally, I also like to (import jaylib :as jl)
so that everything from the library is prefixed with jl/
, making it easier for me to differentiate the jaylib code from everything else.
How did you run this test file? Did you have to build and install @kamisori 's jaylib instead of jpm install jaylib
?
Re: (import jaylib :as jl)
- I do a similar thing sometimes for similar reasons, but it depends on the situation. In this case I was modifying someone else's code where a decision had already been made one way (and I didn't go through to change everything). (One benefit of this approach is that comparison with the original file is easier.)
Re: running the test file - In this case, just to run the test file, I don't think any invocation of jpm install
is necessary (the use
refers to things relatively and references the directory named build
), though building is.
Basically the following sort of steps in a (--recursive
) cloned directory of kamisori's fork works here:
jpm build
janet listview.janet
Note that listview.janet
is the name of the "test" file containing the content posted earlier.
I don't understand. I currently have jaylib installed. So, I should jpm uninstall jaylib
, and then... maybe git clone @kamisori 's jaylib so I can then run:
cd jaylib # the one I just git cloned
jpm build
janet listview.janet # your program above
?
BTW, not sure how relevant this is here, but it looks like raysan recently removed the tooltip API. https://github.com/raysan5/raygui/commit/13aac618ad49648751b13e925ef0311674ddc289
@uvtc I don't think whether you have jaylib installed should affect the instructions above because AFAIK all of the relevant code in this case refers to things in the cloned directory using relative paths.
To spell that out a bit, in listview.janet
, the way kamisori's jaylib code is referenced is via (use ./build/jaylib)
, which IIUC means when janet loads listview.janet
, it will look for jaylib (kamisori's in this case) within a directory named build
relative to listview.janet
. Note that this is assuming listview.janet
lives in the project root for kamisori's fork (as mentioned in my original instructions).
I don't have any version of jaylib installed and the instructions work for me [1].
Didn't know about the tooltip thing -- thanks for the tip :)
[1] I gather though that we manage our janet setups differently. I have a user-specific setup (i.e. it's not a setup where janet lives in a place like /usr/local/bin
or /usr/bin
).