cleaned up renderer
This commit is contained in:
parent
afe23851f0
commit
d661c88ee2
58 changed files with 3030 additions and 4722 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Crafter®.Graphics
|
||||
Copyright (C) 2025 Catcrafts®
|
||||
Copyright (C) 2026 Catcrafts®
|
||||
Catcrafts.net
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
|
@ -20,24 +20,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
module Crafter.Graphics:GridElement_impl;
|
||||
import :GridElement;
|
||||
import :Window;
|
||||
import :Rendertarget;
|
||||
import :Types;
|
||||
import std;
|
||||
|
||||
using namespace Crafter;
|
||||
|
||||
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) {
|
||||
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, Anchor2D anchor) : Transform2D(anchor), columns(columns), rows(rows), spacingX(spacingX), spacingY(spacingY), paddingX(paddingX), paddingY(paddingY) {
|
||||
|
||||
}
|
||||
|
||||
void GridElement::UpdatePositionScaled(Window& window) {
|
||||
std::int32_t cellWidth = (SCALE32 - (paddingX * 2) - (spacingX * (columns - 1))) / columns;
|
||||
std::int32_t cellHeight = (SCALE32 - (paddingY * 2) - (spacingY * (rows - 1))) / rows;
|
||||
void GridElement::UpdatePositionScaled(Rendertarget& window) {
|
||||
std::int32_t cellWidth = (paddingX * 2) - (spacingX * (columns - 1)) / columns;
|
||||
std::int32_t cellHeight = (paddingY * 2) - (spacingY * (rows - 1)) / rows;
|
||||
|
||||
std::size_t childIndex = 0;
|
||||
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];
|
||||
Transform2D* child = children[childIndex];
|
||||
|
||||
// Calculate position for this child
|
||||
std::int32_t childX = (cellWidth * col) + (spacingX * col) + paddingX;
|
||||
|
|
@ -57,12 +57,12 @@ void GridElement::UpdatePositionScaled(Window& window) {
|
|||
}
|
||||
}
|
||||
|
||||
void GridElement::UpdatePosition(Window& window) {
|
||||
window.ScaleElement(*this);
|
||||
void GridElement::UpdatePosition(Rendertarget& window) {
|
||||
ScaleElement(window.transform);
|
||||
UpdatePositionScaled(window);
|
||||
}
|
||||
|
||||
void GridElement::UpdatePosition(Window& window, Transform& parent) {
|
||||
window.ScaleElement(*this, parent);
|
||||
void GridElement::UpdatePosition(Rendertarget& window, Transform2D& parent) {
|
||||
ScaleElement(parent);
|
||||
UpdatePositionScaled(window);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue