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

Retained indeterminate indicator using the receiving scene's existing scheduler. Construct through ui::spinner or ManagedScene::spinner to enable animation. A standalone tree.emplace remains a valid static presentation. All access is UI-affine through WidgetTree. Paint borrows only widget-owned text until the enclosing frame ends. More...

#include <spinner.hpp>

Inheritance diagram for portals::Spinner:
portals::Spinnerportals::Spinner portals::SizedWidget portals::Widget portals::LayoutItem

Public Member Functions

 Spinner (WidthPolicy width={}, SpinnerOptions options={}, ControlStyle style={}, SizePolicy policy=DEFAULT_CONTENT_POLICY, SpinnerLabelResolver resolver={})
 ~Spinner () override
 Cancel this widget's timer on UI, without retaining the scene.
 Spinner (const Spinner &)=delete
Spinner & operator= (const Spinner &)=delete
std::expected< void, TreeError > preparation () 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
std::size_t frameIndex () const noexcept
SpinnerOptions options () const
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.

Static Public Member Functions

static std::expected< void, TreeError > validate (WidthPolicy width, SpinnerOptions options)

Friends

class ManagedScene
std::expected< void, TreeError > setSpinnerActive (WidgetTree &tree, Node< Spinner > node, bool active)
std::expected< void, TreeError > setSpinner (WidgetTree &tree, Node< Spinner > node, const SpinnerOptions &options, SpinnerLabelResolver resolver={})

Detailed Description

Retained indeterminate indicator using the receiving scene's existing scheduler. Construct through ui::spinner or ManagedScene::spinner to enable animation. A standalone tree.emplace remains a valid static presentation. All access is UI-affine through WidgetTree. Paint borrows only widget-owned text until the enclosing frame ends.

Constructor & Destructor Documentation

◆ Spinner()

portals::Spinner::Spinner ( WidthPolicy width = {},
SpinnerOptions options = {},
ControlStyle style = {},
SizePolicy policy = DEFAULT_CONTENT_POLICY,
SpinnerLabelResolver resolver = {} )
explicit
Parameters
widthComplete receiving text-width policy.
optionsOwning finite sequence, label and animation configuration.
styleManual active/dim appearances beneath computed theme styles.
policyExisting owning layout constraints.
resolverOptional synchronous label localization adapter, used only during construction. Construction may allocate; checked tree emplacement translates allocation failures.

Member Function Documentation

◆ arrange()

std::expected< void, TreeError > portals::Spinner::arrange ( CellRect local)
overridevirtual
Parameters
localParent-local allocation; only its extent is retained.
Returns
Success or INVALID_GEOMETRY.

Reimplemented from portals::Widget.

◆ frameIndex()

std::size_t portals::Spinner::frameIndex ( ) const
noexcept
Returns
Current finite frame index, borrowed only during checked UI access.

◆ measure()

std::expected< CellSize, TreeError > portals::Spinner::measure ( CellSize available)
overridevirtual
Parameters
availableOffered extent; intrinsic width includes one space before a nonempty label.
Returns
Maximum sequence width plus label, one row, or construction/geometry error.

Reimplemented from portals::Widget.

◆ options()

SpinnerOptions portals::Spinner::options ( ) const
Returns
Owning configuration snapshot; copies may allocate.

◆ paint()

std::expected< void, TreeError > portals::Spinner::paint ( PaintContext & context)
overridevirtual
Parameters
contextBorrowed synchronous rendering sink.
Returns
Original sink error, preparation error, or WOULD_BLOCK above allocated-area budget.

Reimplemented from portals::Widget.

◆ preparation()

std::expected< void, TreeError > portals::Spinner::preparation ( ) const
noexcept
Returns
Construction-time typed validation result; no callbacks or allocation.

◆ styleDefaults()

ComputedStyle portals::Spinner::styleDefaults ( ) const
overridevirtual
Returns
Owning manual active/dim defaults beneath theme declarations.

Reimplemented from portals::Widget.

◆ validate()

std::expected< void, TreeError > portals::Spinner::validate ( WidthPolicy width,
SpinnerOptions options )
static
Parameters
widthComplete receiving text-width policy.
optionsOwning sequence/budget settings; label is deliberately not resolved here.
Returns
Success for valid bounded single-row frames, or NO_MEMORY/INVALID_ARGUMENT/NODE_LIMIT.

◆ setSpinner

std::expected< void, TreeError > setSpinner ( WidgetTree & tree,
Node< Spinner > node,
const SpinnerOptions & options,
SpinnerLabelResolver resolver = {} )
friend
Parameters
treeBorrowed receiving UI tree.
nodeChecked live indicator identity.
optionsOwning replacement; all text is staged before replacing state/cancelling the old timer.
resolverOptional synchronous localization adapter, not retained after validation.
Returns
Success, NO_MEMORY, INVALID_ARGUMENT, or original tree error; no partial publication on failure. The next ordinary preparation starts one fresh interval, with frame zero and no elapsed-time catch-up.

◆ setSpinnerActive

std::expected< void, TreeError > setSpinnerActive ( WidgetTree & tree,
Node< Spinner > node,
bool active )
friend
Parameters
treeBorrowed receiving UI tree.
nodeChecked live indicator identity.
activeWhether animation should run after ordinary preparation; stopping cancels its token immediately.
Returns
Checked mutation/invalidation result; retains the bounded current frame and allocates no owning sequence.

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