From 289ca3be66a5731fdcd8e2901514ddbb113c5076 Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Wed, 22 Apr 2026 21:06:58 +1200 Subject: Make the layout work roughly, make boxes have a size, update test code to work with boxes --- include/saffron_widget.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'include/saffron_widget.h') diff --git a/include/saffron_widget.h b/include/saffron_widget.h index 4461555..7fc6bc8 100644 --- a/include/saffron_widget.h +++ b/include/saffron_widget.h @@ -3,12 +3,17 @@ #include -typedef enum{ - SAFFRON_SIZE_FIXED, - SAFFRON_SIZE_STRETCH, - SAFFRON_SIZE_SCALE // scale but keep aspect ratio. this must be set on BOTH size modes (width AND height) to work +typedef enum { + SAFFRON_SIZE_FIXED, // keep normal size + SAFFRON_SIZE_STRETCH, // stretch this axis to the maximum size + SAFFRON_SIZE_SCALE // scale but keep aspect ratio. this must be set on BOTH axes (width AND height) to work. if it's only set on one, then it will default back to fixed } SaffronSizeMode; +typedef enum { + SAFFRON_WIDGET_UNKNOWN, + SAFFRON_WIDGET_BOX, +} SaffronWidgetType; + typedef struct SaffronWidget { int x, y, w, h; void (*draw)(struct SaffronWidget *self, SDL_Renderer *renderer); @@ -18,7 +23,8 @@ typedef struct SaffronWidget { int child_count; SaffronSizeMode width_mode; SaffronSizeMode height_mode; - bool pixel_perfect; // Do we scale dynamically (SaffronSizeMode, etc) or use raw x, y, w, h values? If this is true, the SaffronSizeModes from earlier will be ignored + bool pixel_perfect; // Do we scale dynamically (SaffronSizeMode, etc) or use raw x, y, w, h values? If this is true, the SaffronSizeModes from earlier will be ignored. this pretty much tells the engine NOT to layout your widgets, don't expect it to allocate size for it. get better + SaffronWidgetType type; } SaffronWidget; #endif -- cgit v1.2.3