diff options
| author | Arslaan Pathan <[email protected]> | 2026-04-22 21:06:58 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-04-22 21:06:58 +1200 |
| commit | 289ca3be66a5731fdcd8e2901514ddbb113c5076 (patch) | |
| tree | 6ec66f374e042a57bcfaa288d0aa444517488d45 /tests | |
| parent | 76516edf2c8c6ba36c0abb48871b5e69e9930dd2 (diff) | |
| download | saffron-289ca3be66a5731fdcd8e2901514ddbb113c5076.tar.xz saffron-289ca3be66a5731fdcd8e2901514ddbb113c5076.zip | |
Make the layout work roughly, make boxes have a size, update test code to work with boxes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_main.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tests/test_main.c b/tests/test_main.c index 5bef6d5..c3ea050 100644 --- a/tests/test_main.c +++ b/tests/test_main.c @@ -1,3 +1,5 @@ +#include "saffron_api.h" +#include "saffron_layout.h" #include <stdio.h> #include <saffron.h> #include <SDL3/SDL.h> @@ -26,28 +28,40 @@ void my_test_onclick(SaffronWidget* self) { int main(void) { saffron_init(); - SaffronWindow* window = saffron_window_new("saffron test", 800, 600); + SaffronWindow* window = saffron_window_new("Saffron Test", 800, 600); + + /* replace the root with our own, because we want horizontal */ + saffron_widget_free(window->root); + window->root = (SaffronWidget*)saffron_box_new(SAFFRON_ORIENTATION_HORIZONTAL, SAFFRON_HALIGN_LEFT, SAFFRON_VALIGN_TOP, 5, 5, 0, window->w, window->h); /* i guess IM THE LUNATIC NOW * DEAL WITH IT */ SaffronWidget* test = saffron_widget_new(); - test->x = 100; - test->y = 100; + /* we don't need to set X and Y, the window will layout them automatically */ test->w = 200; test->h = 150; test->draw = my_test_draw; test->on_click = my_test_onclick; + /* make a vertical box */ + SaffronWidget* box = (SaffronWidget*)saffron_box_new(SAFFRON_ORIENTATION_VERTICAL, SAFFRON_HALIGN_LEFT, SAFFRON_VALIGN_TOP, 5, 0, 0, 200, 150); + /* lunatic method 2 */ SaffronWidget* test2 = saffron_widget_new(); - test2->x = 150; - test2->y = 500; - test2->w = 300; - test2->h = 170; + test2->w = 200; + test2->h = 72; test2->draw = my_test_draw; + /* lunatic method 3 */ + SaffronWidget* test3 = saffron_widget_new(); + test3->w = 200; + test3->h = 73; + test3->draw = my_test_draw; + saffron_widget_add_child(window->root, test); - saffron_widget_add_child(window->root, test2); + saffron_widget_add_child(window->root, box); + saffron_widget_add_child(box, test2); + saffron_widget_add_child(box, test3); saffron_window_main(window); |
