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

Copyable weak UI-affine semantic handle; the scene owns all queue, action and timer storage. Construction may allocate. A cold/closed handle returns CLOSED; a removed original center returns STALE_NODE and never retargets a replacement. Commands report once through the existing collector. Checked adoption preserves prior state while its owner and services remain live. Independent removal, host shutdown or the existing diagnostic STOP policy can cancel registrations; commands never revive stopped services. A later presentation failure retains admitted data and follows the existing STOP policy. More...

#include <toast.hpp>

Public Member Functions

 NotificationCenter ()
 Construct an unpublished observing handle on the UI thread; may allocate.
std::expected< ToastPostReceipt, ManagedError > post (const ToastMessage &message, std::source_location origin=std::source_location::current()) const
DialogCommandResult show (const ToastMessage &message, std::source_location origin=std::source_location::current()) const
DialogCommandResult show (const TextValue &text, std::source_location origin=std::source_location::current()) const
DialogCommandResult show (std::string_view text, std::source_location origin=std::source_location::current()) const
DialogCommandResult dismiss (ToastId id, std::source_location origin=std::source_location::current()) const
DialogCommandResult dismissLatest (std::source_location origin=std::source_location::current()) const
DialogCommandResult activate (ToastId id, std::source_location origin=std::source_location::current()) const
DialogCommandResult activateLatest (std::source_location origin=std::source_location::current()) const
DialogCommandResult clear (std::source_location origin=std::source_location::current()) const
DialogCommandResult setVisible (bool visible, std::source_location origin=std::source_location::current()) const
DialogCommandResult setReducedMotion (bool reduced, std::source_location origin=std::source_location::current()) const
std::expected< std::shared_ptr< const NotificationSnapshot >, ManagedError > snapshot () const

Friends

struct detail::NotificationAccess

Detailed Description

Copyable weak UI-affine semantic handle; the scene owns all queue, action and timer storage. Construction may allocate. A cold/closed handle returns CLOSED; a removed original center returns STALE_NODE and never retargets a replacement. Commands report once through the existing collector. Checked adoption preserves prior state while its owner and services remain live. Independent removal, host shutdown or the existing diagnostic STOP policy can cancel registrations; commands never revive stopped services. A later presentation failure retains admitted data and follows the existing STOP policy.

Member Function Documentation

◆ activate()

DialogCommandResult portals::ui::NotificationCenter::activate ( ToastId id,
std::source_location origin = std::source_location::current() ) const
Parameters
idOriginal action identity.
originPublic call site.
Returns
Checked once-only admission; no automatic retry.

◆ activateLatest()

DialogCommandResult portals::ui::NotificationCenter::activateLatest ( std::source_location origin = std::source_location::current()) const
Parameters
originPublic call site.
Returns
Success, including no eligible action.

◆ clear()

DialogCommandResult portals::ui::NotificationCenter::clear ( std::source_location origin = std::source_location::current()) const
Parameters
originPublic call site.
Returns
Checked clear without semantic callbacks.

◆ dismiss()

DialogCommandResult portals::ui::NotificationCenter::dismiss ( ToastId id,
std::source_location origin = std::source_location::current() ) const
Parameters
idOriginal identity; foreign centers return WRONG_SESSION.
originPublic call site.
Returns
Checked removal.

◆ dismissLatest()

DialogCommandResult portals::ui::NotificationCenter::dismissLatest ( std::source_location origin = std::source_location::current()) const
Parameters
originPublic call site.
Returns
Success, including no eligible notification.

◆ post()

std::expected< ToastPostReceipt, ManagedError > portals::ui::NotificationCenter::post ( const ToastMessage & message,
std::source_location origin = std::source_location::current() ) const
Parameters
messageOwning UI request borrowed only during this call; retained data and the callable are copied before adoption.
originPublic call site.
Returns
Exact checked receipt or full error; technical errors are reported once to a surviving collector. Pre-adoption allocation, text, style and timer failures preserve the old queue, identities and timer. Explicit policy drops are successful DROPPED receipts. Direct worker calls return WRONG_THREAD.

◆ setReducedMotion()

DialogCommandResult portals::ui::NotificationCenter::setReducedMotion ( bool reduced,
std::source_location origin = std::source_location::current() ) const
Parameters
reducedDisable effects while retaining static content.
originPublic call site.
Returns
Checked change or equal no-op.

◆ setVisible()

DialogCommandResult portals::ui::NotificationCenter::setVisible ( bool visible,
std::source_location origin = std::source_location::current() ) const
Parameters
visibleExplicit center visibility; hide cancels timers immediately.
originPublic call site.
Returns
Checked change or equal no-op.

◆ show() [1/3]

DialogCommandResult portals::ui::NotificationCenter::show ( const TextValue & text,
std::source_location origin = std::source_location::current() ) const
Parameters
textOwning expression.
originPublic call site.
Returns
Checked short result.

◆ show() [2/3]

DialogCommandResult portals::ui::NotificationCenter::show ( const ToastMessage & message,
std::source_location origin = std::source_location::current() ) const
Parameters
messageOwning request borrowed for synchronous adoption.
originPublic call site.
Returns
Checked short result, discarding the policy receipt; ignored DROPPED is intentionally silent.

◆ show() [3/3]

DialogCommandResult portals::ui::NotificationCenter::show ( std::string_view text,
std::source_location origin = std::source_location::current() ) const
Parameters
textBytes copied immediately.
originPublic call site.
Returns
Checked short result.

◆ snapshot()

std::expected< std::shared_ptr< const NotificationSnapshot >, ManagedError > portals::ui::NotificationCenter::snapshot ( ) const
Returns
Independent owning observation or exact error; never reports, lays out or mutates UI.

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