aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-04-22 21:06:58 +1200
committerArslaan Pathan <[email protected]>2026-04-22 21:06:58 +1200
commit289ca3be66a5731fdcd8e2901514ddbb113c5076 (patch)
tree6ec66f374e042a57bcfaa288d0aa444517488d45 /include
parent76516edf2c8c6ba36c0abb48871b5e69e9930dd2 (diff)
downloadsaffron-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 'include')
-rw-r--r--include/saffron_api.h2
-rw-r--r--include/saffron_widget.h16
2 files changed, 12 insertions, 6 deletions
diff --git a/include/saffron_api.h b/include/saffron_api.h
index 7b6fabb..64251e0 100644
--- a/include/saffron_api.h
+++ b/include/saffron_api.h
@@ -20,7 +20,7 @@ void saffron_window_show(SaffronWindow* window);
void saffron_window_main(SaffronWindow* window);
SaffronWidget* saffron_widget_hit_test(SaffronWidget* widget, int x, int y);
-SaffronBox* saffron_box_new(SaffronOrientation orientation, SaffronHorizontalAlignment halign, SaffronVerticalAlignment valign, int spacing, int padding, int margin);
+SaffronBox* saffron_box_new(SaffronOrientation orientation, SaffronHorizontalAlignment halign, SaffronVerticalAlignment valign, int spacing, int padding, int margin, int width, int height);
void saffron_box_layout(SaffronBox* box);
#endif
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 <SDL3/SDL.h>
-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