6#include <portals/widget.hpp>
26 std::int32_t
maximum{std::numeric_limits<std::int32_t>::max()};
100 std::int32_t weight_;
160 virtual std::expected<CellSize, TreeError>
measureChildren(std::span<const MeasuredChild> children)
const = 0;
214 std::expected<CellSize, TreeError>
measureChildren(std::span<const MeasuredChild> children)
const override;
An owning, invariant-preserving half-open cell rectangle.
Definition geometry.hpp:81
Column(LinearOptions options={}, SizePolicy policy={})
Own settings and policies.
Optional const sizing interface, read only within tree.read.
Definition layout.hpp:57
virtual SizePolicy sizePolicy() const =0
Return an owning policy; no tree/model mutation or I/O.
virtual ~LayoutItem()=default
Destroy with the implementing widget.
Pure container interface; callbacks run inside tree.read and an enclosing tree.frame....
Definition layout.hpp:130
virtual std::expected< CellSize, TreeError > childAvailable(CellSize available) const =0
Measurement bounds.
virtual std::expected< std::vector< CellRect >, TreeError > arrangeChildren(std::span< const MeasuredChild > children, CellSize available) const =0
Own parent-local rectangles in child order.
virtual std::expected< CellSize, TreeError > measureChildren(std::span< const MeasuredChild > children) const =0
Own aggregate.
virtual std::expected< LayoutChildPolicy, TreeError > childLayoutFor(NodeId child, CellSize available) const
Describe one child's clip and reveal policy after arrangeChildren.
virtual ~Layout()=default
Destroy with the implementing widget.
virtual std::expected< CellRect, TreeError > childClip(CellSize available) const
Clip descendants within this container without changing allocation.
std::expected< CellSize, TreeError > childAvailable(CellSize available) const override
Checked inset extent.
bool horizontal() const
Definition layout.hpp:231
LinearOptions options() const
Owning copy; no invalidation.
std::expected< std::vector< CellRect >, TreeError > arrangeChildren(std::span< const MeasuredChild > children, CellSize available) const override
Deterministic bounded solve.
LinearLayout(bool horizontal, LinearOptions options, SizePolicy policy)
Initialize axis and owning settings.
std::expected< CellSize, TreeError > measureChildren(std::span< const MeasuredChild > children) const override
Checked sum/max.
friend std::expected< void, TreeError > setLinearOptions(WidgetTree &, Node< LinearLayout >, LinearOptions)
Validate, edit and invalidate layout between frames on the tree's UI owner; tree errors propagate.
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
Row(LinearOptions options={}, SizePolicy policy={})
Own settings and policies.
Spacer(std::int32_t weight=1)
Definition layout.hpp:91
std::int32_t weight() const
Definition layout.hpp:95
std::int32_t cells() const
Definition layout.hpp:111
Spacing(std::int32_t cells)
Definition layout.hpp:107
Public Portals API.
Definition action.hpp:8
std::expected< void, TreeError > layoutTree(WidgetTree &tree, Node< Widget > node, CellRect local, CellRect viewport)
Measure and arrange a subtree inside an active tree frame.
constexpr SizePolicy DEFAULT_EDITOR_POLICY
Single-line editors retain one cell even during shortage; text length is not a flex basis.
Definition layout.hpp:50
SizeMode
Independent axis allocation policy, in integer terminal cells.
Definition layout.hpp:12
@ AUTOMATIC
Use the preferred/intrinsic extent; shrink towards minimum when space is scarce.
Definition layout.hpp:13
@ CONTENT
Prefer intrinsic size, shrink towards minimum, and never grow to consume spare cells.
Definition layout.hpp:16
@ FIXED
Keep the bounded preferred/intrinsic extent even when it overflows the available space.
Definition layout.hpp:14
@ FLEX
Share spare main-axis cells by weight; allow shrinking towards minimum.
Definition layout.hpp:15
std::expected< void, TreeError > setSizePolicy(WidgetTree &tree, Node< SizedWidget > node, SizePolicy policy)
Validate and edit policies between frames on the tree's UI owner; tree errors propagate....
constexpr SizePolicy DEFAULT_CONTENT_POLICY
Intrinsic content on both axes; explicit policies remain authoritative.
Definition layout.hpp:44
constexpr SizePolicy DEFAULT_VIEWPORT_POLICY
A bounded data viewport fills both axes without requesting the whole model extent.
Definition layout.hpp:53
constexpr std::int32_t INTRINSIC_EXTENT
Sentinel requesting the widget's intrinsic measurement.
Definition layout.hpp:20
std::expected< void, TreeError > setLinearOptions(WidgetTree &tree, Node< LinearLayout > node, LinearOptions options)
Validate, edit and invalidate layout between frames on the tree's UI owner; tree errors propagate.
LayoutOverflow
Minimum/fixed sizes survive shortage and are clipped by ancestor geometry.
Definition layout.hpp:180
@ CLIP
Preserve hard minima and fixed extents; clip content that does not fit the viewport.
Definition layout.hpp:181
LayoutAlign
Alignment; center assigns floor(free/2) before the child/group.
Definition layout.hpp:172
@ STRETCH
Fill available cross-axis space within size bounds; acts as START on the linear main axis.
Definition layout.hpp:176
@ START
Place at the leading edge of the available space.
Definition layout.hpp:173
@ CENTER
Center in the usable viewport, rounding down.
Definition dialog.hpp:22
constexpr SizePolicy DEFAULT_FLEX_WIDTH_POLICY
Fill available width from a zero flex basis while retaining content height.
Definition layout.hpp:47
@ START
Immediately after the leading corner.
Definition dialog.hpp:35
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26
Owning per-axis bounds; preferred=-1 or CONTENT uses intrinsic measurement.
Definition layout.hpp:23
std::int32_t minimum
Nonnegative hard minimum.
Definition layout.hpp:24
SizeMode mode
Fixed does not shrink; flex shares spare cells.
Definition layout.hpp:27
constexpr bool operator==(const AxisSize &other) const =default
std::uint32_t weight
Positive flex weight.
Definition layout.hpp:28
std::int32_t maximum
Inclusive cap.
Definition layout.hpp:26
std::int32_t preferred
Intrinsic when -1, otherwise requested size.
Definition layout.hpp:25
An owning available extent in terminal columns/rows.
Definition geometry.hpp:44
Owning nonnegative padding in terminal cells.
Definition layout.hpp:185
std::int32_t bottom
Trailing rows.
Definition layout.hpp:189
std::int32_t left
Leading columns.
Definition layout.hpp:186
std::int32_t right
Trailing columns.
Definition layout.hpp:188
std::int32_t top
Leading rows.
Definition layout.hpp:187
Owning linear container options.
Definition layout.hpp:193
LayoutPadding padding
Insets, retained during shortage.
Definition layout.hpp:195
std::int32_t gap
Cells between visible children only.
Definition layout.hpp:194
LayoutAlign cross_align
Child alignment across the linear direction.
Definition layout.hpp:197
LayoutAlign main_align
Group alignment after allocation; stretch is start on this axis.
Definition layout.hpp:196
LayoutOverflow overflow
Explicit shortage policy.
Definition layout.hpp:198
Owning child input for a pure layout computation.
Definition layout.hpp:120
CellSize desired
Intrinsic or aggregated nonnegative measurement.
Definition layout.hpp:121
SizePolicy policy
Copied policies; no widget references.
Definition layout.hpp:122
NodeId node
Stable owning identity, including when siblings are hidden.
Definition layout.hpp:123
Owning identity, independent of addresses; zero is never a live identity.
Definition widget_types.hpp:15
Owning independent policies for width and height.
Definition layout.hpp:35
AxisSize width
Horizontal policy.
Definition layout.hpp:36
constexpr bool operator==(const SizePolicy &other) const =default
AxisSize height
Vertical policy.
Definition layout.hpp:37