feat: added die colors and adjusted styles

This commit is contained in:
Sara 2025-09-17 21:58:06 +02:00
parent 2cd5a953c9
commit 57a3bec8ad
2 changed files with 54 additions and 30 deletions

View file

@ -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;
}

View file

@ -2,15 +2,23 @@
#define STYLE_H
#include "defs.h"
#include "dice.h"
#include <clay/clay.h>
#include <stdint.h>
////////////////////////////////////
// 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,23 +32,15 @@ constexpr float containerBorders[] = {
};
constexpr Clay_Padding containerPadding = {
32, 32,
16, 16
24, 24,
24, 24,
};
#define INNER_CONTAINER(depth_)\
#define 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;
////////////////////////////////////
// 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_)\
#define H(level_)\
fontId = FONT_BOLD,\
.fontSize = headerSizes[(level_)-1],\
.TEXT_STYLE(color_)
.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