4#include "flint/graphics/types/color.h"
5#include "flint/math/types.h"
6#include "flint/ui/ui-event.h"
7#include "flint/ui/ui-types.h"
85 [[nodiscard]]
const std::string &
getId()
const;
90 [[nodiscard]]
bool isVisible()
const {
94 [[nodiscard]]
bool isEnabled()
const {
104 [[nodiscard]]
const std::vector<std::unique_ptr<UINode>> &
getChildren()
const {
116 [[nodiscard]]
const std::string &
getText()
const;
120 [[nodiscard]] uint16_t getFontSize()
const;
124 [[nodiscard]]
Color getColor()
const;
130 m_normalColor = color;
136 m_activeColor = color;
176 m_fontName = std::move(name);
182 m_fontWeight = weight;
185 void setTextOpticalBias(
float bias) {
186 m_textOpticalBias = bias;
189 [[nodiscard]]
float getTextOpticalBias()
const {
190 return m_textOpticalBias;
202 [[nodiscard]]
bool isFocused()
const {
206 void setHorizontalAlign(UIAlign align);
207 void setVerticalAlign(UIAlign align);
209 [[nodiscard]] UIAlign getHorizontalAlign()
const;
210 [[nodiscard]] UIAlign getVerticalAlign()
const;
220 UINode *m_parent =
nullptr;
221 std::vector<std::unique_ptr<UINode>> m_children;
230 bool m_visible =
true;
231 bool m_enabled =
true;
232 float m_displayScale = 1.0f;
234 std::string m_fontName;
235 uint16_t m_fontWeight = 400;
236 uint16_t m_fontSize = 16;
237 float m_textOpticalBias = 0.f;
241 Color m_normalColor = Colors::white;
242 Color m_activeColor = {0, 255, 0, 255};
247 return (m_hovered || m_focused) ? m_activeColor : m_normalColor;
250 bool m_hovered =
false;
251 bool m_focused =
false;
253 UIAlign m_horizontalAlign = UIAlign::Stretch;
254 UIAlign m_verticalAlign = UIAlign::Start;
255 float m_layoutGrow = 0.f;
263 bool idExists(
const std::string &
id)
const;
Dynamic 2D batching engine processing shape vector geometry and hardware-accelerated text strings....
Manages an isolated user interface canvas workspace sandbox, hosting its own independent node tree an...
void setID(std::string id)
Sets a unique string identifier for this node.
void setContext(UIContext *context)
Recursively propagates a pointer back to the parent-managing workspace layer.
void setFontWeight(uint16_t weight)
Assigns thickness parameters across structural type vectors (e.g., 400 for regular,...
Vec2f getDesiredSize() const
Get the node's requested size from the measure pass.
const std::vector< std::unique_ptr< UINode > > & getChildren() const
Get the list of this node's child nodes.
virtual void render(UICanvas &canvas) const
Pushes current styling rules and geometries straight down to the active pipeline vertex drawing queue...
void setEnabled(bool enabled)
Enables or disables user interaction for this widget.
virtual void setNormalColor(Color color)
Sets the base color of the widget.
void setVisible(bool visible)
Sets widget visibility.
virtual void setActiveColor(Color color)
Sets visual colors used when inputs hover across or lock selections on the widget container.
virtual const Color & currentColor() const
Dynamically picks active color metrics using real-time interaction states.
virtual void setFocused(bool focused)
Sets whether this node is currently focused.
Rect< float > m_layoutRect
Vec2f getPosition() const
Get the node's relative local position.
Vec2f getSize() const
Get the node's base size.
void setFont(std::string name)
Assigns a custom typography description token mapping back to cached font elements.
virtual bool isFocusable() const
Dictates if keyboard selection trackers or gamepad vectors can snap control focuses onto this item.
virtual void handleEvent(const UIEvent &event)
Traverses active child collections to pass translated physical hardware inputs down to focused widget...
virtual void arrange(const Rect< float > &rect)
Pass 2 of the layout engine: Evaluates layout adjustments to pin final screen coordinate values to th...
virtual bool consumesDirectionalInput() const
Dictates whether this widget captures directional inputs instead of passing them to focus navigation.
void addChild(std::unique_ptr< UINode > child)
Inserts a child widget to live inside this layout element container boundary.
virtual bool hitTest(Vec2f point) const
Computes true if a vector coordinate sits inside the spatial arrangement bounding tracking layout box...
virtual void measure(UIConstraints constraints)
Pass 1 of the layout engine: Crawls branches recursively to compute base display boundaries requested...
Abstract base class for all UI widgets, managing hierarchy tracking, layout passes,...
void setSize(Vec2f size)
Assigns a manual static override layout budget footprint dimensions limit.
const std::string & getId() const
Gets the unique lookup ID string of this node.
void setFontSize(uint16_t fontSize)
Set the rendering font size in points.
void setColor(Color color)
Sets the base color of the widget.
float getLayoutGrow() const
Gets the dynamic expansion weight used inside stack layout grids.
void setText(std::string text)
Sets the text content for widgets that display text.
void setPosition(Vec2f position)
Updates the relative local rendering position coordinates of this element block.
void setLayoutGrow(float grow)
Assigns dynamic expansion multipliers used to balance alignment distributions inside sequential layou...
const Rect< float > & getLayoutRect() const
Gets the final screen-space bounding box calculated during the arrange pass.
const std::string & getText() const
Gets the current text content of the widget.
RGBA color with 8-bit unsigned components.
Generic axis-aligned rectangle defined by a position and size.
Represents the boundary budget passed down the node tree during layout allocation.
A normalized data packet containing translated input data routed down the UI node tree.