aboutsummaryrefslogtreecommitdiff
path: root/src/saffron_text.c
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-04-30 23:24:58 +1200
committerArslaan Pathan <[email protected]>2026-04-30 23:24:58 +1200
commit652c89c996f1447e64ccc61ceeaab3a80e7b404d (patch)
treea945461e287c66fd8dba0500bc06d0379d78907e /src/saffron_text.c
parent2cc161aabfe5c1343ca504b79a6a1c7706048a91 (diff)
downloadsaffron-652c89c996f1447e64ccc61ceeaab3a80e7b404d.tar.xz
saffron-652c89c996f1447e64ccc61ceeaab3a80e7b404d.zip
Add theming!
its 10:24pm and im sleepy
Diffstat (limited to 'src/saffron_text.c')
-rw-r--r--src/saffron_text.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/saffron_text.c b/src/saffron_text.c
index 6e7accf..3beb219 100644
--- a/src/saffron_text.c
+++ b/src/saffron_text.c
@@ -13,7 +13,12 @@ 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);
+ SaffronTheme* theme = ((SaffronWidget*)text)->theme;
+ if (!theme) return;
+
+ SaffronColor text_color = theme->primary;
+ SDL_Color color = {text_color.r, text_color.g, text_color.b, text_color.a};
+ SDL_Surface* surface = TTF_RenderText_Blended(text->font, text->text, 0, color);
if (!surface) return;
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
@@ -24,7 +29,7 @@ static void saffron_text_draw(SaffronWidget* widget, SDL_Renderer* renderer) {
SDL_DestroySurface(surface);
}
-SaffronText* saffron_text_new(const char* text, TTF_Font* font, SDL_Color color) {
+SaffronText* saffron_text_new(const char* text, TTF_Font* font) {
SaffronText* text_widget = malloc(sizeof(SaffronText));
if (!text_widget) return NULL;
@@ -47,7 +52,6 @@ SaffronText* saffron_text_new(const char* text, TTF_Font* font, SDL_Color color)
strcpy(text_widget->text, text);
}
text_widget->font = font;
- text_widget->color = color;
return text_widget;
}