aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-04-21 18:11:23 +1200
committerArslaan Pathan <[email protected]>2026-04-21 18:11:23 +1200
commitcce512b7252ff7fd3f1329f224407fb772c9b4aa (patch)
treecc58f0cd705338c49c7f9829f7eb6c13befa994c /include
parent12fb8e70c79fb262a06431bfbd0e4ce97380d2a8 (diff)
downloadsaffron-cce512b7252ff7fd3f1329f224407fb772c9b4aa.tar.xz
saffron-cce512b7252ff7fd3f1329f224407fb772c9b4aa.zip
A bunch of more layout work
Diffstat (limited to 'include')
-rw-r--r--include/saffron_api.h1
-rw-r--r--include/saffron_widget.h13
2 files changed, 12 insertions, 2 deletions
diff --git a/include/saffron_api.h b/include/saffron_api.h
index e8fdfb8..7b6fabb 100644
--- a/include/saffron_api.h
+++ b/include/saffron_api.h
@@ -21,5 +21,6 @@ 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);
+void saffron_box_layout(SaffronBox* box);
#endif
diff --git a/include/saffron_widget.h b/include/saffron_widget.h
index 6d7b6bd..4461555 100644
--- a/include/saffron_widget.h
+++ b/include/saffron_widget.h
@@ -3,13 +3,22 @@
#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
+} SaffronSizeMode;
+
typedef struct SaffronWidget {
int x, y, w, h;
void (*draw)(struct SaffronWidget *self, SDL_Renderer *renderer);
void (*on_click)(struct SaffronWidget *self);
- struct SaffronWidget *parent;
- struct SaffronWidget **children;
+ struct SaffronWidget* parent;
+ struct SaffronWidget** children;
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
} SaffronWidget;
#endif