the great text and type rewrite

This commit is contained in:
Jorijn van der Graaf 2025-12-30 23:28:38 +01:00
commit d0cc3ad16a
15 changed files with 628 additions and 318 deletions

View file

@ -26,23 +26,23 @@ import std;
using namespace Crafter;
GridElement::GridElement(std::uint_fast32_t columns, std::uint_fast32_t rows, std::int_fast32_t spacingX, std::int_fast32_t spacingY, std::int_fast32_t paddingX, std::int_fast32_t paddingY, Anchor anchor) : Transform(anchor), columns(columns), rows(rows), spacingX(spacingX), spacingY(spacingY), paddingX(paddingX), paddingY(paddingY) {
GridElement::GridElement(std::uint32_t columns, std::uint32_t rows, std::int32_t spacingX, std::int32_t spacingY, std::int32_t paddingX, std::int32_t paddingY, Anchor anchor) : Transform(anchor), columns(columns), rows(rows), spacingX(spacingX), spacingY(spacingY), paddingX(paddingX), paddingY(paddingY) {
}
void GridElement::UpdatePositionScaled(Window& window) {
std::int_fast32_t cellWidth = (SCALE - (paddingX * 2) - (spacingX * (columns - 1))) / columns;
std::int_fast32_t cellHeight = (SCALE - (paddingY * 2) - (spacingY * (rows - 1))) / rows;
std::int32_t cellWidth = (SCALE32 - (paddingX * 2) - (spacingX * (columns - 1))) / columns;
std::int32_t cellHeight = (SCALE32 - (paddingY * 2) - (spacingY * (rows - 1))) / rows;
std::size_t childIndex = 0;
for (std::uint_fast32_t row = 0; row < rows && childIndex < children.size(); ++row) {
for (std::uint_fast32_t col = 0; col < columns && childIndex < children.size(); ++col) {
for (std::uint32_t row = 0; row < rows && childIndex < children.size(); ++row) {
for (std::uint32_t col = 0; col < columns && childIndex < children.size(); ++col) {
Transform* child = children[childIndex];
// Calculate position for this child
std::int_fast32_t childX = (cellWidth * col) + (spacingX * col) + paddingX;
std::int32_t childX = (cellWidth * col) + (spacingX * col) + paddingX;
std::int_fast32_t childY = (cellHeight * row) + (spacingY * row) + paddingY;
std::int32_t childY = (cellHeight * row) + (spacingY * row) + paddingY;
// Apply relative positioning
child->anchor.x = childX;