aboutsummaryrefslogtreecommitdiff
path: root/src/saffron_widget.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_widget.c
parent2cc161aabfe5c1343ca504b79a6a1c7706048a91 (diff)
downloadsaffron-652c89c996f1447e64ccc61ceeaab3a80e7b404d.tar.xz
saffron-652c89c996f1447e64ccc61ceeaab3a80e7b404d.zip
Add theming!
its 10:24pm and im sleepy
Diffstat (limited to 'src/saffron_widget.c')
-rw-r--r--src/saffron_widget.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/saffron_widget.c b/src/saffron_widget.c
index 955e265..6cb1664 100644
--- a/src/saffron_widget.c
+++ b/src/saffron_widget.c
@@ -1,3 +1,5 @@
+#include "saffron_api.h"
+#include "saffron_theme.h"
#include <SDL3/SDL.h>
#include <stdio.h>
#include <stdlib.h>
@@ -23,6 +25,7 @@ void saffron_widget_init(SaffronWidget* widget) {
widget->type = SAFFRON_WIDGET_UNKNOWN;
widget->free = NULL;
+ widget->theme = NULL;
}
SaffronWidget* saffron_widget_new(void) {
@@ -75,6 +78,14 @@ void saffron_widget_add_child(SaffronWidget *parent, SaffronWidget *child) {
if (parent->type == SAFFRON_WIDGET_BOX) {
saffron_box_layout((SaffronBox*)parent);
}
+
+ if (!child->theme) {
+ if (parent->theme) {
+ child->theme = parent->theme; /* inherit from parent */
+ } else {
+ child->theme = SF_MACRO_DEFAULT_THEME;
+ }
+ }
}
SaffronWidget* saffron_widget_hit_test(SaffronWidget* widget, int x, int y) {
@@ -100,3 +111,9 @@ SaffronWidget* saffron_widget_hit_test(SaffronWidget* widget, int x, int y) {
return widget;
}
+
+void saffron_widget_set_theme(SaffronWidget *widget, SaffronTheme *theme) {
+ if (!theme) return;
+ if (!widget) return;
+ widget->theme = theme;
+}