aboutsummaryrefslogtreecommitdiff
path: root/tests/test_main.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 /tests/test_main.c
parent2cc161aabfe5c1343ca504b79a6a1c7706048a91 (diff)
downloadsaffron-652c89c996f1447e64ccc61ceeaab3a80e7b404d.tar.xz
saffron-652c89c996f1447e64ccc61ceeaab3a80e7b404d.zip
Add theming!
its 10:24pm and im sleepy
Diffstat (limited to 'tests/test_main.c')
-rw-r--r--tests/test_main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/test_main.c b/tests/test_main.c
index 39b41f2..cb92189 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -1,5 +1,6 @@
#include "saffron_api.h"
#include "saffron_layout.h"
+#include "saffron_theme.h"
#include <stdio.h>
#include <saffron.h>
#include <SDL3/SDL.h>
@@ -11,11 +12,16 @@
* THEY will make draw functions for you
* THIS IS A BAD IDEA */
void my_test_draw(SaffronWidget* self, SDL_Renderer* renderer) {
- SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
+ /* make use of the theme! */
+ SaffronTheme* theme = self->theme;
+ if (!theme) return; // good luck
+ SaffronColor secondary = theme->secondary;
+ SaffronColor tertiary = theme->tertiary;
+ SDL_SetRenderDrawColor(renderer, secondary.r, secondary.g, secondary.b, secondary.a);
SDL_FRect rect = {self->x, self->y, self->w, self->h};
SDL_RenderFillRect(renderer, &rect);
- SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
+ SDL_SetRenderDrawColor(renderer, tertiary.r, tertiary.g, tertiary.b, tertiary.a);
SDL_RenderRect(renderer, &rect);
}
@@ -33,6 +39,7 @@ int main(void) {
/* replace the root with our own, because we want horizontal */
saffron_widget_free(window->root);
window->root = (SaffronWidget*)saffron_box_new(SAFFRON_ORIENTATION_HORIZONTAL, SAFFRON_HALIGN_LEFT, SAFFRON_VALIGN_TOP, 5, 5, 0, window->w, window->h);
+ window->root->theme = SF_MACRO_DEFAULT_THEME;
/* i guess IM THE LUNATIC NOW
* DEAL WITH IT */
@@ -52,9 +59,8 @@ int main(void) {
test2->h = 72;
test2->draw = my_test_draw;
- SDL_Color color = {255, 255, 255, 255};
TTF_Font* font = TTF_OpenFont("/usr/share/fonts/fantasque-sans-mono/FantasqueSansMono-Regular.otf", 24);
- SaffronText* test3 = saffron_text_new("Mangoes", font, color);
+ SaffronText* test3 = saffron_text_new("Mangoes", font);
/* become lunatic, add custom clickhandler to.. text????????????? */
((SaffronWidget*)test3)->on_click = my_test_onclick;