From 57a3bec8ad9b994d6decea8e9ffe39c2e9a5f535 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 17 Sep 2025 21:58:06 +0200 Subject: [PATCH] feat: added die colors and adjusted styles --- src/style.c | 27 +++++++++++++++++++++++++ src/style.h | 57 +++++++++++++++++++++++++---------------------------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/style.c b/src/style.c index eefd5d8..54b4c01 100644 --- a/src/style.c +++ b/src/style.c @@ -1,5 +1,7 @@ #include "style.h" +#include "application.h" #include "defs.h" +#include "dice.h" Clay_Color ContainerBackgrounds(size_t idx) { return (Clay_Color) { @@ -43,3 +45,28 @@ Clay_ElementDeclaration WindowStyle() { .backgroundColor = WindowBackground() }; } + +Clay_Color DieColor(enum die_type die) { + switch(die) { + case COIN: return (Clay_Color) { 230, 184, 48, 255 }; + case D4: return (Clay_Color) { 177, 56, 52, 255 }; + case D6: return (Clay_Color) { 115, 177, 52, 255 }; + case D8: return (Clay_Color) { 52, 177, 125, 255 }; + case D10: return (Clay_Color) { 52, 177, 176, 255 }; + case D12: return (Clay_Color) { 52, 93, 177, 255 }; + case D20: return (Clay_Color) { 177, 52, 140, 255 }; + case D100: return (Clay_Color) { 95, 52, 177, 255 }; + default: return (Clay_Color) { 0, 0, 0, 255 }; + } +} + +Clay_Color DieButtonColor(enum die_type die, bool selected) { + Clay_Color color = DieColor(die); + if (selected) { + float avg = (color.r + color.g + color.b) / 3.f; + color.r = (color.r - avg) * 0.8f + avg - 30; + color.g = (color.g - avg) * 0.8f + avg - 30; + color.b = (color.b - avg) * 0.8f + avg - 30; + } + return color; +} diff --git a/src/style.h b/src/style.h index 53de3aa..124e042 100644 --- a/src/style.h +++ b/src/style.h @@ -2,15 +2,23 @@ #define STYLE_H #include "defs.h" +#include "dice.h" #include #include +//////////////////////////////////// +// WINDOW STYLE +//////////////////////////////////// + +constexpr uint16_t windowPadding = 10; +constexpr float windowBackground = 0.15f; + //////////////////////////////////// // CONTAINER STYLE //////////////////////////////////// constexpr uint16_t containerGap = 10; -constexpr double defaultRadius = 5.; +constexpr double defaultRadius = 5.0; constexpr float containerBackgrounds[] = { .2f, @@ -24,22 +32,14 @@ constexpr float containerBorders[] = { }; constexpr Clay_Padding containerPadding = { - 32, 32, - 16, 16 + 24, 24, + 24, 24, }; -#define INNER_CONTAINER(depth_)\ - backgroundColor = ContainerBackgrounds(depth_),\ - .border = { ContainerBorders(depth_), CLAY_BORDER_ALL(2) },\ - .cornerRadius = defaultRadiusAll - - -//////////////////////////////////// -// WINDOW STYLE -//////////////////////////////////// - -constexpr uint16_t windowPadding = containerGap; -constexpr float windowBackground = .18f; +#define CONTAINER(depth_)\ +backgroundColor = ContainerBackgrounds(depth_),\ +.border = { ContainerBorders(depth_), CLAY_BORDER_ALL(2) },\ +.cornerRadius = defaultRadiusAll //////////////////////////////////// // TEXT STYLE @@ -58,30 +58,19 @@ constexpr uint16_t headerSizes[] = { 28, 16 }; -#define TEXT_STYLE(color_)\ - textColor = TextColors(color_) - #define BODY(color_)\ fontId = FONT_DEFAULT,\ - .fontSize = baseFontSize,\ - .TEXT_STYLE(color_) + .fontSize = baseFontSize -#define H(level_, color_)\ - fontId = FONT_BOLD,\ - .fontSize = headerSizes[(level_)-1],\ - .TEXT_STYLE(color_) +#define H(level_)\ +fontId = FONT_BOLD,\ +.fontSize = headerSizes[(level_)-1] //////////////////////////////////// // COMPILATIONS // | Functions and expressions that combine styling data from the settings above. //////////////////////////////////// -extern Clay_Color ContainerBackgrounds(size_t idx); -extern Clay_Color ContainerBorders(size_t idx); -extern Clay_Color TextColors(size_t idx); -extern Clay_Color WindowBackground(); -extern Clay_ElementDeclaration WindowStyle(); - constexpr Clay_Sizing layoutExpand = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) @@ -92,4 +81,12 @@ constexpr Clay_CornerRadius defaultRadiusAll = { defaultRadius, defaultRadius }; +extern Clay_Color ContainerBackgrounds(size_t idx); +extern Clay_Color ContainerBorders(size_t idx); +extern Clay_Color TextColors(size_t idx); +extern Clay_Color WindowBackground(); +extern Clay_ElementDeclaration WindowStyle(); +extern Clay_Color DieColor(enum die_type die); +extern Clay_Color DieButtonColor(enum die_type die, bool selected); + #endif // !STYLE_H