chore: renamed namespaces in ceramic/ to cera::
This commit is contained in:
parent
f32494a29f
commit
fc07424af4
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
#include <clay/clay.h>
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@
|
|||
#include <SDL3/SDL_render.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
namespace resources {
|
||||
namespace cera {
|
||||
enum Font {
|
||||
FONT_DEFAULT = 0,
|
||||
FONT_BOLD = 1,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
#include "resources.h"
|
||||
#include <clay/clay.h>
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <clay/clay.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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();
|
||||
|
||||
////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue