From fc07424af4870157e856b0c96170bdba9b475dd0 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 26 Oct 2025 20:21:47 +0100 Subject: [PATCH] chore: renamed namespaces in ceramic/ to cera:: --- src/application.cpp | 4 +++- src/ceramic/elements.cpp | 30 +++++++++++++++--------------- src/ceramic/elements.h | 6 +++--- src/ceramic/resources.cpp | 6 +++--- src/ceramic/resources.h | 2 +- src/ceramic/style.cpp | 14 +++++++------- src/ceramic/style.h | 10 +++++----- src/main.cpp | 8 ++++---- 8 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index c269306..904d071 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -7,7 +7,9 @@ namespace application { Clay_RenderCommandArray RenderApplication() { Clay_BeginLayout(); - CLAY(CLAY_ID("OuterContainer"), style::Window()) { + CLAY(CLAY_ID("OuterContainer"), cera::Window()) { + CLAY_AUTO_ID(cera::LeftPanelContainer()) { + } } return Clay_EndLayout(); } diff --git a/src/ceramic/elements.cpp b/src/ceramic/elements.cpp index 72ffea9..4650361 100644 --- a/src/ceramic/elements.cpp +++ b/src/ceramic/elements.cpp @@ -2,26 +2,26 @@ #include "style.h" #include "resources.h" -namespace elements { +namespace cera { void TextButton(Clay_String text, Clay_Color color, OnHoveredFn onHovered, intptr_t onHoveredData) { - Clay_Color hovered{ style::ToHoveredColor(color) }; + Clay_Color hovered{ cera::ToHoveredColor(color) }; CLAY_AUTO_ID({ .layout = { - .padding = style::buttonPadding, + .padding = cera::buttonPadding, .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }, }, .backgroundColor = Clay_Hovered() ? hovered : color, - .cornerRadius = style::buttonRadii, + .cornerRadius = cera::buttonRadii, .border = { - style::ToHoveredColor(Clay_Hovered() ? hovered : color), + cera::ToHoveredColor(Clay_Hovered() ? hovered : color), CLAY_BORDER_ALL(2) }, }) { Clay_OnHover(onHovered, onHoveredData); - elements::Body(text, { - .textColor = style::textColor, + cera::Body(text, { + .textColor = cera::textColor, .textAlignment = CLAY_TEXT_ALIGN_CENTER, }); } @@ -44,7 +44,7 @@ void Toggle(Clay_String label, Clay_Color selected, bool &state) { }, }) { Clay_Color color{Clay_Hovered() - ? style::ToHoveredColor(selected) + ? cera::ToHoveredColor(selected) : selected }; Clay_OnHover(&ToggleHovered, (intptr_t)(&state)); @@ -56,29 +56,29 @@ void Toggle(Clay_String label, Clay_Color selected, bool &state) { }, .backgroundColor = (state ? selected - : style::color::transparent + : cera::color::transparent ), - .cornerRadius = style::buttonRadii, + .cornerRadius = cera::buttonRadii, .border = { color, CLAY_BORDER_OUTSIDE(3) }, }) { } Body(label, { - .textColor = style::textColor + .textColor = cera::textColor }); } } void Body(Clay_String string, Clay_TextElementConfig baseCfg) { - baseCfg.fontId = resources::FONT_DEFAULT; - baseCfg.fontSize = style::baseFontSize; + baseCfg.fontId = cera::FONT_DEFAULT; + baseCfg.fontSize = cera::baseFontSize; CLAY_TEXT(string, CLAY_TEXT_CONFIG(baseCfg)); } void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg) { - baseCfg.fontId = resources::FONT_BOLD; - baseCfg.fontSize = style::headerSizes[(header)-1]; + baseCfg.fontId = cera::FONT_BOLD; + baseCfg.fontSize = cera::headerSizes[(header)-1]; CLAY_TEXT(string, CLAY_TEXT_CONFIG(baseCfg)); } } diff --git a/src/ceramic/elements.h b/src/ceramic/elements.h index c34a52e..c9a6881 100644 --- a/src/ceramic/elements.h +++ b/src/ceramic/elements.h @@ -4,12 +4,12 @@ #include #include "style.h" -namespace elements { +namespace cera { typedef void(*OnHoveredFn)(Clay_ElementId element, Clay_PointerData pointer, intptr_t data); void TextButton(Clay_String text, Clay_Color color, OnHoveredFn onHovered, intptr_t onHoveredData = 0); void Toggle(Clay_String label, Clay_Color selected, bool &state); -void Body(Clay_String string, Clay_TextElementConfig baseCfg = {.textColor = style::textColor}); -void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg = {.textColor = style::textColor}); +void Body(Clay_String string, Clay_TextElementConfig baseCfg = {.textColor = cera::textColor}); +void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg = {.textColor = cera::textColor}); } #endif // !ELEMENTS_H diff --git a/src/ceramic/resources.cpp b/src/ceramic/resources.cpp index 8a2494d..2798d80 100644 --- a/src/ceramic/resources.cpp +++ b/src/ceramic/resources.cpp @@ -5,18 +5,18 @@ #include #include -namespace resources { +namespace cera { TTF_Font *defaultFont[FONT_MAX]; TTF_TextEngine *textEngine = nullptr; void SetDefaultFont(char const *path) { - defaultFont[FONT_DEFAULT] = TTF_OpenFont(path, style::baseFontSize * 5); + defaultFont[FONT_DEFAULT] = TTF_OpenFont(path, cera::baseFontSize * 5); if (defaultFont[FONT_DEFAULT] == nullptr) { SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load default font '%s': %s", path, SDL_GetError()); exit(6); } TTF_SetFontHinting(defaultFont[FONT_DEFAULT], TTF_HINTING_LIGHT_SUBPIXEL); - defaultFont[FONT_BOLD] = TTF_OpenFont(path, style::baseFontSize * 5); + defaultFont[FONT_BOLD] = TTF_OpenFont(path, cera::baseFontSize * 5); if (defaultFont[FONT_BOLD] == nullptr) { SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load default bold font '%s': %s", path, SDL_GetError()); exit(6); diff --git a/src/ceramic/resources.h b/src/ceramic/resources.h index c341e54..3adc3cf 100644 --- a/src/ceramic/resources.h +++ b/src/ceramic/resources.h @@ -3,7 +3,7 @@ #include -namespace resources { +namespace cera { enum Font { FONT_DEFAULT = 0, FONT_BOLD = 1, diff --git a/src/ceramic/style.cpp b/src/ceramic/style.cpp index 1e24225..616b284 100644 --- a/src/ceramic/style.cpp +++ b/src/ceramic/style.cpp @@ -3,8 +3,8 @@ #include "resources.h" #include -namespace style { -Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration baseCfg) { +namespace cera { +Clay_ElementDeclaration ListContainer(Clay_ElementDeclaration baseCfg) { baseCfg.border = { .color = panelBorder, .width = CLAY_BORDER_ALL(2) @@ -13,7 +13,7 @@ Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration base return baseCfg; } -Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) { +Clay_ElementDeclaration PanelContainer(Clay_ElementDeclaration baseCfg) { baseCfg.backgroundColor = panelBackground; baseCfg.border = { .color = panelBorder, @@ -24,16 +24,16 @@ Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration bas return baseCfg; } -Clay_ElementDeclaration LeftPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) { - baseCfg = PanelContainer(depth, baseCfg); +Clay_ElementDeclaration LeftPanelContainer(Clay_ElementDeclaration baseCfg) { + baseCfg = PanelContainer(baseCfg); baseCfg.border.width = { 0, 2, 2, 2, 0 }; baseCfg.cornerRadius = { 0, defaultRadius, 0, defaultRadius }; baseCfg.layout.sizing.height = CLAY_SIZING_GROW(); return baseCfg; } -Clay_ElementDeclaration RightPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) { - baseCfg = PanelContainer(depth, baseCfg); +Clay_ElementDeclaration RightPanelContainer(Clay_ElementDeclaration baseCfg) { + baseCfg = PanelContainer(baseCfg); baseCfg.border.width = { 2, 0, 2, 2, 0 }; baseCfg.cornerRadius = { defaultRadius, 0, defaultRadius, 0 }; baseCfg.layout.sizing.height = CLAY_SIZING_GROW(); diff --git a/src/ceramic/style.h b/src/ceramic/style.h index 218ff7b..409396b 100644 --- a/src/ceramic/style.h +++ b/src/ceramic/style.h @@ -4,7 +4,7 @@ #include #include -namespace style { +namespace cera { //////////////////////////////////// // WINDOW STYLE //////////////////////////////////// @@ -27,10 +27,10 @@ constexpr Clay_Padding panelPadding = { 24, 24, }; -Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration baseCfg); -Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg); -Clay_ElementDeclaration LeftPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg); -Clay_ElementDeclaration RightPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg); +Clay_ElementDeclaration ListContainer(Clay_ElementDeclaration baseCfg = {}); +Clay_ElementDeclaration PanelContainer(Clay_ElementDeclaration baseCfg = {}); +Clay_ElementDeclaration LeftPanelContainer(Clay_ElementDeclaration baseCfg = {}); +Clay_ElementDeclaration RightPanelContainer(Clay_ElementDeclaration baseCfg = {}); Clay_ElementDeclaration Window(); //////////////////////////////////// diff --git a/src/main.cpp b/src/main.cpp index d649347..93ed603 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,7 +79,7 @@ void InitSDL() { SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_Init failed: %s", SDL_GetError()); exit(4); } - if ((resources::textEngine = TTF_CreateRendererTextEngine(renderer)) == nullptr) { + if (!(cera::textEngine = TTF_CreateRendererTextEngine(renderer))) { SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_CreateRendererTextEngine failed: %s", SDL_GetError()); exit(5); } @@ -90,7 +90,7 @@ void InitClay() { clayMemorySize = Clay_MinMemorySize(); clayPrimaryArena = Clay_CreateArenaWithCapacityAndMemory(clayMemorySize, SDL_malloc(clayMemorySize)); Clay_Initialize(clayPrimaryArena, { (float)screenWidth, (float)screenHeight }, { HandleClayErrors }); - Clay_SetMeasureTextFunction(MeasureText, resources::defaultFont); + Clay_SetMeasureTextFunction(MeasureText, cera::defaultFont); Clay_SetLayoutDimensions({ (float)screenWidth, (float)screenHeight }); float x{ 0 }, y{ 0 }; SDL_GetMouseState(&x, &y); @@ -99,10 +99,10 @@ void InitClay() { int main(int argc, char *argv[]) { InitSDL(); - resources::SetDefaultFont("assets/AdwaitaSans-Regular.ttf"); + cera::SetDefaultFont("assets/AdwaitaSans-Regular.ttf"); LogOutputResolution(); InitClay(); - backendData = { renderer, resources::textEngine, resources::defaultFont }; + backendData = { renderer, cera::textEngine, cera::defaultFont }; SDL_Event event; uint64_t startFrameTime = SDL_GetTicksNS(); double deltaTime = 0.0;