aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_main.c30
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);