Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
panel.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4
5#include "flint/ui/ui-node.h"
6#include "flint/ui/ui-types.h"
7
8namespace Flint {
9
18 class UIPanel : public UINode {
19 public:
20 UIPanel() = default;
21 ~UIPanel() override = default;
22
24 void setLayout(UILayoutDirection direction);
25
27 [[nodiscard]] UILayoutDirection getLayout() const {
28 return m_direction;
29 }
30
32 void setPadding(UIPadding padding);
33
34 [[nodiscard]] const UIPadding &getPadding() const {
35 return m_padding;
36 }
37
39 void setGap(float gap);
40
41 [[nodiscard]] float getGap() const {
42 return m_gap;
43 }
44
48 void measure(UIConstraints constraints) override;
49
55 void arrange(const Rect<float> &rect) override;
56 void render(UICanvas &canvas) const override;
57
58 private:
59 UILayoutDirection m_direction = UILayoutDirection::Vertical;
60 UIPadding m_padding = {};
61 float m_gap = 8.0f;
62 };
63
64}
Dynamic 2D batching engine processing shape vector geometry and hardware-accelerated text strings....
Definition ui-canvas.h:106
Abstract base class for all UI widgets, managing hierarchy tracking, layout passes,...
Definition ui-node.h:30
UILayoutDirection getLayout() const
Gets the active layout axis stacking direction.
Definition panel.h:27
void measure(UIConstraints constraints) override
Accumulates the child node sizes along the layout axis, adding border paddings.
void render(UICanvas &canvas) const override
Pushes current styling rules and geometries straight down to the active pipeline vertex drawing queue...
void arrange(const Rect< float > &rect) override
Computes and maps specific layout regions for all children.
A container widget that arranges child nodes into sequential layout distributions.
Definition panel.h:18
void setLayout(UILayoutDirection direction)
Sets the layout axis direction along which children are sequentially stacked.
void setPadding(UIPadding padding)
Space added inside the panel border on all four sides.
void setGap(float gap)
Gap inserted between consecutive children (pixels). Default: 8.
Generic axis-aligned rectangle defined by a position and size.
Definition types.h:87
Represents the boundary budget passed down the node tree during layout allocation.
Definition ui-types.h:76
Defines the internal spacing boundaries (in pixels) for UI layout containers.
Definition ui-types.h:50