morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::forms::Ranged< Min, Max, Step > Struct Template Reference

A bounded numeric field edited as a slider. More...

#include <widget_hints.hpp>

Public Member Functions

constexpr Ranged () noexcept=default
 Constructs the empty state.
constexpr Ranged (decltype(Min) selected) noexcept
 Engages with selected.
constexpr Ranged (std::optional< decltype(Min)> payload) noexcept
 Adopts an optional payload as-is.
constexpr bool hasValue () const noexcept
 Whether a value has been entered.
constexpr decltype(Min) operator* () const noexcept
 Unchecked access to the engaged value (UB when empty, exactly like std::optional::operator*).
constexpr bool operator== (const Ranged &other) const =default
 Equality on the payload; empty equals only empty.

Static Public Member Functions

static constexpr auto min () noexcept
 The slider's inclusive lower bound.
static constexpr auto max () noexcept
 The slider's inclusive upper bound.
static constexpr auto step () noexcept
 The slider's track increment.
static constexpr std::string_view widget () noexcept
 The preferred control id for this field.

Public Attributes

std::optional< decltype(Min)> value
 The payload; std::nullopt means "not entered".

Detailed Description

template<auto Min, auto Max, auto Step = 1>
requires (std::is_arithmetic_v<decltype(Min)> && std::same_as<decltype(Min), decltype(Max)> && std::same_as<decltype(Min), decltype(Step)>)
struct morph::forms::Ranged< Min, Max, Step >

A bounded numeric field edited as a slider.

Template Parameters
MinInclusive lower bound of the control track.
MaxInclusive upper bound of the control track (must be > Min).
StepTrack increment (default 1; must be > 0). Must be the same arithmetic type as Min/Max — a floating-point Ranged must name Step explicitly (the default 1 is int).

Definition at line 72 of file widget_hints.hpp.

Constructor & Destructor Documentation

◆ Ranged() [1/2]

template<auto Min, auto Max, auto Step = 1>
morph::forms::Ranged< Min, Max, Step >::Ranged ( decltype(Min) selected)
inlineconstexprnoexcept

Engages with selected.

Parameters
selectedThe selected value.

Definition at line 84 of file widget_hints.hpp.

◆ Ranged() [2/2]

template<auto Min, auto Max, auto Step = 1>
morph::forms::Ranged< Min, Max, Step >::Ranged ( std::optional< decltype(Min)> payload)
inlineconstexprnoexcept

Adopts an optional payload as-is.

Parameters
payloadEngaged or empty payload.

Definition at line 88 of file widget_hints.hpp.

Member Function Documentation

◆ hasValue()

template<auto Min, auto Max, auto Step = 1>
bool morph::forms::Ranged< Min, Max, Step >::hasValue ( ) const
inlinenodiscardconstexprnoexcept

Whether a value has been entered.

Returns
true if the payload is engaged.

Definition at line 92 of file widget_hints.hpp.

◆ operator*()

template<auto Min, auto Max, auto Step = 1>
decltype(Min) morph::forms::Ranged< Min, Max, Step >::operator* ( ) const
inlinenodiscardconstexprnoexcept

Unchecked access to the engaged value (UB when empty, exactly like std::optional::operator*).

Returns
The engaged value.

Definition at line 98 of file widget_hints.hpp.

◆ min()

template<auto Min, auto Max, auto Step = 1>
constexpr auto morph::forms::Ranged< Min, Max, Step >::min ( )
inlinestaticnodiscardconstexprnoexcept

The slider's inclusive lower bound.

Returns
Min.

Definition at line 102 of file widget_hints.hpp.

◆ max()

template<auto Min, auto Max, auto Step = 1>
constexpr auto morph::forms::Ranged< Min, Max, Step >::max ( )
inlinestaticnodiscardconstexprnoexcept

The slider's inclusive upper bound.

Returns
Max.

Definition at line 106 of file widget_hints.hpp.

◆ step()

template<auto Min, auto Max, auto Step = 1>
constexpr auto morph::forms::Ranged< Min, Max, Step >::step ( )
inlinestaticnodiscardconstexprnoexcept

The slider's track increment.

Returns
Step.

Definition at line 110 of file widget_hints.hpp.

◆ widget()

template<auto Min, auto Max, auto Step = 1>
constexpr std::string_view morph::forms::Ranged< Min, Max, Step >::widget ( )
inlinestaticnodiscardconstexprnoexcept

The preferred control id for this field.

Returns
"slider".

Definition at line 114 of file widget_hints.hpp.

◆ operator==()

template<auto Min, auto Max, auto Step = 1>
bool morph::forms::Ranged< Min, Max, Step >::operator== ( const Ranged< Min, Max, Step > & other) const
nodiscardconstexprdefault

Equality on the payload; empty equals only empty.

Parameters
otherRanged to compare against.
Returns
true when both are empty or both hold equal values.

Member Data Documentation

◆ value

template<auto Min, auto Max, auto Step = 1>
std::optional<decltype(Min)> morph::forms::Ranged< Min, Max, Step >::value

The payload; std::nullopt means "not entered".

Definition at line 77 of file widget_hints.hpp.


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