chore: renamed namespaces in ceramic/ to cera::

This commit is contained in:
Sara Gerretsen 2025-10-26 20:21:47 +01:00
parent f32494a29f
commit fc07424af4
8 changed files with 41 additions and 39 deletions

View file

@ -7,7 +7,9 @@
namespace application { namespace application {
Clay_RenderCommandArray RenderApplication() { Clay_RenderCommandArray RenderApplication() {
Clay_BeginLayout(); Clay_BeginLayout();
CLAY(CLAY_ID("OuterContainer"), style::Window()) { CLAY(CLAY_ID("OuterContainer"), cera::Window()) {
CLAY_AUTO_ID(cera::LeftPanelContainer()) {
}
} }
return Clay_EndLayout(); return Clay_EndLayout();
} }

View file

@ -2,26 +2,26 @@
#include "style.h" #include "style.h"
#include "resources.h" #include "resources.h"
namespace elements { namespace cera {
void TextButton(Clay_String text, Clay_Color color, OnHoveredFn onHovered, intptr_t onHoveredData) { 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({ CLAY_AUTO_ID({
.layout = { .layout = {
.padding = style::buttonPadding, .padding = cera::buttonPadding,
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }, .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
}, },
.backgroundColor = Clay_Hovered() .backgroundColor = Clay_Hovered()
? hovered ? hovered
: color, : color,
.cornerRadius = style::buttonRadii, .cornerRadius = cera::buttonRadii,
.border = { .border = {
style::ToHoveredColor(Clay_Hovered() ? hovered : color), cera::ToHoveredColor(Clay_Hovered() ? hovered : color),
CLAY_BORDER_ALL(2) CLAY_BORDER_ALL(2)
}, },
}) { }) {
Clay_OnHover(onHovered, onHoveredData); Clay_OnHover(onHovered, onHoveredData);
elements::Body(text, { cera::Body(text, {
.textColor = style::textColor, .textColor = cera::textColor,
.textAlignment = CLAY_TEXT_ALIGN_CENTER, .textAlignment = CLAY_TEXT_ALIGN_CENTER,
}); });
} }
@ -44,7 +44,7 @@ void Toggle(Clay_String label, Clay_Color selected, bool &state) {
}, },
}) { }) {
Clay_Color color{Clay_Hovered() Clay_Color color{Clay_Hovered()
? style::ToHoveredColor(selected) ? cera::ToHoveredColor(selected)
: selected : selected
}; };
Clay_OnHover(&ToggleHovered, (intptr_t)(&state)); Clay_OnHover(&ToggleHovered, (intptr_t)(&state));
@ -56,29 +56,29 @@ void Toggle(Clay_String label, Clay_Color selected, bool &state) {
}, },
.backgroundColor = (state .backgroundColor = (state
? selected ? selected
: style::color::transparent : cera::color::transparent
), ),
.cornerRadius = style::buttonRadii, .cornerRadius = cera::buttonRadii,
.border = { .border = {
color, color,
CLAY_BORDER_OUTSIDE(3) CLAY_BORDER_OUTSIDE(3)
}, },
}) { } }) { }
Body(label, { Body(label, {
.textColor = style::textColor .textColor = cera::textColor
}); });
} }
} }
void Body(Clay_String string, Clay_TextElementConfig baseCfg) { void Body(Clay_String string, Clay_TextElementConfig baseCfg) {
baseCfg.fontId = resources::FONT_DEFAULT; baseCfg.fontId = cera::FONT_DEFAULT;
baseCfg.fontSize = style::baseFontSize; baseCfg.fontSize = cera::baseFontSize;
CLAY_TEXT(string, CLAY_TEXT_CONFIG(baseCfg)); CLAY_TEXT(string, CLAY_TEXT_CONFIG(baseCfg));
} }
void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg) { void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg) {
baseCfg.fontId = resources::FONT_BOLD; baseCfg.fontId = cera::FONT_BOLD;
baseCfg.fontSize = style::headerSizes[(header)-1]; baseCfg.fontSize = cera::headerSizes[(header)-1];
CLAY_TEXT(string, CLAY_TEXT_CONFIG(baseCfg)); CLAY_TEXT(string, CLAY_TEXT_CONFIG(baseCfg));
} }
} }

