4#include "flint/core/api.h"
5#include "flint/graphics/types/color.h"
6#include "flint/math/types.h"
7#include "flint/ui/ui-event.h"
8#include "flint/ui/ui-types.h"
48 FLINT_API
void addChild(std::unique_ptr<UINode> child);
84 FLINT_API
void setID(std::string
id);
86 [[nodiscard]] FLINT_API
const std::string &
getId()
const;
91 [[nodiscard]]
bool isVisible()
const {
95 [[nodiscard]]
bool isEnabled()
const {
105 [[nodiscard]]
const std::vector<std::unique_ptr<UINode>> &
getChildren()
const {
117 [[nodiscard]] FLINT_API
const std::string &
getText()
const;
121 [[nodiscard]] FLINT_API uint16_t getFontSize()
const;
125 [[nodiscard]] FLINT_API
Color getColor()
const;
131 m_normalColor = color;
137 m_activeColor = color;
177 m_fontName = std::move(name);
183 m_fontWeight = weight;
186 void setTextOpticalBias(
float bias) {
187 m_textOpticalBias = bias;
190 [[nodiscard]]
float getTextOpticalBias()
const {
191 return m_textOpticalBias;
203 [[nodiscard]]
bool isFocused()
const {
207 FLINT_API
void setHorizontalAlign(UIAlign align);
208 FLINT_API
void setVerticalAlign(UIAlign align);
210 [[nodiscard]] FLINT_API UIAlign getHorizontalAlign()
const;
211 [[nodiscard]] FLINT_API UIAlign getVerticalAlign()
const;
221 UINode *m_parent =
nullptr;
222 std::vector<std::unique_ptr<UINode>> m_children;
231 bool m_visible =
true;
232 bool m_enabled =
true;
233 float m_displayScale = 1.0f;
235 std::string m_fontName;
236 uint16_t m_fontWeight = 400;
237 uint16_t m_fontSize = 16;
238 float m_textOpticalBias = 0.f;
242 Color m_normalColor = Colors::white;
243 Color m_activeColor = {0, 255, 0, 255};
248 return (m_hovered || m_focused) ? m_activeColor : m_normalColor;
251 bool m_hovered =
false;
252 bool m_focused =
false;
254 UIAlign m_horizontalAlign = UIAlign::Stretch;
255 UIAlign m_verticalAlign = UIAlign::Start;
256 float m_layoutGrow = 0.f;
264 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...
Abstract base class for all UI widgets, managing hierarchy tracking, layout passes,...
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.
FLINT_API const std::string & getText() const
Gets the current text content of the widget.
FLINT_API void setLayoutGrow(float grow)
Assigns dynamic expansion multipliers used to balance alignment distributions inside sequential layou...
virtual FLINT_API bool hitTest(Vec2f point) const
Computes true if a vector coordinate sits inside the spatial arrangement bounding tracking layout box...
FLINT_API void setFontSize(uint16_t fontSize)
Set the rendering font size in points.
virtual void setNormalColor(Color color)
Sets the base color of the widget.
virtual FLINT_API void measure(UIConstraints constraints)
Pass 1 of the layout engine: Crawls branches recursively to compute base display boundaries requested...
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.
FLINT_API void setText(std::string text)
Sets the text content for widgets that display text.
FLINT_API void setContext(UIContext *context)
Recursively propagates a pointer back to the parent-managing workspace layer.
Rect< float > m_layoutRect
Vec2f getPosition() const
Get the node's relative local position.
Vec2f getSize() const
Get the node's base size.
FLINT_API void setID(std::string id)
Sets a unique string identifier for this node.
virtual FLINT_API void render(UICanvas &canvas) const
Pushes current styling rules and geometries straight down to the active pipeline vertex drawing queue...
FLINT_API void setSize(Vec2f size)
Assigns a manual static override layout budget footprint dimensions limit.
virtual FLINT_API void arrange(const Rect< float > &rect)
Pass 2 of the layout engine: Evaluates layout adjustments to pin final screen coordinate values to th...
FLINT_API const std::string & getId() const
Gets the unique lookup ID string of this node.
void setFont(std::string name)
Assigns a custom typography description token mapping back to cached font elements.
FLINT_API void setVisible(bool visible)
Sets widget visibility.
virtual bool isFocusable() const
Dictates if keyboard selection trackers or gamepad vectors can snap control focuses onto this item.
FLINT_API float getLayoutGrow() const
Gets the dynamic expansion weight used inside stack layout grids.
FLINT_API void addChild(std::unique_ptr< UINode > child)
Inserts a child widget to live inside this layout element container boundary.
virtual FLINT_API void handleEvent(const UIEvent &event)
Traverses active child collections to pass translated physical hardware inputs down to focused widget...
FLINT_API void setEnabled(bool enabled)
Enables or disables user interaction for this widget.
virtual bool consumesDirectionalInput() const
Dictates whether this widget captures directional inputs instead of passing them to focus navigation.
FLINT_API void setPosition(Vec2f position)
Updates the relative local rendering position coordinates of this element block.
FLINT_API const Rect< float > & getLayoutRect() const
Gets the final screen-space bounding box calculated during the arrange pass.
FLINT_API void setColor(Color color)
Sets the base color 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.