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

UI-owned extension object. Hooks borrow their arguments for one call. Models are separate explicit owners chosen by the application. Hooks must not block, perform terminal I/O, or retain contexts. Measure/arrange/paint cannot mutate the tree. More...

#include <widget.hpp>

Inheritance diagram for portals::Widget:
portals::Widgetportals::Widget portals::Dialog portals::SizedWidget portals::Spacer portals::Spacing portals::Border portals::Chart< T > portals::Control portals::Gauge portals::Grid portals::LineEdit portals::LinearLayout portals::Overlay portals::Password portals::RadioGroup portals::ScrollArea portals::ScrollBar portals::Spinner portals::VirtualList< T > portals::VirtualRows< T > portals::VirtualTable< T >

Public Member Functions

virtual ~Widget ()=default
 Destroy on UI after the last active tree borrow.
virtual void mount ()
 Called exactly once after attachment; exceptions are reported.
virtual void unmount ()
 Called once before destruction, children first; cleanup continues on exceptions.
virtual std::expected< CellSize, TreeError > measure (CellSize available)
 Default desired size is empty.
virtual std::expected< void, TreeError > arrange (CellRect local)
 Default accepts the owning rectangle.
virtual std::expected< void, TreeError > paint (PaintContext &context)
 Default emits no commands.
virtual ComputedStyle styleDefaults () const
 Read manual presentation defaults during style staging on UI.
virtual bool styleReadOnly () const noexcept
 Read actual view-only state during style staging; false by default.
const std::shared_ptr< const StyleSnapshot > & computedStyle () const noexcept
 Inspect the last atomically installed theme inside tree.read/frame.
std::uint64_t styleRevision () const noexcept

Friends

class StyleEngine

Detailed Description

UI-owned extension object. Hooks borrow their arguments for one call. Models are separate explicit owners chosen by the application. Hooks must not block, perform terminal I/O, or retain contexts. Measure/arrange/paint cannot mutate the tree.

Member Function Documentation

◆ arrange()

virtual std::expected< void, TreeError > portals::Widget::arrange ( CellRect local)
virtual

Default accepts the owning rectangle.

Parameters
localParent-relative rectangle selected by the layout owner.
Returns
Success by default, or an extension-defined arrangement failure.

Reimplemented in portals::Border, portals::Chart< T >, portals::Control, portals::Gauge, portals::Grid, portals::KeyHints, portals::LineEdit, portals::Menu, portals::Password, portals::PopupMenu, portals::RadioGroup, portals::ScrollArea, portals::ScrollBar, portals::Slider, portals::Spinner, portals::StatusBar, portals::VirtualList< T >, portals::VirtualRows< T >, and portals::VirtualTable< T >.

◆ computedStyle()

const std::shared_ptr< const StyleSnapshot > & portals::Widget::computedStyle ( ) const
noexcept

Inspect the last atomically installed theme inside tree.read/frame.

Returns
Borrowed owning handle, empty before binding. The handle reference and nested borrows expire on the next style publication. Copy the shared pointer to retain the immutable snapshot independently of subsequent publications or widget destruction. Read access never allocates; use StyleSnapshot::flatten for an owning legacy flat value.

◆ measure()

virtual std::expected< CellSize, TreeError > portals::Widget::measure ( CellSize available)
virtual

Default desired size is empty.

Parameters
availableNormalized cell-space constraints supplied by WidgetTree.
Returns
Desired size (empty by default), or an extension-defined measurement failure.

Reimplemented in portals::Border, portals::Button, portals::Chart< T >, portals::Control, portals::Gauge, portals::KeyHints, portals::LineEdit, portals::LogView, portals::Menu, portals::Password, portals::PopupMenu, portals::RadioGroup, portals::ScrollArea, portals::ScrollBar, portals::Slider, portals::SpinBox, portals::Spinner, portals::Switch, portals::VirtualList< T >, and portals::VirtualTable< T >.

◆ paint()

virtual std::expected< void, TreeError > portals::Widget::paint ( PaintContext & context)
virtual

Default emits no commands.

Parameters
contextBorrowed synchronous sink; neither it nor frame text may escape the frame.
Returns
Success after emitting commands (none by default), or a painting/sink failure.

Reimplemented in portals::Border, portals::Button, portals::Chart< T >, portals::Control, portals::DocumentView, portals::Gauge, portals::Grid, portals::KeyHints, portals::LineEdit, portals::LogView, portals::Menu, portals::Password, portals::PopupMenu, portals::RadioGroup, portals::ScrollArea, portals::ScrollBar, portals::Slider, portals::Spinner, portals::StatusBar, portals::VirtualList< T >, portals::VirtualRows< T >, and portals::VirtualTable< T >.

◆ styleDefaults()

virtual ComputedStyle portals::Widget::styleDefaults ( ) const
virtual

Read manual presentation defaults during style staging on UI.

Returns
Owning defaults beneath stylesheet declarations; empty by default.
Note
The engine holds a frame borrow: tree mutation/reentry is rejected. Do not perform I/O, mutate domain state or retain borrows. Exceptions abort the complete style transaction.

Reimplemented in portals::Border, portals::Chart< T >, portals::Control, portals::Gauge, portals::Grid, portals::LineEdit, portals::Password, portals::RadioGroup, portals::ScrollArea, portals::ScrollBar, portals::Spinner, portals::StatusBar, portals::VirtualList< T >, and portals::VirtualTable< T >.

◆ styleReadOnly()

virtual bool portals::Widget::styleReadOnly ( ) const
virtualnoexcept

Read actual view-only state during style staging; false by default.

Returns
Orthogonal read-only selector fact. The engine passes this fact on the stack for bound widgets; standalone resolveStyle accepts an explicit fact argument.
Note
This nonthrowing hook must not mutate state, perform I/O or reenter the tree.

Reimplemented in portals::DocumentView, portals::RadioGroup, and portals::Slider.

◆ styleRevision()

std::uint64_t portals::Widget::styleRevision ( ) const
noexcept
Returns
Last installed engine revision, or zero before binding; UI reads only.

◆ unmount()

virtual void portals::Widget::unmount ( )
virtual

Called once before destruction, children first; cleanup continues on exceptions.

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


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