View file

@ -4,12 +4,12 @@
#include <clay/clay.h> #include <clay/clay.h>
#include "style.h" #include "style.h"
namespace elements { namespace cera {
typedef void(*OnHoveredFn)(Clay_ElementId element, Clay_PointerData pointer, intptr_t data); 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 TextButton(Clay_String text, Clay_Color color, OnHoveredFn onHovered, intptr_t onHoveredData = 0);
void Toggle(Clay_String label, Clay_Color selected, bool &state); void Toggle(Clay_String label, Clay_Color selected, bool &state);
void Body(Clay_String string, 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 = style::textColor}); void Header(Clay_String string, size_t header, Clay_TextElementConfig baseCfg = {.textColor = cera::textColor});
} }
#endif // !ELEMENTS_H #endif // !ELEMENTS_H

View file

@ -5,18 +5,18 @@
#include <SDL3/SDL_render.h> #include <SDL3/SDL_render.h>
#include <SDL3_image/SDL_image.h> #include <SDL3_image/SDL_image.h>
namespace resources { namespace cera {
TTF_Font *defaultFont[FONT_MAX]; TTF_Font *defaultFont[FONT_MAX];
TTF_TextEngine *textEngine = nullptr; TTF_TextEngine *textEngine = nullptr;
void SetDefaultFont(char const *path) { 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) { if (defaultFont[FONT_DEFAULT] == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load default font '%s': %s", path, SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load default font '%s': %s", path, SDL_GetError());
exit(6); exit(6);
} }
TTF_SetFontHinting(defaultFont[FONT_DEFAULT], TTF_HINTING_LIGHT_SUBPIXEL); 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) { 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()); SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_OpenFont failed: Failed to load default bold font '%s': %s", path, SDL_GetError());
exit(6); exit(6);

View file

