Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
dialog.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <optional>
6#include <portals/grid.hpp>
7#include <portals/primitives.hpp>
8
9namespace portals {
10namespace detail {
11struct DialogAccess;
12}
13
15enum class DialogMode {
18};
19
26
32
36 END
37};
38
45
48 std::size_t maxLayers{32};
49};
50
62
68class OverlayHost : public Overlay {
69public:
73 explicit OverlayHost(OverlayHostOptions options = {}, SizePolicy policy = {});
79 std::expected<CellSize, TreeError> childAvailable(CellSize available) const override;
83 std::expected<CellSize, TreeError> measureChildren(std::span<const MeasuredChild> children) const override;
88 std::expected<std::vector<CellRect>, TreeError> arrangeChildren(std::span<const MeasuredChild> children,
89 CellSize available) const override;
90
91private:
92 friend struct detail::DialogAccess;
93 OverlayHostOptions options_;
94 NodeId body_{};
95};
96
102class Dialog : public Widget, public Layout {
103public:
111 static std::expected<void, TreeError> validate(DialogOptions options);
115 std::expected<CellSize, TreeError> childAvailable(CellSize available) const override;
119 std::expected<CellSize, TreeError> measureChildren(std::span<const MeasuredChild> children) const override;
124 std::expected<std::vector<CellRect>, TreeError> arrangeChildren(std::span<const MeasuredChild> children,
125 CellSize available) const override;
126
127private:
128 friend struct detail::DialogAccess;
129 DialogOptions options_;
130 std::optional<CellRect> anchor_;
131 NodeId close_{};
132};
133} // namespace portals
std::expected< CellSize, TreeError > measureChildren(std::span< const MeasuredChild > children) const override
std::expected< std::vector< CellRect >, TreeError > arrangeChildren(std::span< const MeasuredChild > children, CellSize available) const override
static std::expected< void, TreeError > validate(DialogOptions options)
DialogOptions options() const
std::expected< CellSize, TreeError > childAvailable(CellSize available) const override
Dialog(DialogOptions options={})
Pure container interface; callbacks run inside tree.read and an enclosing tree.frame....
Definition layout.hpp:130
OverlayHost(OverlayHostOptions options={}, SizePolicy policy={})
std::expected< std::vector< CellRect >, TreeError > arrangeChildren(std::span< const MeasuredChild > children, CellSize available) const override
OverlayHostOptions hostOptions() const
std::expected< CellSize, TreeError > measureChildren(std::span< const MeasuredChild > children) const override
std::expected< CellSize, TreeError > childAvailable(CellSize available) const override
OverlayOptions options() const
Owning UI-thread copy.
Overlay(OverlayOptions options={}, SizePolicy policy={})
Own settings and size policies.
UI-owned extension object. Hooks borrow their arguments for one call. Models are separate explicit ow...
Definition widget.hpp:32
Public Portals API.
Definition action.hpp:8
@ CANCEL
Cancel the current interaction.
Definition action.hpp:12
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
DialogDismissReason
Generic dismissal cause, independent of application results.
Definition dialog.hpp:28
@ PROGRAMMATIC
Explicit semantic action, the default for caller-created ActionEvent.
Definition action.hpp:25
DialogPlacement
Preferred panel position within the owning host.
Definition dialog.hpp:21
@ ABOVE_START
Prefer above the body anchor, aligned to its leading edge.
Definition dialog.hpp:24
@ CENTER
Center in the usable viewport, rounding down.
Definition dialog.hpp:22
@ BELOW_START
Prefer below the body anchor, aligned to its leading edge.
Definition dialog.hpp:23
DialogClosePlacement
Which top-frame segment owns the close affordance.
Definition dialog.hpp:34
@ START
Immediately after the leading corner.
Definition dialog.hpp:35
@ END
Immediately before the trailing corner.
Definition dialog.hpp:36
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
An owning available extent in terminal columns/rows.
Definition geometry.hpp:44
Optional finite close chrome settings; the glyph occupies three terminal cells.
Definition dialog.hpp:40
DialogClosePlacement placement
Top-edge placement.
Definition dialog.hpp:42
bool focusable
Include in focus traversal; initial action focus is unchanged.
Definition dialog.hpp:43
bool enabled
Enable this explicitly requested close affordance.
Definition dialog.hpp:41
Owning panel geometry and managed input settings, in terminal cells.
Definition dialog.hpp:52
bool closeOnEscape
Allow managed cancellation with Escape.
Definition dialog.hpp:58
std::int32_t anchorGap
Nonnegative distance from the anchor.
Definition dialog.hpp:57
DialogCloseOptions closeButton
Opt-in close chrome on the top frame edge.
Definition dialog.hpp:60
BorderOptions frame
Frame glyph policy and allocated opaque-area paint cap.
Definition dialog.hpp:59
std::int32_t viewportMargin
Nonnegative inset, reduced on tiny viewports.
Definition dialog.hpp:56
DialogPlacement placement
Preferred placement; anchors belong to the host body.
Definition dialog.hpp:54
CellSize maximumPanelSize
Strictly positive independent width and height caps.
Definition dialog.hpp:55
DialogMode mode
Modal input confinement by default.
Definition dialog.hpp:53
Owning identity, independent of addresses; zero is never a live identity.
Definition widget_types.hpp:15
Owning registration budget for a single scene overlay host.
Definition dialog.hpp:47
std::size_t maxLayers
Positive cap on registered layers, including hidden layers.
Definition dialog.hpp:48
Owning independent policies for width and height.
Definition layout.hpp:35