A gui library based on C, SDL2 and Plato Ideas!
- SDL2_ttf-devel
- SDL-devel
- git
- gcc(or clang)
- gdb(or seergdb)
- fzf
First source project.sh file:
. project.sh
And then call p(it's a bash function).
Now you can see a list of commands, like:
- run
- clean
- debug
- generate tags
- valgrind
- find strings in the binary
- list symbols from object files
There are two main directories:
- lib
- In this directory, you can find graphical widgets(https://en.wikipedia.org/wiki/Graphical_widget).
- there is a special widget that acts as a main container and it's app.c. this file contains 3 important functions:
initialize(): All initializations happen here.render(): The main loop of the program when all top-level events come here. and then we use function pointers to dispatch them to a local widget. Actually, events do not process here. if you look carefully, for each event we call a function:callFunctions()and we pass it as a Node*. actually, we delegate event handling to every widget.cleanup(): Free all the resource allocated for the application(including dynamically allocated memories, SDL specific memories, etc..)
- If you need some widgets that do not exist, feel free to raise an issue.
- example
- main.c: the
main()function resides here. it just calls other functions fromapp.c. also it pass initWidgets() function to app.c. if you add any new widget in your application, you should put it's init() function here. - sample widgets: there are some widgets like btnTest, lblTest, txtInputTest, etc.. you can see how they are implemented if you need ideas about widget creation.
- main.c: the
- put lib/ directory in your project.
- start designing your scene by creating different widgets. you should follow some rules:
2.1. for every widget that you create, you should provide an init() function for it in its header file.(look at
txtInputTest.h) 2.2. in the equivalent.cfile, you should implement that init function. 2.2.1. inside this function, you should set the properties of each widget.(most rokh widgets have a structure that you need to initialize) 2.2.2. you should register callback functions to handle events.(look attxtInputTest.c, if you need some ideas) - finally, call your init function in
initWidgets()that you can find it in main.c.