new structure
This commit is contained in:
parent
dfe9b1abe9
commit
1155e67d63
37 changed files with 2399 additions and 751 deletions
88
interfaces/Crafter.Graphics-UiElement.cppm
Normal file
88
interfaces/Crafter.Graphics-UiElement.cppm
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
Crafter®.Graphics
|
||||
Copyright (C) 2025 Catcrafts®
|
||||
Catcrafts.net
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
export module Crafter.Graphics:UiElement;
|
||||
import std;
|
||||
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 UiElement {
|
||||
public:
|
||||
Event<MouseMoveEvent> onMouseMove;
|
||||
Event<MouseMoveEvent> onMouseEnter;
|
||||
Event<MouseMoveEvent> onMouseLeave;
|
||||
Event<MousePoint> onMouseRightClick;
|
||||
Event<MousePoint> onMouseLeftClick;
|
||||
Event<MousePoint> onMouseRightHold;
|
||||
Event<MousePoint> onMouseLeftHold;
|
||||
Event<MousePoint> onMouseRightRelease;
|
||||
Event<MousePoint> onMouseLeftRelease;
|
||||
float z;
|
||||
float anchorX;
|
||||
float anchorY;
|
||||
bool useRelativeSize;
|
||||
bool ignoreScaling;
|
||||
std::uint32_t bufferWidth;
|
||||
std::uint32_t bufferHeight;
|
||||
std::uint32_t absoluteWidth;
|
||||
std::uint32_t absoluteHeight;
|
||||
float relativeWidth;
|
||||
float relativeHeight;
|
||||
float anchorOffsetX;
|
||||
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);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue