Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::Layout Class Referenceabstract

Pure container interface; callbacks run inside tree.read and an enclosing tree.frame. No callback may call tree operations, recurse into layout, mutate models, retain spans, or perform I/O. Independent algorithms for Grid/Overlay can implement this interface without changing Widget. More...

#include <layout.hpp>

Inheritance diagram for portals::Layout:
portals::Layoutportals::Layout portals::Border portals::Dialog portals::Grid portals::LinearLayout portals::Overlay portals::ScrollArea portals::VirtualRows< T > portals::Column portals::Row portals::OverlayHost portals::DocumentView portals::LogView portals::DataStateView portals::FindBar portals::FormField portals::HelpView portals::ComboBox portals::SpinBox portals::StatusBar portals::DropDown

Public Member Functions

virtual ~Layout ()=default
 Destroy with the implementing widget.
virtual std::expected< CellSize, TreeError > childAvailable (CellSize available) const =0
 Measurement bounds.
virtual std::expected< CellRect, TreeError > childClip (CellSize available) const
 Clip descendants within this container without changing allocation.
virtual std::expected< LayoutChildPolicy, TreeError > childLayoutFor (NodeId child, CellSize available) const
 Describe one child's clip and reveal policy after arrangeChildren.
virtual std::expected< CellSize, TreeError > measureChildren (std::span< const MeasuredChild > children) const =0
 Own aggregate.
virtual std::expected< std::vector< CellRect >, TreeError > arrangeChildren (std::span< const MeasuredChild > children, CellSize available) const =0
 Own parent-local rectangles in child order.

Detailed Description

Pure container interface; callbacks run inside tree.read and an enclosing tree.frame. No callback may call tree operations, recurse into layout, mutate models, retain spans, or perform I/O. Independent algorithms for Grid/Overlay can implement this interface without changing Widget.

Member Function Documentation

◆ arrangeChildren()

virtual std::expected< std::vector< CellRect >, TreeError > portals::Layout::arrangeChildren ( std::span< const MeasuredChild > children,
CellSize available ) const
pure virtual

Own parent-local rectangles in child order.

Parameters
childrenBorrowed measured children in the same order as the resulting rectangles.
availableContainer-local extent available for arrangement.
Returns
One parent-local rectangle per child, or validation, arithmetic or allocation failure.

Implemented in portals::Border, portals::Dialog, portals::Grid, portals::LinearLayout, portals::Overlay, portals::OverlayHost, portals::ScrollArea, and portals::VirtualRows< T >.

◆ childAvailable()

virtual std::expected< CellSize, TreeError > portals::Layout::childAvailable ( CellSize available) const
pure virtual

Measurement bounds.

Parameters
availableNormalized cell extent offered to this container.
Returns
Bounds to pass to child measurement, or a validation/arithmetic failure.

Implemented in portals::Border, portals::Dialog, portals::Grid, portals::LinearLayout, portals::Overlay, portals::OverlayHost, portals::ScrollArea, and portals::VirtualRows< T >.

◆ childClip()

virtual std::expected< CellRect, TreeError > portals::Layout::childClip ( CellSize available) const
virtual

Clip descendants within this container without changing allocation.

Parameters
availableAllocated normalized container extent in cells.
Returns
Container-local descendant clip; the default is the complete extent. Overrides must return a clip contained in that extent, or an unchanged typed error. Adding this virtual requires rebuilding consumers; old object-file ABI compatibility is not promised.

Reimplemented in portals::Border, portals::Grid, and portals::ScrollArea.

◆ childLayoutFor()

virtual std::expected< LayoutChildPolicy, TreeError > portals::Layout::childLayoutFor ( NodeId child,
CellSize available ) const
virtual

Describe one child's clip and reveal policy after arrangeChildren.

Parameters
childExact identity of a measured direct child.
availableAllocated normalized parent extent.
Returns
Owning policy; the default forwards the existing virtual childClip. The same pure-callback restrictions apply. No tree operation or input mutation is permitted.

Reimplemented in portals::Grid.

◆ measureChildren()

virtual std::expected< CellSize, TreeError > portals::Layout::measureChildren ( std::span< const MeasuredChild > children) const
pure virtual

Own aggregate.

Parameters
childrenBorrowed visible children in sibling order, including stable identities and copied policies.
Returns
The owning aggregate intrinsic extent, or a layout error.

Implemented in portals::Border, portals::Dialog, portals::DocumentView, portals::Grid, portals::LinearLayout, portals::LogView, portals::Overlay, portals::OverlayHost, portals::ScrollArea, and portals::VirtualRows< T >.


The documentation for this class was generated from the following file: