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

Explicit owning allowlist; builtins include VBox/HBox/Label/LineEdit/FormField/Password/Button/CheckBox/ThreeState. Construction and copying may allocate. Captured services remain explicit borrows and must outlive prepare; registry callbacks are released with the consumed scene recipe. More...

#include <ui_scene_resource.hpp>

Public Member Functions

std::expected< void, SceneResourceErrorCode > popupMenu (std::string_view name, Ref< PopupMenu > reference, std::initializer_list< PopupEntry > entries, PopupMenuOptions options={})
 Bind a named loaded popup to an owning code-defined action tree.
 SceneResourceRegistry ()
 Register the safe builtin recipe adapters without mounting anything.
 ~SceneResourceRegistry ()=default
 Release owning adapters; copying remains fallible instead of a noexcept debug-vector move.
template<class T, class Factory>
requires detail::ResourceFactory<T, Factory>
std::expected< void, SceneResourceErrorCode > add (std::string_view name, Factory factory, bool children=false)
 Register an explicitly typed custom recipe; existing names cannot be replaced.
template<class T, class Factory, class Schema>
requires detail::ResourceFactory<T, Factory> && std::same_as<std::remove_cvref_t<Schema>, std::span<const ControlPropertyDescriptor>>
std::expected< void, SceneResourceErrorCode > add (std::string_view name, Factory factory, Schema &&schema)
 Explicitly bind the existing native MessageBox/Notifications/ThemeSelector/ThemeSelectorCatalog semantic schema to a real code-owned factory.

Friends

struct detail::ResourceAccess

Detailed Description

Explicit owning allowlist; builtins include VBox/HBox/Label/LineEdit/FormField/Password/Button/CheckBox/ThreeState. Construction and copying may allocate. Captured services remain explicit borrows and must outlive prepare; registry callbacks are released with the consumed scene recipe.

Member Function Documentation

◆ add() [1/2]

template<class T, class Factory>
requires detail::ResourceFactory<T, Factory>
std::expected< void, SceneResourceErrorCode > portals::ui::SceneResourceRegistry::add ( std::string_view name,
Factory factory,
bool children = false )
inline

Register an explicitly typed custom recipe; existing names cannot be replaced.

Template Parameters
TPublic Widget subtype returned by the factory, including final types.
FactoryCopyable owning callable accepting owning SceneResourceArguments, returning Description<T> or exactly expected<Description<T>, ManagedError>.
Parameters
nameASCII identifier copied now; case-sensitive and unique, including builtin names.
factoryInvoked once per node at prepare, after complete syntax/schema/id validation. External side effects are not rolled back; exceptions use the existing checked mount boundary. In CONFIGURATION, exact VirtualList/VirtualTable/Chart registrations accept their applicable scalar settings; these are staged after the factory, like common size properties. Models and formatters remain code captures.
childrenWhether this custom type accepts child resource nodes; defaults to a leaf.
Returns
Success, UNKNOWN_TYPE for an invalid name, or DUPLICATE_TYPE for a registered name. Allocation/capture construction before and during registration may throw.

◆ add() [2/2]

template<class T, class Factory, class Schema>
requires detail::ResourceFactory<T, Factory> && std::same_as<std::remove_cvref_t<Schema>, std::span<const ControlPropertyDescriptor>>
std::expected< void, SceneResourceErrorCode > portals::ui::SceneResourceRegistry::add ( std::string_view name,
Factory factory,
Schema && schema )
inline

Explicitly bind the existing native MessageBox/Notifications/ThemeSelector/ThemeSelectorCatalog semantic schema to a real code-owned factory.

Template Parameters
TPublic Widget result type.
FactoryExisting owning resource callable.
SchemaExactly the metadata span returned by controlPropertySchema; deduction preserves old bool calls.
Parameters
nameUnique owning registration name.
factoryActual code-owned native composite recipe producer.
schemaComplete canonical MessageBox, Notifications, ThemeSelector or ThemeSelectorCatalog descriptors, read only during this call and never retained.
Returns
Checked registration, or INVALID_VALUE for empty/foreign/modified metadata. A returned ordinary/wrong native recipe is rejected during prepare. Message dialogs accept one owning custom-body child; other semantic nodes remain leaves.

◆ popupMenu()

std::expected< void, SceneResourceErrorCode > portals::ui::SceneResourceRegistry::popupMenu ( std::string_view name,
Ref< PopupMenu > reference,
std::initializer_list< PopupEntry > entries,
PopupMenuOptions options = {} )
inline

Bind a named loaded popup to an owning code-defined action tree.

Parameters
nameUnique resource type name.
referenceUnified observing popup slot.
entriesOwning finite entries copied now; resources never deserialize ActionRefs.
optionsCode-owned finite budgets and plane caps.
Returns
Registration result; loaded common sizing/classes/visible/enabled remain scalar data.

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