Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::VirtualTable< T > Class Template Reference

One UI-owned table with bounded owning cell text and one independent model consumer. Construct with a consumer of the frame's model. Each column owns captures and returns owning text; each formatter runs only during preparation and must not perform I/O, mutate models/tree, or retain row borrows. Preparation is transactional on allocation/delegate failure. The retained frame and text survive through render inside WidgetTree::frame. No row widgets, worker, hidden pin or terminal I/O exist. Use tree-checked free mutations; read getters through tree.read. Destroy on the UI owner. More...

#include <virtual_table.hpp>

Inheritance diagram for portals::VirtualTable< T >:
portals::VirtualTable< T >portals::VirtualTable< T > portals::SizedWidget portals::Widget portals::LayoutItem

Public Member Functions

 VirtualTable (ModelConsumer< T > consumer, std::span< const TableColumn< std::type_identity_t< T > > > columns, VirtualTableOptions options={}, SizePolicy policy=DEFAULT_VIEWPORT_POLICY)
 Own consumer, columns and options; validation happens on preparation.
 ~VirtualTable () override
 Cancel work; worker ownership may outlive this view.
std::uint64_t firstRow () const noexcept
 Integral scroll position, clamped at preparation.
ScrollState scrollState () const noexcept
std::optional< RowId > anchorRow () const noexcept
std::optional< RowId > selection () const noexcept
 Stable identity, retained across model revisions and hidden views.
RowRange visibleRange () const noexcept
 Last successfully prepared visible rows.
RowRange preparedRange () const noexcept
 Last successfully prepared viewport plus overscan.
RangeState rangeState () const noexcept
 Last prepared model readiness; error text is owned by its retained model range.
std::expected< VisibleModelSnapshot< T >, VisibleModelReadError > visibleSnapshot (const NodeGeometry &geometry) const
 Capture prepared ready body rows intersecting final arranged geometry.
DataRangeStatus dataStatus () const noexcept
std::expected< CellSize, TreeError > measure (CellSize available) override
 Viewport-sized intrinsic extent, independent of logical row count.
std::expected< void, TreeError > arrange (CellRect local) override
 Remember local bounds without reading/loading/formatting rows.
std::expected< void, TreeError > paint (PaintContext &context) override
 Emit widget-local commands; caller applies surface translation and ancestor clip.
ComputedStyle styleDefaults () const override
Public Member Functions inherited from portals::SizedWidget
 SizedWidget (SizePolicy policy={})
 Own the supplied policies; checked by layout.
SizePolicy sizePolicy () const override
 Copy current policy without borrowing storage.
Public Member Functions inherited from portals::Widget
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 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
Public Member Functions inherited from portals::LayoutItem
virtual ~LayoutItem ()=default
 Destroy with the implementing widget.

Friends

class ManagedScene

Detailed Description

template<class T>
class portals::VirtualTable< T >

One UI-owned table with bounded owning cell text and one independent model consumer. Construct with a consumer of the frame's model. Each column owns captures and returns owning text; each formatter runs only during preparation and must not perform I/O, mutate models/tree, or retain row borrows. Preparation is transactional on allocation/delegate failure. The retained frame and text survive through render inside WidgetTree::frame. No row widgets, worker, hidden pin or terminal I/O exist. Use tree-checked free mutations; read getters through tree.read. Destroy on the UI owner.

Template Parameters
TDomain value exposed by ModelRow<T>. It need not be copyable/default-constructible; this view only borrows const rows during its column formatters. The provider must publish immutable transitively owned values and stable nonzero RowId pairs. The copyable formatters own captures, return GraphemeText with options.width_policy, and may throw; preparation reports those failures.

Constructor & Destructor Documentation

◆ VirtualTable()

template<class T>
portals::VirtualTable< T >::VirtualTable ( ModelConsumer< T > consumer,
std::span< const TableColumn< std::type_identity_t< T > > > columns,
VirtualTableOptions options = {},
SizePolicy policy = DEFAULT_VIEWPORT_POLICY )
inline

Own consumer, columns and options; validation happens on preparation.

Parameters
consumerIndependent move-only range slot, normally obtained from Model<T>::openRange().
columnsBorrowed definitions copied into owned storage during this call; IDs must be unique and widths positive.
optionsOwning height, overscan, width-policy and styles.
policyOwning layout constraints inherited by SizedWidget.
Note
Construct through WidgetTree::emplace on UI; allocation/capture failures follow its errors.

