5#include <portals/ui_layout.hpp>
10std::expected<Node<T>, ManagedError> mountAt(ManagedScene &, Node<Widget>, Description<T> &&, ControlContext);
23std::expected<Node<T>, ManagedError> detail::mountAt(ManagedScene &scene, Node<Widget> mountParent,
27 auto consumed = std::move(description);
28 return std::unexpected(admitted.error());
35 auto consumed = std::move(description);
36 return std::unexpected(detail::controlContextError(installed.error(), scene.root()));
41 for (
const auto name : {
"Border",
"Gauge",
"Spinner"}) {
45 auto consumed = std::move(description);
47 return std::unexpected(detail::controlContextError(installed.error(), scene.root()));
51 for (
const auto name : {
"ScrollArea",
"ScrollBar",
"LogView"}) {
55 auto consumed = std::move(description);
57 return std::unexpected(detail::controlContextError(installed.error(), scene.root()));
60 for (
const auto name : {
"HelpView",
"KeyHints"}) {
63 auto consumed = std::move(description);
64 return std::unexpected(detail::controlContextError(installed.error(), scene.root()));
67 for (
const auto name : {
"VirtualList",
"VirtualTable",
"Chart"}) {
71 auto consumed = std::move(description);
72 return std::unexpected(detail::controlContextError(installed.error(), scene.root()));
76 for (
const auto name : {
"OverlayHost",
"Dialog"}) {
80 auto consumed = std::move(description);
82 return std::unexpected(detail::controlContextError(installed.error(), scene.root()));
88 if (!notificationInstalled) {
89 auto consumed = std::move(description);
91 return std::unexpected(detail::controlContextError(notificationInstalled.error(), scene.root()));
96 if (!selectorInstalled) {
97 auto consumed = std::move(description);
98 return std::unexpected(detail::controlContextError(selectorInstalled.error(), scene.root()));
103 if (!messageInstalled) {
104 auto consumed = std::move(description);
106 return std::unexpected(detail::controlContextError(messageInstalled.error(), scene.root()));
111 if (!dataStateInstalled) {
112 auto consumed = std::move(description);
114 return std::unexpected(detail::controlContextError(dataStateInstalled.error(), scene.root()));
119 auto consumed = std::move(description);
120 return std::unexpected(detail::controlContextError(installed.error(), scene.root()));
125 ? std::expected<ControlContext, ControlContextError>(controls)
126 : controls.prepared();
128 auto consumed = std::move(description);
129 return std::unexpected(detail::controlContextError(prepared.error(), scene.root()));
136 detail::Access::endMount(scene);
142 context.
controls = std::move(*prepared);
143 std::expected<Node<T>, ManagedError> result =
147 Node<OverlayHost> automaticHost;
149 auto needsHost = detail::Access::prepareChoiceHost(description, context.controls);
151 result = std::unexpected(needsHost.error());
152 }
else if (*needsHost) {
154 auto host = scene.emplace<OverlayHost>(mountParent, OverlayHostOptions{}, SizePolicy{fill, fill});
157 result = std::unexpected(host.error());
159 automaticHost = *host;
160 context.root = *host;
164 const auto body = context.mountedOuter != Node<Widget>{} ? context.mountedOuter :
Node<Widget>(*result);
165 auto bound = scene.overlayHost(*host, body);
168 result = std::unexpected(bound.error());
177 for (
auto &finalize : context.finalize) {
178 auto completed = finalize();
180 result = std::unexpected(completed.error());
186 for (
auto node : context.nodes) {
190 result = std::unexpected(
live.error());
196 }
catch (
const std::bad_alloc &) {
202 if (!result && context.root != Node<Widget>{}) {
203 auto removed = scene.remove(context.root);
206 if (
const auto *cause = std::get_if<TreeError>(&removed.error().cause)) {
208 result.error().cleanup = *cause;
215 context.committed =
true;
216 for (
auto &publish : context.publish) {
222}
catch (
const std::bad_alloc &) {
224 auto consumed = std::move(description);
231 return detail::mountAt(scene, scene.root(), std::move(description), std::move(controls));
237template <
class T> std::expected<Node<T>, ManagedError> mount(ManagedScene &scene,
Description<T> &&description) {
Node()=default
Empty observer; checked access fails.
Cheap owning immutable snapshot of named definitions and defaults. Const snapshot reads are concurren...
Definition ui_control_context.hpp:632
Single-use owning construction recipe; no mounted widget ownership.
Definition ui_description.hpp:48
auto live(ManagedScene &scene, const S &description)
Definition style_static.hpp:1703
@ FLEX
Share spare main-axis cells by weight; allow shrinking towards minimum.
Definition layout.hpp:15
@ CLOSED
The owning tree or source is closed.
Definition widget_types.hpp:31
@ CALLBACK_FAILED
A user extension or callback threw.
Definition widget_types.hpp:37
@ STALE_NODE
The observed node or model consumer is absent or retired.
Definition widget_types.hpp:30
@ INVALID_ARGUMENT
An option, enum value or operation argument is invalid.
Definition widget_types.hpp:27
@ NO_MEMORY
Allocation failed inside the operation boundary.
Definition widget_types.hpp:33
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 void beginMount(ManagedScene &scene) noexcept
Definition ui_recipe_access.hpp:523
static std::expected< void, ManagedError > check(ManagedScene &scene, Node< Widget > node)
Verify a created node remains accessible before publishing references.
Definition ui_recipe_access.hpp:1394
static bool defersControlValidation(const Description< T > &description)
Definition ui_description.hpp:3149
static bool needsGridContext(const Description< T > &description)
Definition ui_description.hpp:3086
static std::expected< void, ControlContextError > installFallbackSchema(ControlContext &context) noexcept
static std::expected< void, ControlContextError > installDialogSchema(ControlContext &context, std::string_view name) noexcept
static std::expected< void, ControlContextError > installNotificationSchema(ControlContext &context) noexcept
static std::expected< void, ControlContextError > installDataStateSchema(ControlContext &context) noexcept
static std::expected< void, ControlContextError > installOverlaySchema(ControlContext &context) noexcept
static std::expected< void, ControlContextError > installScrollSchema(ControlContext &context, std::string_view name) noexcept
static bool hasUserConfiguration(const ControlContext &context) noexcept
static std::expected< void, ControlContextError > installThemeCatalogSchema(ControlContext &context, bool recipient=false) noexcept
static std::expected< void, ControlContextError > installPrimitiveSchema(ControlContext &context, std::string_view name) noexcept
static std::expected< void, ControlContextError > installKeyHelpSchema(ControlContext &context, std::string_view name) noexcept
static std::expected< void, ControlContextError > installMessageSchema(ControlContext &context) noexcept
static std::expected< void, ControlContextError > installVirtualViewSchema(ControlContext &context, std::string_view name) noexcept
Stack-owned transaction bookkeeping, discarded after one description mount.
Definition ui_recipe_context.hpp:554
ControlContext controls
Immutable owning defaults for this mount transaction.
Definition ui_recipe_context.hpp:555