diff options
| author | Arslaan Pathan <[email protected]> | 2026-04-26 10:52:34 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-04-26 10:52:34 +1200 |
| commit | 4fbf7e5b7b5325828099456c347183ba92864862 (patch) | |
| tree | fef509e9f5ecc64cc9070b7a5820318908dbc156 /src | |
| parent | a2252b2952e4027b7edb420dccbd8494ae822b0f (diff) | |
| download | saffron-4fbf7e5b7b5325828099456c347183ba92864862.tar.xz saffron-4fbf7e5b7b5325828099456c347183ba92864862.zip | |
[feat] add some stuff??
Diffstat (limited to 'src')
| -rw-r--r-- | src/saffron_layout.c | 1 | ||||
| -rw-r--r-- | src/saffron_text.c | 31 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/saffron_layout.c b/src/saffron_layout.c index 725537f..72d915c 100644 --- a/src/saffron_layout.c +++ b/src/saffron_layout.c @@ -2,7 +2,6 @@ #include "saffron_api.h" #include "saffron_widget.h" #include <SDL3/SDL_video.h> -#include <stdio.h> #include <stdlib.h> #include <SDL3/SDL.h> #include <SDL3_ttf/SDL_ttf.h> diff --git a/src/saffron_text.c b/src/saffron_text.c new file mode 100644 index 0000000..8a093ea --- /dev/null +++ b/src/saffron_text.c @@ -0,0 +1,31 @@ +#include <SDL3/SDL_render.h> +#include <saffron.h> +#include <SDL3/SDL.h> +#include <SDL3_ttf/SDL_ttf.h> +#include <stdlib.h> + +static void saffron_text_draw(SaffronWidget* widget, SDL_Renderer* renderer) { + SaffronText* text = (SaffronText*)widget; + if (!text->text || !text->font) return; + + SDL_Surface* surface = TTF_RenderText_Blended(text->font, text->text, 0, text->color); + if (!surface) return; + + SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface); + SDL_FRect dest = {widget->x, widget->y, (float)surface->w, (float)surface->h}; + SDL_RenderTexture(renderer, texture, NULL, &dest); + + SDL_DestroyTexture(texture); + SDL_DestroySurface(surface); +} + +SaffronText* saffron_text_new(const char* text, int font_size, SDL_Color color) { + SaffronText* text_widget = malloc(sizeof(SaffronText)); + if (!text_widget) return NULL; + + saffron_widget_init((SaffronWidget*)text_widget); + + // todo actually do stuff + // and return something + // im tired ill do this later +} |
