diff options
| author | Arslaan Pathan <[email protected]> | 2026-04-08 13:41:35 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-04-08 13:41:35 +1200 |
| commit | c9660a840256308d4dde40613a1af3296d3fdead (patch) | |
| tree | 13e3049ea6bc6d2606bffeced7dc1ead990a1169 /src/saffron_widget.c | |
| parent | 04ff8c0a6acc2cc9204492690b7f99f892ed439a (diff) | |
| download | saffron-c9660a840256308d4dde40613a1af3296d3fdead.tar.xz saffron-c9660a840256308d4dde40613a1af3296d3fdead.zip | |
what (i cannot put the commit message into words)
I added a lot of stuff, it dont really work fully yet but its very good stuff
Diffstat (limited to 'src/saffron_widget.c')
| -rw-r--r-- | src/saffron_widget.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/saffron_widget.c b/src/saffron_widget.c new file mode 100644 index 0000000..089c040 --- /dev/null +++ b/src/saffron_widget.c @@ -0,0 +1,36 @@ +#include <SDL3/SDL.h> +#include <stdlib.h> +#include <saffron_widget.h> +#include <saffron_api.h> +#include <saffron_window.h> + +SaffronWidget* saffron_widget_new() { + /* This function is a generic primitive for creating widgets. You wouldn't want to do this manually unless you're a lunatic. It is meant to be wrapped around by other functions that change the default parameters, for example, what sane person makes a widget 0x0x0x0? you LUNATIC! */ + SaffronWidget* widget = malloc(sizeof(SaffronWidget)); + + widget->x = 0; + widget->y = 0; + widget->w = 0; + widget->h = 0; + + widget->draw = NULL; + widget->on_click = NULL; + + widget->parent = NULL; + widget->children = NULL; + widget->child_count = 0; + + return widget; +} + +void saffron_widget_free(SaffronWidget *widget) { + /* should probably check if widget is NULL here + * oh well, too bad so sad. not my problem if the caller + * doesn't check and causes undefined behaviour. */ + for (int i = 0; i < widget->child_count; i++) { + saffron_widget_free(widget->children[i]); + } + + free(widget->children); + free(widget); +} |
