pub struct Dialog {
pub title: String,
pub message: Option<String>,
pub width: f32,
pub radius: f32,
pub presentation: DialogPresentation,
/* private fields */
}Expand description
A dialog surface: title, optional message, action buttons.
Two ways to present it:
OverlayApi::dialog— co-located declaration; always the modal presentation (scrim, centering, input blocking, focus trap).Dialog::emit— theDrawer::emit-style per-frame push, which honors the presentation chosen withDialog::modal/Dialog::non_modal/Dialog::full_page.
Button::new("Delete")
.dialog(confirm.clone(), move || Box::new(
Dialog::new("Delete item?")
.message("This cannot be undone.")
.action("Cancel", { let c = confirm.clone(); move || c.set(false) })
.destructive_action("Delete", move || { /* … */ })
))Fields§
§title: String§message: Option<String>§width: f32§radius: f32§presentation: DialogPresentationImplementations§
Source§impl Dialog
impl Dialog
pub fn new(title: impl Into<String>) -> Self
pub fn message(self, m: impl Into<String>) -> Self
pub fn width(self, w: f32) -> Self
pub fn radius(self, r: f32) -> Self
Sourcepub fn background(self, c: Color) -> Self
pub fn background(self, c: Color) -> Self
Dialog surface fill color (theme’s surface if unset).
Sourcepub fn material(self, m: ShaderMaterial) -> Self
pub fn material(self, m: ShaderMaterial) -> Self
Per-instance shader material — replaces the surface fill when
resolved. Beats the theme’s DialogMaterial default (D124 Step 5).
Sourcepub fn modal(self) -> Self
pub fn modal(self) -> Self
Present as a modal dialog (the default) — see
DialogPresentation::Modal.
Sourcepub fn non_modal(self) -> Self
pub fn non_modal(self) -> Self
Present as a non-modal dialog — the content below stays interactive.
See DialogPresentation::NonModal.
Sourcepub fn full_page(self) -> Self
pub fn full_page(self) -> Self
Present full-page — the dialog fills the window like a pushed page.
See DialogPresentation::FullPage.
Sourcepub fn action(
self,
label: impl Into<String>,
f: impl Fn() + Send + Sync + 'static,
) -> Self
pub fn action( self, label: impl Into<String>, f: impl Fn() + Send + Sync + 'static, ) -> Self
Add a neutral (secondary) action button.
Sourcepub fn primary_action(
self,
label: impl Into<String>,
f: impl Fn() + Send + Sync + 'static,
) -> Self
pub fn primary_action( self, label: impl Into<String>, f: impl Fn() + Send + Sync + 'static, ) -> Self
Add a highlighted (primary) action button.
Sourcepub fn destructive_action(
self,
label: impl Into<String>,
f: impl Fn() + Send + Sync + 'static,
) -> Self
pub fn destructive_action( self, label: impl Into<String>, f: impl Fn() + Send + Sync + 'static, ) -> Self
Add a destructive (danger) action button.
Sourcepub fn overlay_entry(
self,
on_dismiss: impl Fn() + Send + Sync + 'static,
) -> OverlayEntry
pub fn overlay_entry( self, on_dismiss: impl Fn() + Send + Sync + 'static, ) -> OverlayEntry
The pure presentation→overlay-config mapping: consumes the dialog and
returns the OverlayEntry that presents it. on_dismiss is wired
to the barrier (scrim tap / Escape) where the presentation has one;
DialogPresentation::NonModal has no barrier, so on_dismiss is
simply unused there.
Sourcepub fn emit(self, open: &Atom<bool>)
pub fn emit(self, open: &Atom<bool>)
Present via the overlay stack while open is true — same per-frame
re-push convention as Drawer::emit / Snackbar::emit: call from
a host widget’s paint (or the app’s build) every frame the dialog
should be visible. The barrier dismisser sets open to false.
Trait Implementations§
Source§impl Widget for Dialog
impl Widget for Dialog
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
ctx.constraints and return a size within them. Read more