feat: added die colors and adjusted styles
This commit is contained in:
parent
2cd5a953c9
commit
57a3bec8ad
27
src/style.c
27
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;
|
||||
}
|
||||
|
|
57
src/style.h
57
src/style.h
|
@ -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,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
|
||||
|
|
Loading…
Reference in a new issue