@ -3,7 +3,7 @@
#include <SDL3_ttf/SDL_ttf.h> #include <SDL3_ttf/SDL_ttf.h>
namespace resources { namespace cera {
enum Font { enum Font {
FONT_DEFAULT = 0, FONT_DEFAULT = 0,
FONT_BOLD = 1, FONT_BOLD = 1,

View file

@ -3,8 +3,8 @@
#include "resources.h" #include "resources.h"
#include <clay/clay.h> #include <clay/clay.h>
namespace style { namespace cera {
Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration baseCfg) { Clay_ElementDeclaration ListContainer(Clay_ElementDeclaration baseCfg) {
baseCfg.border = { baseCfg.border = {
.color = panelBorder, .color = panelBorder,
.width = CLAY_BORDER_ALL(2) .width = CLAY_BORDER_ALL(2)
@ -13,7 +13,7 @@ Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration base
return baseCfg; return baseCfg;
} }
Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) { Clay_ElementDeclaration PanelContainer(Clay_ElementDeclaration baseCfg) {
baseCfg.backgroundColor = panelBackground; baseCfg.backgroundColor = panelBackground;
baseCfg.border = { baseCfg.border = {
.color = panelBorder, .color = panelBorder,
@ -24,16 +24,16 @@ Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration bas
return baseCfg; return baseCfg;
} }
Clay_ElementDeclaration LeftPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) { Clay_ElementDeclaration LeftPanelContainer(Clay_ElementDeclaration baseCfg) {
baseCfg = PanelContainer(depth, baseCfg); baseCfg = PanelContainer(baseCfg);
baseCfg.border.width = { 0, 2, 2, 2, 0 }; baseCfg.border.width = { 0, 2, 2, 2, 0 };
baseCfg.cornerRadius = { 0, defaultRadius, 0, defaultRadius }; baseCfg.cornerRadius = { 0, defaultRadius, 0, defaultRadius };
baseCfg.layout.sizing.height = CLAY_SIZING_GROW(); baseCfg.layout.sizing.height = CLAY_SIZING_GROW();
return baseCfg; return baseCfg;
} }
Clay_ElementDeclaration RightPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) { Clay_ElementDeclaration RightPanelContainer(Clay_ElementDeclaration baseCfg) {
baseCfg = PanelContainer(depth, baseCfg); baseCfg = PanelContainer(baseCfg);
baseCfg.border.width = { 2, 0, 2, 2, 0 }; baseCfg.border.width = { 2, 0, 2, 2, 0 };
baseCfg.cornerRadius = { defaultRadius, 0, defaultRadius, 0 }; baseCfg.cornerRadius = { defaultRadius, 0, defaultRadius, 0 };
baseCfg.layout.sizing.height = CLAY_SIZING_GROW(); baseCfg.layout.sizing.height = CLAY_SIZING_GROW();

View file

@ -4,7 +4,7 @@
#include <clay/clay.h> #include <clay/clay.h>
#include <stdint.h> #include <stdint.h>
namespace style { namespace cera {
//////////////////////////////////// ////////////////////////////////////
// WINDOW STYLE // WINDOW STYLE
//////////////////////////////////// ////////////////////////////////////
@ -27,10 +27,10 @@ constexpr Clay_Padding panelPadding = {
24, 24, 24, 24,
}; };
Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration baseCfg); Clay_ElementDeclaration ListContainer(Clay_ElementDeclaration baseCfg = {});
Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg); Clay_ElementDeclaration PanelContainer(Clay_ElementDeclaration baseCfg = {});
Clay_ElementDeclaration LeftPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg); Clay_ElementDeclaration LeftPanelContainer(Clay_ElementDeclaration baseCfg = {});
Clay_ElementDeclaration RightPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg); Clay_ElementDeclaration RightPanelContainer(Clay_ElementDeclaration baseCfg = {});
Clay_ElementDeclaration Window(); Clay_ElementDeclaration Window();
//////////////////////////////////// ////////////////////////////////////

View file

@ -79,7 +79,7 @@ void InitSDL() {
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_Init failed: %s", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_Init failed: %s", SDL_GetError());
exit(4); 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()); SDL_LogError(SDL_LOG_CATEGORY_ERROR, "TTF_CreateRendererTextEngine failed: %s", SDL_GetError());
exit(5); exit(5);
} }
@ -90,7 +90,7 @@ void InitClay() {
clayMemorySize = Clay_MinMemorySize(); clayMemorySize = Clay_MinMemorySize();
clayPrimaryArena = Clay_CreateArenaWithCapacityAndMemory(clayMemorySize, SDL_malloc(clayMemorySize)); clayPrimaryArena = Clay_CreateArenaWithCapacityAndMemory(clayMemorySize, SDL_malloc(clayMemorySize));
Clay_Initialize(clayPrimaryArena, { (float)screenWidth, (float)screenHeight }, { HandleClayErrors }); Clay_Initialize(clayPrimaryArena, { (float)screenWidth, (float)screenHeight }, { HandleClayErrors });
Clay_SetMeasureTextFunction(MeasureText, resources::defaultFont); Clay_SetMeasureTextFunction(MeasureText, cera::defaultFont);
Clay_SetLayoutDimensions({ (float)screenWidth, (float)screenHeight }); Clay_SetLayoutDimensions({ (float)screenWidth, (float)screenHeight });
float x{ 0 }, y{ 0 }; float x{ 0 }, y{ 0 };
SDL_GetMouseState(&x, &y); SDL_GetMouseState(&x, &y);
@ -99,10 +99,10 @@ void InitClay() {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
InitSDL(); InitSDL();
resources::SetDefaultFont("assets/AdwaitaSans-Regular.ttf"); cera::SetDefaultFont("assets/AdwaitaSans-Regular.ttf");
LogOutputResolution(); LogOutputResolution();
InitClay(); InitClay();
backendData = { renderer, resources::textEngine, resources::defaultFont }; backendData = { renderer, cera::textEngine, cera::defaultFont };
SDL_Event event; SDL_Event event;
uint64_t startFrameTime = SDL_GetTicksNS(); uint64_t startFrameTime = SDL_GetTicksNS();
double deltaTime = 0.0; double deltaTime = 0.0;