Member Function Documentation

◆ anchorRow()

template<class T>
std::optional< RowId > portals::VirtualTable< T >::anchorRow ( ) const
inlinenoexcept
Returns
First ready visible row identity retained across hidden periods, or no established anchor.

◆ arrange()

template<class T>
std::expected< void, TreeError > portals::VirtualTable< T >::arrange ( CellRect local)
inlineoverridevirtual

Remember local bounds without reading/loading/formatting rows.

Parameters
localOwning parent-local rectangle supplied by layoutTree inside the frame.
Returns
Success after storing the local size; does not prepare rows or invalidate the tree.

Reimplemented from portals::Widget.

◆ dataStatus()

template<class T>
DataRangeStatus portals::VirtualTable< T >::dataStatus ( ) const
inlinenoexcept
Returns
Owning facts of this successful preparation, without reading or pinning the model. Call through tree.read on UI. Hidden/unprepared views return prepared=false.

◆ firstRow()

template<class T>
std::uint64_t portals::VirtualTable< T >::firstRow ( ) const
inlinenoexcept

Integral scroll position, clamped at preparation.

Returns
Integral intended scroll position, clamped at the last successful preparation.

◆ measure()

template<class T>
std::expected< CellSize, TreeError > portals::VirtualTable< T >::measure ( CellSize available)
inlineoverridevirtual

Viewport-sized intrinsic extent, independent of logical row count.

Parameters
availableBorrowed-by-value cell bounds; negative extents normalize to zero.
Returns
Normalized available extent without model access, formatting, allocation or invalidation.

Reimplemented from portals::Widget.

◆ paint()

template<class T>
std::expected< void, TreeError > portals::VirtualTable< T >::paint ( PaintContext & context)
inlineoverridevirtual

Emit widget-local commands; caller applies surface translation and ancestor clip.

Parameters
contextSynchronous borrowed sink; rendered text must not outlive the enclosing tree.frame.
Returns
Success, WOULD_BLOCK for dirty/unprepared content, INVALID_GEOMETRY after resize, or the sink error. Caller must discard partial commands on error.
Note
UI frame only; no I/O, model reads, delegate calls or invalidation.

Reimplemented from portals::Widget.

◆ preparedRange()

template<class T>
RowRange portals::VirtualTable< T >::preparedRange ( ) const
inlinenoexcept

Last successfully prepared viewport plus overscan.

Returns
Owning viewport-plus-overscan interval; hidden/unprepared tables return an empty interval.

◆ rangeState()

template<class T>
RangeState portals::VirtualTable< T >::rangeState ( ) const
inlinenoexcept

Last prepared model readiness; error text is owned by its retained model range.

Returns
Last prepared ready/pending/error state; an unprepared/hidden table reports pending.

◆ scrollState()

template<class T>
ScrollState portals::VirtualTable< T >::scrollState ( ) const
inlinenoexcept
Returns
Owning logical/raster scroll position; reads require the UI owner's tree.read.

◆ selection()

template<class T>
std::optional< RowId > portals::VirtualTable< T >::selection ( ) const
inlinenoexcept

Stable identity, retained across model revisions and hidden views.

Returns
Owning stable ID, including an offscreen/removed ID, or nullopt when cleared.

◆ styleDefaults()

template<class T>
ComputedStyle portals::VirtualTable< T >::styleDefaults ( ) const
inlineoverridevirtual
Returns
Owning manual row and header appearances beneath theme declarations.

Reimplemented from portals::Widget.

◆ visibleRange()

template<class T>
RowRange portals::VirtualTable< T >::visibleRange ( ) const
inlinenoexcept

Last successfully prepared visible rows.

Returns
Owning interval of the last prepared visible rows, or an empty interval before preparation.

◆ visibleSnapshot()

template<class T>
std::expected< VisibleModelSnapshot< T >, VisibleModelReadError > portals::VirtualTable< T >::visibleSnapshot ( const NodeGeometry & geometry) const
inline

Capture prepared ready body rows intersecting final arranged geometry.

Parameters
geometryCurrent published geometry from the table's UI owner; never inferred or laid out here.
Returns
Owning ready values, NOT_PREPARED after invalidation, or explicit provider readiness/error.
Note
Call through the owning tree's read boundary on UI. Includes each partially clipped row once. No provider call, formatting, domain copy or overscan traversal occurs. Error text copying may throw.

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