From 652c89c996f1447e64ccc61ceeaab3a80e7b404d Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Thu, 30 Apr 2026 23:24:58 +1200 Subject: Add theming! its 10:24pm and im sleepy --- src/saffron_widget.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/saffron_widget.c') 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 #include #include @@ -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; +} -- cgit v1.2.3