5#include <portals/ui_controls.hpp>
6#include <portals/ui_layout.hpp>
7#include <portals/ui_scene_recipes.hpp>
19template <detail::DescriptionInput Body>
22 auto description = detail::Access::cold<Overlay>(
23 [center = std::move(center), body = std::forward<Body>(body),
24 options](ManagedScene &scene, Node<Widget> parent,
26 auto effective = detail::controlOverlayOptions(*context.controlSettings, {});
28 return std::unexpected(detail::error(parent, effective.error()));
30 auto wrapper = scene.emplace<Overlay>(parent, *effective);
32 return std::unexpected(wrapper.error());
34 if (context.root == Node<Widget>{}) {
35 context.root = *wrapper;
39 return std::unexpected(content.error());
41 auto effectiveOptions = detail::controlNotificationOptions(*context.controlSettings, options);
42 auto bound = detail::Access::notifications(scene, *wrapper, *content, center, effectiveOptions, context);
43 return bound ? wrapper : std::unexpected(bound.error());
58template <detail::DescriptionInput Body>
60 NotificationOptions options = {}) {
61 return notifications(std::move(center), std::forward<Body>(body), std::move(options)).reference(std::move(reference));
75Description<OverlayHost> overlayHost(OverlayHostOptions options, Body &&body, Layers &&...layers) {
77 auto description = detail::Access::cold<OverlayHost>(
78 [options, body = std::forward<Body>(body), layers = std::tuple(std::forward<Layers>(layers)...)](
79 ManagedScene &scene, Node<Widget> parent,
81 const auto effective = detail::controlOverlayHostOptions(*context.controlSettings, options);
82 auto host = scene.emplace<OverlayHost>(parent, effective);
84 return std::unexpected(host.error());
86 if (context.root == Node<Widget>{}) {
91 return std::unexpected(content.error());
93 const auto bodyRoot = context.mountedOuter != Node<Widget>{} ? context.mountedOuter :
Node<Widget>(*content);
94 auto bound = scene.overlayHost(*host, bodyRoot);
96 return std::unexpected(bound.error());
98 auto styled = scene.style(*host, StyleTarget{.type =
"OverlayHost", .classes = {
"overlay-host"}});
100 return std::unexpected(styled.error());
102 std::expected<void, ManagedError> result;
104 [&](
auto &...layer) {
105 [[maybe_unused]]
const auto mount = [&](
auto &recipe) {
109 result = std::unexpected(child.error());
116 return result ? host : std::unexpected(result.error());
133Description<OverlayHost> overlayHost(Body &&body, Layers &&...layers) {
134 return overlayHost(OverlayHostOptions{}, std::forward<Body>(body), std::forward<Layers>(layers)...);
147Description<OverlayHost> overlayHost(
Ref<OverlayHost> reference, Body &&body, Layers &&...layers) {
148 return overlayHost(std::forward<Body>(body), std::forward<Layers>(layers)...).
reference(std::move(reference));
158template <detail::DescriptionInput Body>
160 auto heading = label(std::move(title)).style(StyleTarget{.type =
"Label", .classes = {
"dialog-title"}});
161 auto content = detail::Access::dialogContent(column(std::forward<Body>(body)))
162 .style(StyleTarget{.type =
"Column", .classes = {
"dialog-body"}});
165 detail::Access::cold<Dialog>([options, heading = std::move(heading), content = std::move(content)](
166 ManagedScene &scene, Node<Widget> parent,
168 const auto effective = detail::controlDialogOptions(*context.controlSettings, options);
170 if (context.controlSettings->title) {
171 heading = std::move(heading).settings({.text = *context.controlSettings->title});
173 if (context.controlPrepared) {
180 return std::unexpected(detail::error(parent, valid.error()));
182 auto root = scene.emplace<Dialog>(parent, effective);
184 return std::unexpected(root.error());
186 if (context.root == Node<Widget>{}) {
187 context.root = *root;
189 auto panel = detail::Access::dialogPanel(scene, *root, effective.frame);
191 return std::unexpected(panel.error());
193 context.nodes.push_back(*panel);
194 auto column = scene.emplace<Column>(*panel);
196 return std::unexpected(column.error());
198 context.nodes.push_back(*column);
201 return std::unexpected(titleNode.error());
205 return std::unexpected(mounted.error());
207 auto bound = scene.dialog(*root, *panel, *mounted);
209 return std::unexpected(bound.error());
211 auto styled = scene.style(
212 *root, StyleTarget{.type =
"Dialog",
213 .classes = {
"dialog", effective.mode ==
DialogMode::MODAL ?
"modal" :
"nonmodal"}});
214 return styled ? root : std::unexpected(styled.error());
228template <detail::DescriptionInput Body>
230 return dialog(std::move(title), std::forward<Body>(body), options).reference(std::move(reference));
239template <detail::DescriptionInput Body>
240Description<Dialog> dialog(std::string_view title, Body &&body, DialogOptions options = {}) {
241 return dialog(
TextValue(title), std::forward<Body>(body), options);
251template <detail::DescriptionInput Body>
253 return dialog(std::move(reference),
TextValue(title), std::forward<Body>(body), options);
262template <detail::DescriptionInput Body>
267 detail::MessageAccess::describe(std::move(reference), std::move(title), {},
277template <detail::DescriptionInput Body>
280 return dialog(std::move(reference),
TextValue(title), std::forward<Body>(body), buttons, std::move(options));
288 return detail::MessageAccess::describe(std::move(reference), std::move(title), std::move(body), {},
289 std::move(options), buttons);
297 return dialog(std::move(reference),
TextValue(title),
TextValue(body), buttons, std::move(options));
302Description<Dialog> defaultThemeSelector(ThemeSelectorRef reference, std::span<const ThemeChoice> choices,
303 const ThemeSelectionOptions &selection,
304 const std::optional<std::string> &initialId, ThemeSelectorOptions options);
307template <std::
size_t N>
311 return detail::defaultThemeSelector(std::move(reference), choices,
ThemeSelectionOptions{}, {}, std::move(options));
314template <
class Catalog>
317 return detail::defaultThemeSelector(std::move(reference), catalog.choices, catalog.selection, catalog.initialId,
331 return std::move(description).maxLayers(modifier.
value);
336inline OverlayHostModifier maxLayers(std::size_t value) {
351 (void)std::move(description).title(std::move(*modifier.
patch.
title));
354 return std::move(description).dialogSettings(modifier.
patch.
dialog);
370 (void)std::move(description).body(std::move(*modifier.
patch.
body));
373 (void)std::move(description).messageSettings(std::move(modifier.
patch.
message));
376 return std::move(description);
381inline MessageModifier body(
TextValue value) {
382 return {{.body = std::move(value)},
false};
392 return {{.message = std::move(value)},
true};
397 return {{.title = std::move(value)}};
407 return {{.dialog = {.mode = value}}};
421 return {{.dialog = {.placement = value}}};
426 return {{.dialog = {.maximumPanelSize = {.width = value.width, .height = value.height}}}};
431 return {{.dialog = {.viewportMargin = value}}};
436 return {{.dialog = {.anchorGap = value}}};
441 return {{.dialog = {.closeOnEscape = value}}};
445inline DialogModifier closeButton(DialogCloseOptions options = {}) {
446 return {{.dialog = {.closeButton = {
447 .enabled = options.enabled, .placement = options.placement, .focusable = options.focusable}}}};
452 return {{.dialog = value}};
466 requires(std::same_as<T, HelpView> || std::same_as<T, KeyHints>)
468 (void)std::move(description).format(std::move(modifier.
formatter));
469 if (modifier.
empty) {
470 (void)std::move(description).emptyText(std::move(*modifier.
empty));
473 (void)std::move(description).unavailableText(std::move(*modifier.
unavailable));
475 return std::move(description);
480inline KeyHelpModifier format(ControlKeyFormatSettings values) {
481 return {std::move(values), {}, {}};
486 return {{}, std::move(value), {}};
491 return {{}, {}, std::move(value)};
502 return std::move(description).initiallyOpen(modifier.
value);
507inline HelpOpenModifier initiallyOpen(
bool value =
true) {
523 (void)std::move(description).entrySeparator(std::move(*modifier.
separator));
526 (void)std::move(description).overflowMarker(std::move(*modifier.
overflow));
528 return std::move(description);
533inline KeyHintsModifier entrySeparator(std::string value) {
534 return {std::move(value), {}};
539 return {{}, std::move(value)};
552 return std::move(description).themeCatalogSettings(std::move(modifier.
patch));
559inline ThemeCatalogModifier themeCatalogSettings(ControlThemeCatalogSettings values) {
560 return {std::move(values)};
573 return std::move(description).themeSelectorSettings(std::move(modifier.
patch));
578inline ThemeSelectorModifier themeSelectorSettings(ControlThemeSelectorSettings values) {
579 return {std::move(values)};
590 return std::move(description).notificationSettings(modifier.
patch);
597inline NotificationModifier notificationSettings(ControlNotificationSettings values) {
611 if constexpr (std::same_as<std::remove_cvref_t<Body>, Description<OverlayHost>>) {
612 return std::forward<Body>(body);
614 return overlayHost(std::forward<Body>(body));
620 Access::transaction([hosted = std::move(hosted), layers = std::tuple(std::forward<Layers>(layers)...)](
621 ManagedScene &owner, Node<Widget> parent,
622 MountContext &context)
mutable -> std::expected<Node<Widget>, ManagedError> {
623 auto root =
Access::mount(std::move(hosted), owner, parent, context);
626 return std::unexpected(root.error());
632 return std::unexpected(host.error());
635 std::expected<void, ManagedError> result;
638 [&](
auto &...layer) {
639 const auto mountLayer = [&](
auto &recipe) {
644 auto mounted =
Access::mount(std::move(recipe), owner, *host, context);
646 result = mounted ?
Access::checkLayer(owner, *mounted) : std::unexpected(mounted.error());
649 (mountLayer(layer), ...);
653 return result ? std::expected<Node<Widget>, ManagedError>(*root) : std::unexpected(result.error());
676Scene scene(
SceneOptions options, std::source_location origin, Body &&body, First &&first, Layers &&...layers) {
678 return scene(detail::layered(std::forward<Body>(body), std::forward<First>(first), std::forward<Layers>(layers)...),
682 [factory = std::forward<Body>(body),
683 layers = std::tuple(std::forward<First>(first), std::forward<Layers>(layers)...)](
686 if constexpr (std::invocable<
decltype(factory) &, ManagedScene &>) {
687 return std::invoke(factory, owner);
693 const auto compose = [&](
auto &&content) {
695 [&](
auto &...layer) {
696 return detail::layered(std::move(content), std::move(layer)...);
702 return compose(std::move(recipe));
705 return std::unexpected(recipe.error());
708 return compose(std::move(*recipe));
727Scene scene(
SceneOptions options, Body &&body, First &&first, Layers &&...layers) {
728 return scene(options, std::source_location::current(), std::forward<Body>(body), std::forward<First>(first),
729 std::forward<Layers>(layers)...);
743Scene scene(Body &&body, First &&first, Layers &&...layers) {
744 return scene(
SceneOptions{}, std::source_location::current(), std::forward<Body>(body), std::forward<First>(first),
745 std::forward<Layers>(layers)...);
static std::expected< void, TreeError > validate(DialogOptions options)
Node()=default
Empty observer; checked access fails.
Owning literal bytes or a resource key, measured only at resolution.
Definition text_value.hpp:42
constexpr TextValue(const TextValue &other)=default
Copy expression bytes and kind into independent storage.
Single-use owning construction recipe; no mounted widget ownership.
Definition ui_description.hpp:48
Description && reference(NodeRef< T > reference) &&
Definition ui_description.hpp:1251
Copyable weak UI-affine semantic handle; the scene owns all queue, action and timer storage....
Definition toast.hpp:311
Typed Widget observation; explicit composite specializations reuse their existing weak facades.
Definition ui_ref.hpp:761
Single-use lazy owner of one Application and ManagedScene; no second runtime. Construct and operate o...
Definition ui_scene.hpp:253
Owning catalog input; legacy factories run synchronously once per explicit preview attempt on UI....
Definition theme_selection.hpp:95
Weak UI-affine observation of one scene-owned selector view. Commands are checked only: they never re...
Definition theme_selector.hpp:82
Select the legacy factory signature before considering an Application borrow.
Definition ui_scene_recipes.hpp:43
Admit a declared dialog layer or an erased recipe checked after its existing factory runs.
Definition ui_recipe_context.hpp:82
DialogMode
Input policy applied by the managed dialog owner.
Definition dialog.hpp:15
@ NON_MODAL
Let input outside the panel reach the scene.
Definition dialog.hpp:17
@ MODAL
Confine input to the active modal layer.
Definition dialog.hpp:16
DialogPlacement
Preferred panel position within the owning host.
Definition dialog.hpp:21
Sparse native dialog geometry/input options, merged per leaf.
Definition ui_control_context.hpp:342
Sparse native MessageBox options, preserving captured values and kind-specific checks.
Definition ui_control_context.hpp:252
Sparse immutable notification-center construction options; runtime posts stay code-owned.
Definition ui_control_context.hpp:318
Owning sparse literals only; never contains IDs, models, handlers or live history.
Definition ui_control_context.hpp:391
std::optional< TextValue > body
Owning native MessageBox paragraph expression.
Definition ui_control_context.hpp:454
ControlDialogSettings dialog
Native Dialog-only options, merged per leaf.
Definition ui_control_context.hpp:453
ControlMessageSettings message
Native MessageBox-only sparse options.
Definition ui_control_context.hpp:455
std::optional< TextValue > title
Owning Dialog caption expression; unspecified keeps the actual caption.
Definition ui_control_context.hpp:452
Constructor-only scalars for a real owning default catalog recipe.
Definition ui_control_context.hpp:299
Native ThemeSelector view settings, independent of model/catalog construction.
Definition ui_control_context.hpp:311
Owning exact Dialog stage; no title resolution occurs while staging.
Definition ui_dialogs.hpp:341
ControlSettings patch
Only title and the nine dialog leaves are staged by these helpers.
Definition ui_dialogs.hpp:344
friend Description< Dialog > operator|(Description< Dialog > &&description, DialogModifier modifier)
Definition ui_dialogs.hpp:349
Owning exact HelpView initial-open stage.
Definition ui_dialogs.hpp:495
friend Description< HelpView > operator|(Description< HelpView > &&description, HelpOpenModifier modifier)
Definition ui_dialogs.hpp:501
bool value
Initial open state.
Definition ui_dialogs.hpp:496
Owning sparse native help presentation stage.
Definition ui_dialogs.hpp:456
std::optional< std::string > unavailable
Optional literal unavailable presentation.
Definition ui_dialogs.hpp:459
std::optional< std::string > empty
Optional literal empty presentation.
Definition ui_dialogs.hpp:458
ControlKeyFormatSettings formatter
Sparse owning formatter leaves.
Definition ui_dialogs.hpp:457
Owning exact KeyHints literal strip stage.
Definition ui_dialogs.hpp:512
friend Description< KeyHints > operator|(Description< KeyHints > &&description, KeyHintsModifier modifier)
Definition ui_dialogs.hpp:521
std::optional< std::string > separator
Complete-entry separator.
Definition ui_dialogs.hpp:515
std::optional< std::string > overflow
Nonempty overflow marker.
Definition ui_dialogs.hpp:516
Owning MessageBox-only stage, checked against actual native capability at preparation.
Definition ui_dialogs.hpp:359
bool options
Distinguish an explicit empty message group from a body stage.
Definition ui_dialogs.hpp:363
ControlSettings patch
Owning body and grouped native message options.
Definition ui_dialogs.hpp:362
friend Description< Dialog > operator|(Description< Dialog > &&description, MessageModifier modifier)
Definition ui_dialogs.hpp:368
Immutable settings for a ready-made modal choice dialog.
Definition message_box.hpp:90
Sparse immutable native notification-center construction stage.
Definition ui_dialogs.hpp:583
ControlNotificationSettings patch
Numeric/native enum literals only; no runtime resolver is added.
Definition ui_dialogs.hpp:584
friend Description< Overlay > operator|(Description< Overlay > &&description, NotificationModifier modifier)
Definition ui_dialogs.hpp:589
Exact host stage; does not opt into ordinary Overlay layout modifiers.
Definition ui_dialogs.hpp:324
std::size_t value
Positive layer-registration cap, including hidden layers.
Definition ui_dialogs.hpp:325
friend Description< OverlayHost > operator|(Description< OverlayHost > &&description, OverlayHostModifier modifier)
Definition ui_dialogs.hpp:330
Policies for one lazy facade over the existing managed runtime.
Definition ui_scene.hpp:17
Constructor-only stage for a real owning default-catalog selector.
Definition ui_dialogs.hpp:543
friend Description< Dialog > operator|(Description< Dialog > &&description, ThemeCatalogModifier modifier)
Definition ui_dialogs.hpp:551
ControlThemeCatalogSettings patch
Owning sparse admission and startup inputs.
Definition ui_dialogs.hpp:545
Finite normalization budgets and optional first-preview layer admission.
Definition theme_selection.hpp:77
Advanced owning catalog settings for a selector with its scene-owned default model....
Definition theme_selector.hpp:70
Sparse native ThemeSelector view stage; model/catalog inputs remain code-owned.
Definition ui_dialogs.hpp:564
ControlThemeSelectorSettings patch
Owning captions, limits and optional shortcut.
Definition ui_dialogs.hpp:567
friend Description< Dialog > operator|(Description< Dialog > &&description, ThemeSelectorModifier modifier)
Definition ui_dialogs.hpp:572
Owning selector captions, established dialog settings and optional application delivery.
Definition theme_selector.hpp:44
static Description< Overlay > notificationControl(Description< Overlay > description)
Definition ui_description.hpp:3356
static Description< T > withLayout(Description< T > description, std::shared_ptr< RecipeLayout > layout)
Definition ui_description.hpp:3229
static std::expected< Node< T >, ManagedError > mount(Description< T > &&description, ManagedScene &scene, Node< Widget > parent, MountContext &context)
Mount a root or child inside the same transaction.
Definition ui_description.hpp:3560
static std::expected< Node< OverlayHost >, ManagedError > layerHost(ManagedScene &scene, Node< Widget > root)
static std::shared_ptr< RecipeLayout > captureLayouts(Children &...children)
Definition ui_description.hpp:3202
static void preparedDialogHeading(Description< Label > &description, const TextValue &title)
Definition ui_description.hpp:3302
static std::expected< void, ManagedError > checkLayer(ManagedScene &scene, Node< Widget > node)
static Description< T > configuredControl(Description< T > description, std::string_view type, bool inherit=true)
Attach a builtin configuration identity to an owning recipe.
Definition ui_description.hpp:3409
static Description< Widget > erase(Description< T > description)
Erase only the observer type while preserving one mount transaction.
Definition ui_description.hpp:3534
static Description< Widget > transaction(Factory factory)
Definition ui_description.hpp:3489
Recognize an owning recipe after cv/ref normalization.
Definition ui_recipe_context.hpp:35
Stack-owned transaction bookkeeping, discarded after one description mount.
Definition ui_recipe_context.hpp:554
static Application & application(ManagedScene &owner) noexcept
Definition ui_scene.hpp:1168