This commit is contained in:
Jorijn van der Graaf 2025-06-14 01:45:33 +02:00
commit 53df70b4f1
70 changed files with 108 additions and 11285 deletions

View file

@ -27,8 +27,8 @@ export module Crafter.Graphics:UiElement;
import Crafter.Event;
import :Types;
export namespace Crafter {
class UiElement {
namespace Crafter {
export class UiElement {
public:
Event<MouseMoveEvent> onMouseMove;
Event<MouseMoveEvent> onMouseEnter;
@ -54,7 +54,35 @@ export namespace Crafter {
float anchorOffsetY;
std::vector<Pixel_BU8_GU8_RU8_AU8> buffer;
std::vector<UiElement> children;
/**
* @brief Constructs a UiElement with absolute dimensions
* @param anchorX Relative position where this elements x anchor (top-left) is placed to its parent x anchor
* @param anchorY Relative position where this elements y anchor (top-left) is placed to its parent y anchor
* @param bufferWidth The width of this elements pixel buffer
* @param bufferHeight The height of this elements pixel buffer
* @param absoluteWidth The absolute x size in pixels this element should be scaled to
* @param absoluteHeight The absolute y size in pixels this element should be scaled to
* @param anchorOffsetX The amount this element's anchor should be offset from the top left corner (0.5 to in the middle)
* @param anchorOffsetY The amount this element's anchor should be offset from the top left corner (0.5 to place it in the middle)
* @param z This elements Z position
* @param ignoreScaling Wether this element ignores the scaling of the window, if true its size will be scaled according to the window scale
*/
UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
/**
* @brief Constructs a UiElement with relative dimensions
* @param anchorX Relative position where this elements x anchor (top-left) is placed to its parent x anchor
* @param anchorY Relative position where this elements y anchor (top-left) is placed to its parent y anchor
* @param bufferWidth The width of this elements pixel buffer
* @param bufferHeight The height of this elements pixel buffer
* @param relativeWidth The relative x size this element should be scaled to compared to its parent
* @param relativeHeight The relative y size this element should be scaled to compared to its parent
* @param anchorOffsetX The amount this element's anchor should be offset from the top left corner (0.5 to in the middle)
* @param anchorOffsetY The amount this element's anchor should be offset from the top left corner (0.5 to place it in the middle)
* @param z This elements Z position
* @param ignoreScaling Wether this element ignores the scaling of the window, if true its size will be scaled according to the window scale
*/
UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, float relativeWidth, float relativeHeight, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
};
}