Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
control_context.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/key_hints.hpp>
6#include <portals/managed.hpp>
7#include <portals/ui_control_context.hpp>
8#include <portals/ui_ref.hpp>
9
10#include <bitset>
11
12namespace portals::ui::detail {
13
14inline constexpr std::size_t CONTROL_PROPERTY_COUNT = 285;
15inline constexpr std::size_t CONTROL_PRESENCE_BITS =
16 CONTROL_PROPERTY_COUNT < 32 ? 32 : CONTROL_PROPERTY_COUNT;
17using ControlPropertyPresence = std::bitset<CONTROL_PRESENCE_BITS>;
18
24void mergeRecipeControlSettings(ControlSettings &target, const ControlSettings &patch);
25
29void freezeControlDocumentSettings(ControlSettings &settings);
30
37 static bool hasDeclaredType(const ControlContext &context, std::string_view name) noexcept;
42 static bool hasUserConfiguration(const ControlContext &context) noexcept;
46 static std::string_view canonicalProperty(std::string_view property) noexcept;
50 static std::expected<void, ControlContextError> installFallbackSchema(ControlContext &context) noexcept;
55 static std::expected<void, ControlContextError> installPrimitiveSchema(ControlContext &context,
56 std::string_view name) noexcept;
61 static std::expected<void, ControlContextError> installScrollSchema(ControlContext &context,
62 std::string_view name) noexcept;
66 static std::expected<void, ControlContextError> installOverlaySchema(ControlContext &context) noexcept;
71 static std::expected<void, ControlContextError> installKeyHelpSchema(ControlContext &context,
72 std::string_view name) noexcept;
77 static std::expected<void, ControlContextError> installVirtualViewSchema(ControlContext &context,
78 std::string_view name) noexcept;
82 static std::expected<void, ControlContextError> installDataStateSchema(ControlContext &context) noexcept;
86 static std::expected<void, ControlContextError> installNotificationSchema(ControlContext &context) noexcept;
87
91 static std::expected<void, ControlContextError> installThemeSelectorSchema(ControlContext &context) noexcept;
92
97 static std::expected<void, ControlContextError> installThemeCatalogSchema(ControlContext &context,
98 bool recipient = false) noexcept;
104 static std::expected<void, ControlContextError> themeFamilySchema(ControlContext &context, std::string_view name,
105 ControlFactoryKind kind) noexcept;
106
110 static std::expected<void, ControlContextError> installMessageSchema(ControlContext &context) noexcept;
111
116 static std::expected<void, ControlContextError> installDialogSchema(ControlContext &context,
117 std::string_view name) noexcept;
119 static std::span<const ControlPropertyDescriptor> gridSchema() noexcept;
120};
121
127void applyFluentControlOrigins(ControlSettings &patch, const ControlSettings &previous);
128
132std::uint32_t controlSettingsPresence(const ControlSettings &settings) noexcept;
133
137ControlPropertyPresence controlSettingsPresenceSet(const ControlSettings &settings) noexcept;
138
144LinearOptions controlLinearOptions(const ControlSettings &settings, LinearOptions options) noexcept;
145
150std::expected<OverlayOptions, TreeError> controlOverlayOptions(const ControlSettings &settings,
151 OverlayOptions options) noexcept;
152
158TextLimits controlTextLimits(const ControlSettings &settings, TextLimits limits) noexcept;
159
163LogViewConfig controlLogViewConfig(const ControlSettings &settings, LogViewConfig config) noexcept;
164
170std::expected<std::optional<FrameOptions>, ManagedError>
171controlFrameOptions(const ControlSettings &settings, std::optional<FrameOptions> base, WidthPolicy policy);
172
177BorderOptions controlBorderOptions(const ControlSettings &settings, BorderOptions options) noexcept;
178
183GaugeOptions controlGaugeOptions(const ControlSettings &settings, GaugeOptions options) noexcept;
188SpinnerOptions controlSpinnerOptions(const ControlSettings &settings, SpinnerOptions options);
189
193bool hasScrollbarSettings(const ControlScrollbarSettings &settings) noexcept;
194
199std::expected<ScrollAreaOptions, TreeError> controlScrollAreaOptions(const ControlSettings &settings,
200 ScrollAreaOptions options) noexcept;
201
206std::expected<ScrollBarOptions, TreeError> controlScrollBarOptions(const ControlSettings &settings,
207 ScrollBarOptions options) noexcept;
208
212bool validControlLiteral(std::string_view value) noexcept;
213
218HelpViewOptions controlHelpViewOptions(const ControlSettings &settings, HelpViewOptions options);
219
224KeyHintsOptions controlKeyHintsOptions(const ControlSettings &settings, KeyHintsOptions options);
225
230VirtualListOptions controlVirtualListOptions(const ControlSettings &settings, VirtualListOptions options) noexcept;
231
236VirtualTableOptions controlVirtualTableOptions(const ControlSettings &settings, VirtualTableOptions options) noexcept;
237
243std::expected<ChartOptions, TreeError> controlChartOptions(const ControlSettings &settings,
244 ChartOptions options) noexcept;
245
250DataStateConfig controlDataStateConfig(const ControlSettings &settings, DataStateConfig config);
251
255OverlayHostOptions controlOverlayHostOptions(const ControlSettings &settings, OverlayHostOptions options) noexcept;
256
260DialogOptions controlDialogOptions(const ControlSettings &settings, DialogOptions options) noexcept;
261
266MessageOptions controlMessageOptions(const ControlSettings &settings, MessageOptions options, DialogButtons buttons);
267
268inline MessageOptions controlMessageOptions(const ControlSettings &settings, MessageOptions options, int kind) {
269 return controlMessageOptions(settings, std::move(options), legacyDialogButtons(kind));
270}
271
275NotificationOptions controlNotificationOptions(const ControlSettings &settings, NotificationOptions options);
276
280ThemeSelectorOptions controlThemeSelectorOptions(const ControlSettings &settings, ThemeSelectorOptions options);
281
287std::expected<void, TreeError> controlThemeCatalogOptions(const ControlSettings &settings,
288 ThemeSelectionOptions &options,
289 std::optional<std::string> &initialId);
290
296ManagedError controlContextError(const ControlContextError &failure, Node<Widget> node = {});
297
306std::expected<LineEditOptions, ManagedError> controlLineEditOptions(const ControlSettings &settings,
307 const LineEditOptions &options, WidthPolicy policy,
308 const TextResolver &resolver,
309 Node<Widget> node = {});
310
311} // namespace portals::ui::detail
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
Cheap owning immutable snapshot of named definitions and defaults. Const snapshot reads are concurren...
Definition ui_control_context.hpp:632
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26
Owning frame decoration and finite paint-work policy.
Definition primitives.hpp:27
Owning chart settings, validated during preparation.
Definition chart.hpp:61
Construction-only settings for retained data presentation.
Definition data_presentation.hpp:79
Owning panel geometry and managed input settings, in terminal cells.
Definition dialog.hpp:52
Owning advanced frame settings; legacy BorderOptions remains a literal value type.
Definition primitives.hpp:62
Owning strictly determinate gauge settings.
Definition primitives.hpp:91
Ordinary help pane options; open/close bindings belong to the application.
Definition help_view.hpp:21
Single-row compact presentation options, bounded by the canonical registration limit.
Definition key_hints.hpp:12
Owning bounds and appearances for a one-line editor.
Definition line_edit.hpp:175
Owning linear container options.
Definition layout.hpp:193
Owning bounded-log settings; frame bars use ON_FRAME without a horizontal gutter.
Definition log_view.hpp:23
Original error plus independent runner/restoration and cleanup failures.
Definition managed_diagnostics.hpp:62
Fixed host budgets and explicit localization; no borrowed option spans.
Definition toast.hpp:81
Owning registration budget for a single scene overlay host.
Definition dialog.hpp:47
Owning overlay alignment and insets; all children share the content rectangle.
Definition grid.hpp:227
Owning ordinary-area settings; content is retained rather than automatically virtualized....
Definition scroll_options.hpp:36
Owning standalone bar settings, validated before mounting or replacement. No callbacks,...
Definition scroll_options.hpp:17
Owning single-row indicator configuration; no thread or timer is created by this value.
Definition spinner.hpp:87
Owning limits checked without silently truncating input or clusters.
Definition text.hpp:57
Owning fixed-row presentation settings; invalid heights are rejected at preparation.
Definition virtual_list.hpp:18
Owning table settings; preparation rejects invalid dimensions and exceeded budgets....
Definition virtual_table.hpp:13
Owning deterministic width policy; no font or terminal matching promise.
Definition text.hpp:42
Allocation-free typed fallback remains usable if diagnostic construction fails.
Definition ui_control_context.hpp:580
Static canonical property descriptor; returned views have process lifetime.
Definition ui_control_context.hpp:597
Sparse owning scrollbar skin; omitted leaves preserve context defaults. Glyph colors and supported at...
Definition ui_control_context.hpp:132
Owning sparse literals only; never contains IDs, models, handlers or live history.
Definition ui_control_context.hpp:391
Immutable settings for a ready-made modal choice dialog.
Definition message_box.hpp:90
Finite normalization budgets and optional first-preview layer admission.
Definition theme_selection.hpp:77
Owning selector captions, established dialog settings and optional application delivery.
Definition theme_selector.hpp:44
Loader-only bounded schema installation in an effective context copy.
Definition control_context.hpp:32
static bool hasDeclaredType(const ControlContext &context, std::string_view name) noexcept
static std::expected< void, ControlContextError > installFallbackSchema(ControlContext &context) noexcept
static std::span< const ControlPropertyDescriptor > gridSchema() noexcept
static std::expected< void, ControlContextError > installDialogSchema(ControlContext &context, std::string_view name) noexcept
static std::expected< void, ControlContextError > themeFamilySchema(ControlContext &context, std::string_view name, ControlFactoryKind kind) noexcept
static std::expected< void, ControlContextError > installThemeSelectorSchema(ControlContext &context) noexcept
static std::string_view canonicalProperty(std::string_view property) 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