diff options
| author | Arslaan Pathan <[email protected]> | 2026-04-21 15:28:04 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-04-21 15:28:04 +1200 |
| commit | 12fb8e70c79fb262a06431bfbd0e4ce97380d2a8 (patch) | |
| tree | 684a4ef53637317486736c6a5bc7e9b823336b2f /include | |
| parent | 3cdc4ac982c0a708dcd50a2f83f984303342902b (diff) | |
| download | saffron-12fb8e70c79fb262a06431bfbd0e4ce97380d2a8.tar.xz saffron-12fb8e70c79fb262a06431bfbd0e4ce97380d2a8.zip | |
Add foundations for layout
Diffstat (limited to 'include')
| -rw-r--r-- | include/saffron.h | 1 | ||||
| -rw-r--r-- | include/saffron_api.h | 4 | ||||
| -rw-r--r-- | include/saffron_layout.h | 33 |
3 files changed, 38 insertions, 0 deletions
diff --git a/include/saffron.h b/include/saffron.h index aae8086..d5cc59f 100644 --- a/include/saffron.h +++ b/include/saffron.h @@ -6,5 +6,6 @@ #include "saffron_text.h" #include "saffron_widget.h" #include "saffron_window.h" +#include "saffron_layout.h" #endif diff --git a/include/saffron_api.h b/include/saffron_api.h index c2e6c9c..e8fdfb8 100644 --- a/include/saffron_api.h +++ b/include/saffron_api.h @@ -3,12 +3,14 @@ #include "saffron_widget.h" /* satisfy the lsp and also if someone includes api without the saffron.h wrapper (you lunatic) then it still works */ #include "saffron_window.h" +#include "saffron_layout.h" bool saffron_init(void); void saffron_quit(void); void saffron_widget_draw(SaffronWidget* widget, SDL_Renderer *renderer); void saffron_widget_add_child(SaffronWidget* parent, SaffronWidget* child); +void saffron_widget_init(SaffronWidget* widget); /* generic primitive for generic widgets as said below. saffron_widget_new just calls this under the hood */ SaffronWidget* saffron_widget_new(); /* generic primitive for generic widgets, e.g. the window root. ideally window root is a hbox/vbox/box once those are implemented */ void saffron_widget_free(SaffronWidget* widget); @@ -18,4 +20,6 @@ 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); + #endif diff --git a/include/saffron_layout.h b/include/saffron_layout.h new file mode 100644 index 0000000..9e5ff40 --- /dev/null +++ b/include/saffron_layout.h @@ -0,0 +1,33 @@ +#ifndef SAFFRON_LAYOUT_H +#define SAFFRON_LAYOUT_H + +#include "saffron_widget.h" + +typedef enum { + SAFFRON_ORIENTATION_VERTICAL, + SAFFRON_ORIENTATION_HORIZONTAL +} SaffronOrientation; + +typedef enum { + SAFFRON_HALIGN_LEFT, + SAFFRON_HALIGN_CENTER, + SAFFRON_HALIGN_RIGHT +} SaffronHorizontalAlignment; + +typedef enum { + SAFFRON_VALIGN_TOP, + SAFFRON_VALIGN_CENTER, + SAFFRON_VALIGN_BOTTOM +} SaffronVerticalAlignment; + +typedef struct { + SaffronWidget base; + SaffronOrientation orientation; + SaffronHorizontalAlignment halign; + SaffronVerticalAlignment valign; + int spacing; + int padding; + int margin; +} SaffronBox; + +#endif |
