semi working wayland
This commit is contained in:
parent
e795ab880c
commit
4bb7219ccf
34 changed files with 13863 additions and 3121 deletions
|
|
@ -24,10 +24,7 @@ import Crafter.Event;
|
|||
import :Types;
|
||||
|
||||
namespace Crafter {
|
||||
/**
|
||||
* @brief General use UiElement for handeling input events.
|
||||
* Add to a window's elements member to start recieving events.
|
||||
*/
|
||||
export class Font;
|
||||
export class UiElement {
|
||||
public:
|
||||
Event<MouseMoveEvent> onMouseMove;
|
||||
|
|
@ -53,36 +50,19 @@ namespace Crafter {
|
|||
float anchorOffsetX;
|
||||
float anchorOffsetY;
|
||||
std::vector<Pixel_BU8_GU8_RU8_AU8> buffer;
|
||||
std::vector<UiElement> children;
|
||||
std::vector<std::unique_ptr<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, float relativeWidth, float relativeHeight, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
|
||||
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);
|
||||
UiElement(const std::filesystem::path& image, float anchorX, float anchorY, float relativeWidth, float relativeHeight, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
|
||||
UiElement(UiElement&&) noexcept = default;
|
||||
UiElement& operator=(UiElement&&) noexcept = default;
|
||||
};
|
||||
|
||||
export class TextElement : public UiElement {
|
||||
public:
|
||||
TextElement(const std::string_view text, float size, Pixel_BU8_GU8_RU8_AU8 color, const Font& font, float anchorX, float anchorY, float relativeWidth, float relativeHeight, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
|
||||
void RenderText(const std::string_view text, float size, Pixel_BU8_GU8_RU8_AU8 color, const Font& font);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue