Expand description
Dialogs, as a plugin (DialogsPlugin, in DefaultPlugins): a
question before an action (Confirm), a form of typed fields
(Form, from value descriptors), a choice among options, each
answering a value of its own, with a filter field (Choose), a
notice to acknowledge (Info), and a dialog with a body of its own
(Custom, opened with Dialogs::open_custom). They queue, one
shown at a time, modal, drawn from the theme’s tokens.
A dialog belongs to the window it was opened from (ADR 0025): the
application window being drawn, or the one whose command opened it
(its appWindow), else the active one. Each application window has
its own queue, one dialog shown at a time in each, and a dialog blocks
its own window only: the main window and an application window each
answer their own. In the main window’s group, a dialog comes up over
the window of it the user worked in last
(AppHandle::active_window): a detached panel’s window when the
dialog was opened from there, the main window otherwise, or once that
window is closed; it blocks the main window and its detached panels
(their keys dropped, a backdrop over them; a click there brings the
dialog’s window to the front). A dialog whose application window
closes is cancelled with it, as a file choice asked from there is; one
whose window moves into the main window (the main window closed while
it was open) goes to the main window’s queue.
A dialog is a popup on the bus (ADR 0029): coming up, it asks its
pop.popup.open (dialog:<id>, owned by the plugin that opened it or by
this one, its parent the window of its group); answered, cancelled, or
its plugin gone, its pop.popup.close. Its window closing asks that
pop.popup.close (parent-closed), and this plugin’s listener on it
(POPUP_LISTENER) cancels the dialog in that call; the dialogs still
waiting in that window’s queue are cancelled by CANCEL_ON_CLOSE, a
listener of pop.window.close. The dialogs’ block is in the WINDOW_OVERLAYS zone, drawn in
every window.
Dialogs::current, Dialogs::answer and the dialogs collector
address the dialog shown in the current window group (the one being
drawn, or commanded, or an agent’s call names), else the first one
queued.
A custom dialog is a host of the mount contract (ADR 0013): its body
is drawn by a closure kept on the application’s side (the queue
stays Clone and Send), in a size of the dialog’s own, in a
dialog focus scope and a fault boundary, every frame (the body’s
components keep draining their workers’ queues). It keeps every
dialog rule: the primary button says what it does, Enter accepts and
Escape cancels, steps, the debug bridge, movable, closable, the
backdrop. Keys the body claims (Custom::claims, from its
component’s Mountable) go to it first: when it claims Enter,
Ctrl+Enter accepts; when it claims Escape, Escape goes to the body
while it has something to cancel (CustomPass::claim_escape, a
drag), and cancels the dialog otherwise. Its values
(CustomPass::value) are merged into the command’s arguments; the
dialogs collector shows its description (CustomPass::describe)
and answers it as a form.
Rules: the primary button says what it does (“Delete 3 images”, never “OK”); a dangerous one is styled as such and the focus starts on Cancel; Enter accepts (except a danger), Escape cancels. Accepting runs the dialog’s command (through the host) with its arguments, the form’s values and the choice merged in.
No header band and no close button by default: Cancel and Escape are
the way out. A dialog opened as DialogSpec::closable() (or every
dialog, with the dialogs.closable setting) has a ✕ at the right end
of its title row, named “Close”, which is Escape: the same cancel,
through the same step and hooks, refused when Escape is.
A notice and a confirmation have a Copy button in their bottom left
corner (left out with .copyable(false)): it puts their title and
text on the clipboard, then their Details, key-value lines for a
bug report, under a separator. The details stay off screen, or show
in a collapsed “Details” section (DetailsMode; shown by default
on an error, Info::error).
A dialog opened as DialogSpec::movable() (or every dialog, with
the dialogs.movable setting) has a header band instead of its title
row: its own tone, a separator, the move cursor, the ✕ when it is
closable. Dragging the band moves the dialog, kept inside the window
(again when the window is resized); a double click on it centres it
again; the dialogs.move command (Alt+F7) moves it with the arrow
keys (Shift for bigger steps), Enter keeping the place and Escape
putting it back. A dialog comes up centred, or where it was left when
opened with DialogSpec::remember_position() (kept per key in the
host’s store, under ui/dialogs/<key>).
Its backdrop (Backdrop) dims the interface (Dim, the
backdrop.opacity token’s strength, fading while the dialog is
dragged) or leaves it untouched (Clear, for a dialog previewing its
effect on the image); the dialog stays modal either way, and a click
on the backdrop never closes it.
A form’s path field (a descriptor made with Descriptor::path) has a
Browse button: the file chooser (crate::files: the system’s, or
the in-app picker), its result written into the field when it comes;
without the files plugin, the in-app picker inside the dialog.
Every open dialog is data: the debug bridge’s dialogs collector
shows the current one (a form’s values also as a plain values map)
and answers it (answer, the user’s unless the application offers it
to agents) as its caller, so an agent sees and answers what a person
would, with its origin recorded. Accepting a dialog runs its command
with the answer’s origin; an answer that would run a command not
offered to agents (CommandSpec::no_agent) is refused to anyone but
the user, whoever gives it (dialog.answer.refused on the journal),
and the dialog stays open.
Steps (ADR 0011): dialog.show runs when a dialog comes up (a
before-hook may veto it: it is cancelled), dialog.answer around each
answer (a before-hook may veto it, the dialog staying open with the
reason, or redirect it to another answer; a run-hook may answer its
own way), dialog.move when a dialog is dropped, moved by a key or
centred again (a before-hook may veto it, the dialog going back, or
redirect it elsewhere). The journal says dialog.answered, then
dialog.chosen (the option’s index, label and value) or
dialog.cancelled, dialog.filtered as a choice’s filter changes,
and dialog.moved once a move is done.
A dialog belongs to the plugin of its command, and a custom one also to
the plugin that opened it (whose command, connection or handler was
running). When that plugin is disconnected, the dialog is cancelled
at once (ADR 0028): dialog.cancelled from egui_pop, with the reason
(“its plugin x is disconnected”), and the next queued one shows.
use egui_pop_api::dialogs::{self, Confirm};
use egui_pop_api::App;
use egui_pop_model::ids::CommandId;
let app = App::builder()
.plugin(dialogs::DialogsPlugin)
.build(&egui::Context::default())
.unwrap();
let d = app.handle().service(&dialogs::DIALOGS).unwrap();
d.open(Confirm::new("Delete 3 images?", "Delete 3 images", CommandId::from_static("doc.delete"))
.detail("They go to the trash.")
.danger());
assert_eq!(d.describe()["kind"], "confirm");Structs§
- Choose
- One option among several, under a filter field; the command gets the
option’s value (under
value_key,valueby default), its index (choice) and itslabel, merged intoargs. - Choose
Option - One option of a
Choose: what it shows and the value it answers. - Confirm
- A question before an action: a primary button and Cancel, or, with a
Secondary, the classic three buttons (“Save”, “Don’t save”, “Cancel”) in the platform’s order (ButtonOrder). - Custom
- A dialog with a body of its own (ADR 0013), drawn by a closure
given to
Dialogs::open_custom: a preview, a viewport, a curve. - Custom
Pass - What a custom dialog’s body says during a pass: its values, whether the primary action is possible, its description, an Escape it takes, an answer of its own.
- Details
- A dialog’s technical details, for a bug report: key-value lines,
copied after its text under a
---separator, eachkey: value. - Dialog
Spec - A dialog and how it is presented around its content: what
Dialogs::opentakes (any dialog converts into one, presented by default). - Dialogs
- The queue of dialogs.
- Dialogs
Plugin - The plugin.
- Field
- One field of a form.
- Form
- Fields typed by value descriptors, and the command they go to.
- Info
- Something to read and acknowledge: a message, or an error
(
Info::error). - Secondary
- A confirmation’s second action (
Confirm::secondary): often the destructive one (“Don’t save”, “Quit without saving”), in the danger tone, which is never the default: Enter takes the primary button.
Enums§
- Answer
- An answer.
- Backdrop
- What a modal dialog does to the interface behind it. Either way the interface is blocked while the dialog is open, and a click on it never closes the dialog.
- Button
Order - The order of a dialog’s buttons along its footer, as the platform has it.
- Details
Mode - Where a dialog’s details go.
- Dialog
- A dialog.
Constants§
- CANCEL_
ON_ CLOSE - The dialogs’ listener on
pop.window.close: the dialogs waiting in the closing window’s queue (never shown, so no popup yet) are cancelled. - CMD_
MOVE - Moves the dialog shown with the arrow keys (Alt+F7): Shift for bigger steps, Enter keeps the place, Escape puts it back.
- DIALOGS
- The dialogs, as a service.
- PLUGIN
- The plugin’s id, owner of the positions it keeps.
- POPUP_
LISTENER - The dialogs’ listener on
pop.popup.close: the dialog of that popup is cancelled, whoever asked (its window closing, among others). - POPUP_
PREFIX - A dialog’s popup id in the registry:
dialog:<id>. - SETTING_
CLOSABLE - The setting: every dialog has the close button, as if opened
DialogSpec::closable(). - SETTING_
MOVABLE - The setting: every dialog is movable, as if opened
DialogSpec::movable(). - STEP_
ANSWER - A dialog is answered:
{"dialog": description, "answer": answer, "origin": source}; a veto keeps it open with the reason, a redirect changes the answer. - STEP_
MOVE - A dialog is moved: dropped after a drag, moved by a key, centred
again.
{"id", "title", "key", "how": "drag" | "keys" | "recentre", "from": [x, y], "to": [x, y]}, offsets from the window’s centre in points; a veto puts it back where it was, a redirect places it at its ownto. - STEP_
SHOW - A dialog comes up: its arguments are its description; a veto cancels it.
Functions§
- custom_
host - What the custom dialog offers its body (ADR 0013): a size of its own, modal, transient, Enter and Escape given to a body claiming them, a focus scope and a fault boundary, the main window, sRGB first (decided 2026-10-14), outside the context stack’s projection.
- entries
- The entries of a folder a picker lists: folders, then the files the hint accepts (none for a folder picker), by name; hidden ones left out.