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

Noninteractive horizontal determinate gauge with widget-owned fill text. Paint has no owning allocation or polling; text remains alive until the enclosing frame ends. Value mutations are UI-only and use checked tree operations or existing onPrepare callbacks. Manual style defaults are construction-only; dynamic styling uses the existing style resolver. More...

#include <primitives.hpp>

Inheritance diagram for portals::Gauge:
portals::Gaugeportals::Gauge portals::SizedWidget portals::Widget portals::LayoutItem

Public Member Functions

 Gauge (double value, WidthPolicy width={}, GaugeOptions options={}, ControlStyle style={}, SizePolicy policy=DEFAULT_CONTENT_POLICY)
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
double value () const noexcept
std::expected< void, TreeError > display (double value)
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 (double value, GaugeOptions options)

Friends

std::expected< void, TreeError > setGaugeValue (WidgetTree &tree, Node< Gauge > node, double value)
std::expected< void, TreeError > adjustGaugeValue (WidgetTree &tree, Node< Gauge > node, double delta)
std::expected< void, TreeError > syncGauge (WidgetTree &tree, Node< Gauge > node)

Detailed Description

Noninteractive horizontal determinate gauge with widget-owned fill text. Paint has no owning allocation or polling; text remains alive until the enclosing frame ends. Value mutations are UI-only and use checked tree operations or existing onPrepare callbacks. Manual style defaults are construction-only; dynamic styling uses the existing style resolver.

Constructor & Destructor Documentation

◆ Gauge()

portals::Gauge::Gauge ( double value,
WidthPolicy width = {},
GaugeOptions options = {},
ControlStyle style = {},
SizePolicy policy = DEFAULT_CONTENT_POLICY )
explicit
Parameters
valueInitial finite value in the inclusive configured range; measure validates it.
widthComplete owning text policy, shared with the receiving frame.
optionsOwning bounds, preferred width, glyph mode and finite paint cap.
styleConstruction-only owning manual defaults beneath theme declarations.
policyOwning layout constraints, checked by the existing solver. Construction may allocate or throw for an invalid width policy; tree emplacement translates exceptions.

Member Function Documentation

◆ arrange()

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

Reimplemented from portals::Widget.

◆ display()

std::expected< void, TreeError > portals::Gauge::display ( double value)
Parameters
valueFinite replacement in the inclusive range; equal values are a no-op.
Returns
Success, or INVALID_ARGUMENT without mutation. This snapshot helper does not invalidate; use setGaugeValue between frames, or call display from an already dirty onPrepare callback.

◆ measure()

std::expected< CellSize, TreeError > portals::Gauge::measure ( CellSize available)
overridevirtual
Parameters
availableOffered extent; intrinsic width comes from GaugeOptions.
Returns
Preferred width and height one, or INVALID_ARGUMENT for invalid value/settings.

Reimplemented from portals::Widget.

◆ paint()

std::expected< void, TreeError > portals::Gauge::paint ( PaintContext & context)
overridevirtual
Parameters
contextSynchronous sink borrowing widget-owned glyph text through this frame.
Returns
Success, INVALID_ARGUMENT, WOULD_BLOCK above the allocated-area cap before submit, or unchanged sink error. Sink exceptions propagate to the existing WidgetTree::paint boundary; discard a failed frame.

Reimplemented from portals::Widget.

◆ styleDefaults()

ComputedStyle portals::Gauge::styleDefaults ( ) const
overridevirtual
Returns
Owning manual appearances beneath the existing style resolver.

Reimplemented from portals::Widget.

◆ validate()

std::expected< void, TreeError > portals::Gauge::validate ( double value,
GaugeOptions options )
static
Parameters
valueFinite value checked against the owning settings.
optionsFinite bounds with a representable positive span, nonnegative width and positive paint cap.
Returns
Success, or INVALID_ARGUMENT for NaN/infinity, invalid mode, bounds, cap or out-of-range value.

◆ value()

double portals::Gauge::value ( ) const
noexcept
Returns
Current finite presentation value; borrow the widget only inside a checked tree callback.

◆ adjustGaugeValue

std::expected< void, TreeError > adjustGaugeValue ( WidgetTree & tree,
Node< Gauge > node,
double delta )
friend
Parameters
treeBorrowed UI owner; mutation is allowed only between frames.
nodeLive gauge belonging to tree.
deltaFinite amount added to the current value without clamping.
Returns
Checked boundary/value error, or success. Nonfinite/out-of-range results preserve state; unchanged results request no redraw, other changes invalidate PAINT before publication.

◆ setGaugeValue

std::expected< void, TreeError > setGaugeValue ( WidgetTree & tree,
Node< Gauge > node,
double value )
friend
Parameters
treeBorrowed UI owner; mutation is allowed only between frames.
nodeLive gauge belonging to tree.
valueFinite replacement in the inclusive configured range.
Returns
Checked boundary/value error, or success; equal values request no redraw, other changes invalidate PAINT.

◆ syncGauge

std::expected< void, TreeError > syncGauge ( WidgetTree & tree,
Node< Gauge > node )
friend
Parameters
treeBorrowed UI owner, between frames.
nodeLive gauge whose own and ancestor input eligibility is copied for disabled presentation.
Returns
Tree boundary error or success; unchanged eligibility requests no redraw.

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