From 4fbf7e5b7b5325828099456c347183ba92864862 Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Sun, 26 Apr 2026 10:52:34 +1200 Subject: [feat] add some stuff?? --- include/saffron.h | 3 +++ include/saffron_api.h | 7 +++++++ include/saffron_button.h | 8 +++++--- include/saffron_text.h | 15 +++++++++++++++ include/saffron_widget.h | 1 + 5 files changed, 31 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/saffron.h b/include/saffron.h index d5cc59f..53f27fb 100644 --- a/include/saffron.h +++ b/include/saffron.h @@ -1,6 +1,9 @@ #ifndef SAFFRON_H #define SAFFRON_H +#include +#include + #include "saffron_api.h" #include "saffron_button.h" #include "saffron_text.h" diff --git a/include/saffron_api.h b/include/saffron_api.h index 64251e0..4ab4731 100644 --- a/include/saffron_api.h +++ b/include/saffron_api.h @@ -4,6 +4,10 @@ #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" +#include "saffron_text.h" +#include +#include +#include bool saffron_init(void); void saffron_quit(void); @@ -23,4 +27,7 @@ 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, int width, int height); void saffron_box_layout(SaffronBox* box); +SaffronText* saffron_text_new(const char* text, int font_size, SDL_Color color); +void saffron_text_set_text(SaffronText* text, const char* new_text); + #endif diff --git a/include/saffron_button.h b/include/saffron_button.h index 3112edf..ab4ed97 100644 --- a/include/saffron_button.h +++ b/include/saffron_button.h @@ -1,11 +1,13 @@ #ifndef SAFFRON_BUTTON_H #define SAFFRON_BUTTON_H +#include "saffron_layout.h" #include "saffron_widget.h" -typedef struct { - SaffronWidget base; // must be first, or we're f**ked - const char* label; +typedef struct SaffronButton { + SaffronBox base; + void (*callback)(struct SaffronButton* self); + bool enabled; } SaffronButton; #endif diff --git a/include/saffron_text.h b/include/saffron_text.h index e69de29..51bfc47 100644 --- a/include/saffron_text.h +++ b/include/saffron_text.h @@ -0,0 +1,15 @@ +#ifndef SAFFRON_TEXT_H +#define SAFFRON_TEXT_H + +#include "saffron_widget.h" +#include +#include + +typedef struct { + SaffronWidget base; + char* text; + TTF_Font* font; + SDL_Color color; +} SaffronText; + +#endif diff --git a/include/saffron_widget.h b/include/saffron_widget.h index 7fc6bc8..ddf4f78 100644 --- a/include/saffron_widget.h +++ b/include/saffron_widget.h @@ -12,6 +12,7 @@ typedef enum { typedef enum { SAFFRON_WIDGET_UNKNOWN, SAFFRON_WIDGET_BOX, + SAFFRON_WIDGET_TEXT } SaffronWidgetType; typedef struct SaffronWidget { -- cgit v1.2.3