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

UI-owned retained plot of a bounded immutable model range. Accessors run only in prepareChart, never paint/measure. They must not retain row borrows, mutate the model/tree, block or perform I/O. Projected OHLC values are presentation data; provider ownership is retained and the business model is never copied by the view. More...

#include <chart.hpp>

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

Public Member Functions

 Chart (ModelConsumer< T > consumer, std::function< std::optional< Ohlc >(const T &)> accessor, ChartOptions options={}, SizePolicy policy=DEFAULT_VIEWPORT_POLICY)
 Own one range consumer and the typed projection.
 ~Chart () override
 Cancel outstanding work on UI without waiting.
RangeState rangeState () const noexcept
std::uint64_t dataRevision () const noexcept
RowRange visibleRange () const noexcept
std::expected< CellSize, TreeError > measure (CellSize available) override
std::expected< void, TreeError > arrange (CellRect local) override
std::expected< void, TreeError > paint (PaintContext &context) override
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

template<class U>
std::expected< std::optional< ModelRequest< U > >, TreeError > prepareChart (WidgetTree &, Node< Chart< U > >, const ModelFrame< U > &, CellSize, std::uint64_t)

Detailed Description

template<class T>
class portals::Chart< T >

UI-owned retained plot of a bounded immutable model range. Accessors run only in prepareChart, never paint/measure. They must not retain row borrows, mutate the model/tree, block or perform I/O. Projected OHLC values are presentation data; provider ownership is retained and the business model is never copied by the view.

Template Parameters
TImmutable domain record type; the same provider may serve VirtualTable<T>.

Constructor & Destructor Documentation

◆ Chart()

template<class T>
portals::Chart< T >::Chart ( ModelConsumer< T > consumer,
std::function< std::optional< Ohlc >(const T &)> accessor,
ChartOptions options = {},
SizePolicy policy = DEFAULT_VIEWPORT_POLICY )
inline

Own one range consumer and the typed projection.

Parameters
consumerSame-model UI-owned consumer transferred into the chart.
accessorOwning callable returning an OHLC value, or nullopt to break the line.
optionsOwning mode, scale and paint settings; invalid values fail preparation.
policyOwning viewport constraints; explicit policies retain their modes and bounds.

Member Function Documentation

◆ arrange()

template<class T>
std::expected< void, TreeError > portals::Chart< T >::arrange ( CellRect local)
inlineoverridevirtual
Parameters
localParent-relative bounds, borrowed by value.
Returns
Success after recording size; does not read the provider.

Reimplemented from portals::Widget.

◆ dataRevision()

template<class T>
std::uint64_t portals::Chart< T >::dataRevision ( ) const
inlinenoexcept
Returns
Retained provider revision, or zero before preparation.

◆ measure()

template<class T>
std::expected< CellSize, TreeError > portals::Chart< T >::measure ( CellSize available)
inlineoverridevirtual
Parameters
availableAvailable cell extent; negatives normalize to zero.
Returns
Normalized extent without model access or allocation.

Reimplemented from portals::Widget.

◆ paint()

template<class T>
std::expected< void, TreeError > portals::Chart< T >::paint ( PaintContext & context)
inlineoverridevirtual
Parameters
contextSynchronous sink; command text borrows survive through the tree frame.
Returns
WOULD_BLOCK before preparation, INVALID_GEOMETRY after resize, or renderer/sink result. No model access, delegate calls, allocation, I/O or invalidation; discard commands on error.

Reimplemented from portals::Widget.

◆ rangeState()

template<class T>
RangeState portals::Chart< T >::rangeState ( ) const
inlinenoexcept
Returns
Last prepared provider readiness, or PENDING before preparation.

◆ styleDefaults()

template<class T>
ComputedStyle portals::Chart< T >::styleDefaults ( ) const
inlineoverridevirtual
Returns
Manual plot appearance beneath stylesheet declarations; series colors remain independent.

Reimplemented from portals::Widget.

◆ visibleRange()

template<class T>
RowRange portals::Chart< T >::visibleRange ( ) const
inlinenoexcept
Returns
Last prepared bounded domain interval, or empty before preparation.

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