diff --git a/src/application.c b/src/application.c index 7f148ca..da46b26 100644 --- a/src/application.c +++ b/src/application.c @@ -1,57 +1,9 @@ #include "application.h" - +#include "dice_container.h" #include "style.h" #include #include -static inline -void DiceSelectorContainer() { - CLAY(CLAY_ID("DiceSelector"), { - .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .sizing = { CLAY_SIZING_PERCENT(0.15), CLAY_SIZING_GROW(0) }, - .padding = containerPadding, - .childGap = paragraphGap, - }, - .INNER_CONTAINER(0), - }) { - } -} - -static inline -void ActiveDiceContainer() { - CLAY(CLAY_ID("ActiveDice"), { - .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, - .padding = containerPadding, - .childGap = paragraphGap, - }, - .INNER_CONTAINER(0), - }) { - CLAY_TEXT(CLAY_STRING("Header Text"), CLAY_TEXT_CONFIG({ - .H(1, 0), - })); - CLAY_TEXT(CLAY_STRING("Content text"), CLAY_TEXT_CONFIG({ - .BODY(0), - })); - } -} - -static inline -void DiceContainer() { - CLAY(CLAY_ID("DiceContainer"), { - .layout = { - .layoutDirection = CLAY_LEFT_TO_RIGHT, - .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_PERCENT(0.4) }, - .childGap = containerGap - }, - }) { - DiceSelectorContainer(); - ActiveDiceContainer(); - } -} - static inline void DiceLogContainer() { CLAY(CLAY_ID("LogContainer"), { @@ -76,7 +28,7 @@ void InitiativeListContainer() { Clay_RenderCommandArray RenderApplication() { Clay_BeginLayout(); - CLAY(CLAY_ID("OuterContainer"), windowStyle) { + CLAY(CLAY_ID("OuterContainer"), WindowStyle()) { DiceContainer(); CLAY(CLAY_ID("LowerSplitContainer"), { .layout = { diff --git a/src/dice_container.c b/src/dice_container.c new file mode 100644 index 0000000..187a09b --- /dev/null +++ b/src/dice_container.c @@ -0,0 +1,42 @@ +#include "dice_container.h" +#include +#include "style.h" + +static inline +void DiceSelectorContainer() { + CLAY(CLAY_ID("DiceSelector"), { + .layout = { + .layoutDirection = CLAY_TOP_TO_BOTTOM, + .sizing = { CLAY_SIZING_PERCENT(0.15), CLAY_SIZING_GROW(0) }, + .padding = containerPadding, + .childGap = paragraphGap, + }, + .INNER_CONTAINER(0), + }) { } +} + +static inline +void ActiveDiceContainer() { + CLAY(CLAY_ID("ActiveDice"), { + .layout = { + .layoutDirection = CLAY_TOP_TO_BOTTOM, + .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, + .padding = containerPadding, + .childGap = paragraphGap, + }, + .INNER_CONTAINER(0), + }) { } +} + +void DiceContainer() { + CLAY(CLAY_ID("DiceContainer"), { + .layout = { + .layoutDirection = CLAY_LEFT_TO_RIGHT, + .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_PERCENT(0.4) }, + .childGap = containerGap + }, + }) { + DiceSelectorContainer(); + ActiveDiceContainer(); + } +} diff --git a/src/dice_container.h b/src/dice_container.h new file mode 100644 index 0000000..0be5062 --- /dev/null +++ b/src/dice_container.h @@ -0,0 +1,6 @@ +#ifndef DICE_CONTAINER_H +#define DICE_CONTAINER_H + +extern void DiceContainer(); + +#endif // !DICE_CONTAINER_H diff --git a/src/style.c b/src/style.c index 8b13789..eefd5d8 100644 --- a/src/style.c +++ b/src/style.c @@ -1 +1,45 @@ +#include "style.h" +#include "defs.h" +Clay_Color ContainerBackgrounds(size_t idx) { + return (Clay_Color) { + 255*containerBackgrounds[idx], + 255*containerBackgrounds[idx], + 255*containerBackgrounds[idx], + 255 + }; +} + +Clay_Color ContainerBorders(size_t idx) { + return (Clay_Color) { + 255*containerBorders[idx], + 255*containerBorders[idx], + 255*containerBorders[idx], + 255 + }; +} + +Clay_Color TextColors(size_t idx) { + return (Clay_Color) { + 255*textColorsP[idx], + 255*textColorsP[idx], + 255*textColorsP[idx], + 255 + }; +} + +Clay_Color WindowBackground() { + return (Clay_Color) { 255*windowBackground, 255*windowBackground, 255*windowBackground, 255 }; +} + +Clay_ElementDeclaration WindowStyle() { + return (Clay_ElementDeclaration) { + .layout = { + .layoutDirection = CLAY_TOP_TO_BOTTOM, + .sizing = layoutExpand, + .padding = CLAY_PADDING_ALL(windowPadding), + .childGap = containerGap, + }, + .backgroundColor = WindowBackground() + }; +} diff --git a/src/style.h b/src/style.h index 25d846f..53de3aa 100644 --- a/src/style.h +++ b/src/style.h @@ -5,37 +5,33 @@ #include #include -constexpr int renderScale = 1; - //////////////////////////////////// // CONTAINER STYLE //////////////////////////////////// -constexpr uint16_t containerGap = 5 * renderScale; +constexpr uint16_t containerGap = 10; +constexpr double defaultRadius = 5.; + +constexpr float containerBackgrounds[] = { + .2f, + .3f, + .4f +}; +constexpr float containerBorders[] = { + .3f, + .4f, + .5f +}; + constexpr Clay_Padding containerPadding = { - 32 * renderScale, 32 * renderScale, - 16 * renderScale, 16 * renderScale -}; -constexpr Clay_Color containerColors[] = { - { 255*0.25, 255*0.25, 255*0.25, 255 }, - { 255*0.2, 255*0.2, 255*0.2, 255 }, - { 255*0.1, 255*0.1, 255*0.1, 255 }, + 32, 32, + 16, 16 }; -constexpr Clay_Sizing layoutExpand = { - .width = CLAY_SIZING_GROW(0), - .height = CLAY_SIZING_GROW(0) -}; - -constexpr double defaultRadius = 5.0 * renderScale; -constexpr Clay_CornerRadius defaultRadiusAll = { - defaultRadius, defaultRadius, - defaultRadius, defaultRadius -}; - -#define INNER_CONTAINER(depth_) \ -backgroundColor = containerColors[depth_],\ -.cornerRadius = defaultRadiusAll +#define INNER_CONTAINER(depth_)\ + backgroundColor = ContainerBackgrounds(depth_),\ + .border = { ContainerBorders(depth_), CLAY_BORDER_ALL(2) },\ + .cornerRadius = defaultRadiusAll //////////////////////////////////// @@ -43,39 +39,27 @@ backgroundColor = containerColors[depth_],\ //////////////////////////////////// constexpr uint16_t windowPadding = containerGap; -constexpr Clay_Color windowBackground = { - 255*0.35, 255*0.35, 255*0.35, 255 -}; -constexpr Clay_ElementDeclaration windowStyle = { - .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .sizing = layoutExpand, - .padding = CLAY_PADDING_ALL(windowPadding), - .childGap = containerGap, - }, - .backgroundColor = windowBackground -}; +constexpr float windowBackground = .18f; //////////////////////////////////// // TEXT STYLE //////////////////////////////////// -constexpr float paragraphGap = 10 * renderScale; -constexpr uint16_t baseFontSize = 16 * renderScale; - -constexpr Clay_Color textColors[] = { - { 250, 250, 250, 255 }, - { 250, 250, 250, 255 }, - { 250, 250, 250, 255 }, +constexpr float paragraphGap = 10; +constexpr uint16_t baseFontSize = 16; +constexpr float textColorsP[] = { + 0.9f, + 0.9f, + 0.9f }; constexpr uint16_t headerSizes[] = { - 64 * renderScale, 32 * renderScale, - 28 * renderScale, 16 * renderScale + 64, 32, + 28, 16 }; #define TEXT_STYLE(color_)\ - textColor = textColors[color_] + textColor = TextColors(color_) #define BODY(color_)\ fontId = FONT_DEFAULT,\ @@ -87,4 +71,25 @@ constexpr uint16_t headerSizes[] = { .fontSize = headerSizes[(level_)-1],\ .TEXT_STYLE(color_) +//////////////////////////////////// +// 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) +}; + +constexpr Clay_CornerRadius defaultRadiusAll = { + defaultRadius, defaultRadius, + defaultRadius, defaultRadius +}; + #endif // !STYLE_H