clay-template/src/style.cpp
Sara 9b2ae482f1 feat: setup template
feat: implemented game of life

feat: implemented automatic stepping

fix: operator< Cell Cell now sorts by y first, then x

fix: equalized scroll x/y

fix: removed unused code path

fix: marked simulation::living as static since it's no longer forward
declared

tweak: decreased number of cells on random initialization

feat: defined Toggle element

feat: added debug information toggle to UI

feat: implemented simulation multithreading

feat: improved simulation frame delta controls

feat: inverted direction of panel colours

fix: removed leftover die colors

feat: reorganized and cleaned up style namespace

chore: increased button border width

feat: added SDL3 submodule

feat: added SDL3_ttf submodule

feat: moved clay to vendor (rather than include)

feat: replaced premake5 with CMake to vendor SDL3

chore: translated more C stuff to C++ in main.cpp

fix: stepping being inconsistent while running

feat: fixed incorrect behaviour on simulation and added benchmarking
code

feat: minor adjustments to UI layout

feat: increased thread count for pool

feat: improved simulation benchmarking

feat: simulation tasks can now be subdivided into separate workloads for
separate threads

feat: improved task counting thread safety

chore: massively increased random field

fix: target delta time is now enforced

feat: added toggle for locked framerate

fix: replaced manual .lock()/.unlock() calls with std::scoped_lock

fix: benchmarking code was off by a magnitude of 1

feat: separated cell state checking into separate function in case
another algo is faster than .contains

chore: some comments on variables in simulation.cpp

feat: set task split to hardware_concurrency()

feat: added basic culling to cell renderer

feat: implemented simulation threading toggle

chore: lowered random button's field size

chore: reduced padding on panel containers

chore: minor formatting adjustment

feat: added README.md

fix: inverted x scroll

feat: converted project to template

feat: added .clangd
2025-09-25 13:12:30 +02:00

88 lines
2.1 KiB
C++

#include "style.h"
#include "resources.h"
#include <clay/clay.h>
namespace style {
Clay_ElementDeclaration ListContainer(size_t depth, Clay_ElementDeclaration baseCfg) {
baseCfg.border = {
PanelBorder(depth),
CLAY_BORDER_ALL(2)
};
baseCfg.cornerRadius = defaultRadiusAll;
return baseCfg;
}
Clay_ElementDeclaration PanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) {
baseCfg.backgroundColor = PanelBackground(depth);
baseCfg.border = {
PanelBorder(depth),
CLAY_BORDER_OUTSIDE(2)
};
baseCfg.cornerRadius = defaultRadiusAll;
baseCfg.layout.padding = CLAY_PADDING_ALL(8);
return baseCfg;
}
Clay_ElementDeclaration LeftPanelContainer(size_t depth, Clay_ElementDeclaration baseCfg) {
baseCfg = PanelContainer(depth, 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);
baseCfg.border.width = { 2, 0, 2, 2, 0 };
baseCfg.cornerRadius = { defaultRadius, 0, defaultRadius, 0 };
baseCfg.layout.sizing.height = CLAY_SIZING_GROW();
return baseCfg;
}
Clay_Color PanelBackground(size_t idx) {
return {
255*panelBackground[idx],
255*panelBackground[idx],
255*panelBackground[idx],
255
};
}
Clay_Color PanelBorder(size_t idx) {
return {
255*panelBorder[idx],
255*panelBorder[idx],
255*panelBorder[idx],
255
};
}
Clay_Color TextColor(size_t idx) {
return {
255*textColorsP[idx],
255*textColorsP[idx],
255*textColorsP[idx],
255
};
}
Clay_ElementDeclaration Window() {
return {
.layout = {
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
.padding = CLAY_PADDING_ALL(0),
.childGap = 0,
.layoutDirection = CLAY_LEFT_TO_RIGHT,
},
};
}
Clay_Color ToHoveredColor(Clay_Color color) {
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;
}
}