Skip to main content

Dialog

Struct Dialog 

Source
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:

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: DialogPresentation

Implementations§

Source§

impl Dialog

Source

pub fn new(title: impl Into<String>) -> Self

Source

pub fn message(self, m: impl Into<String>) -> Self

Source

pub fn width(self, w: f32) -> Self

Source

pub fn radius(self, r: f32) -> Self

Source

pub fn background(self, c: Color) -> Self

Dialog surface fill color (theme’s surface if unset).

Source

pub fn color(self, c: Color) -> Self

Title/message text color (theme’s on_surface if unset).

Source

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).

Source

pub fn modal(self) -> Self

Present as a modal dialog (the default) — see DialogPresentation::Modal.

Source

pub fn non_modal(self) -> Self

Present as a non-modal dialog — the content below stays interactive. See DialogPresentation::NonModal.

Source

pub fn full_page(self) -> Self

Present full-page — the dialog fills the window like a pushed page. See DialogPresentation::FullPage.

Source

pub fn action( self, label: impl Into<String>, f: impl Fn() + Send + Sync + 'static, ) -> Self

Add a neutral (secondary) action button.

Source

pub fn primary_action( self, label: impl Into<String>, f: impl Fn() + Send + Sync + 'static, ) -> Self

Add a highlighted (primary) action button.

Source

pub fn destructive_action( self, label: impl Into<String>, f: impl Fn() + Send + Sync + 'static, ) -> Self

Add a destructive (danger) action button.

Source

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.

Source

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

Source§

fn layout(&self, ctx: &LayoutCtx<'_>) -> Size

Measure under ctx.constraints and return a size within them. Read more
Source§

fn paint(&self, ctx: &mut PaintCtx<'_>)

Record draw commands for ctx.rect. Read more
Source§

fn children(&self) -> Children<'_>

Declare this widget’s children. Drives every default below.
Source§

fn flex_factor(&self) -> f32

Flex weight inside Row/Column. Wrappers are transparent by default.
Source§

fn into_element(self) -> Element
where Self: Sized + 'static,

Wrap this widget in an Element so it can be returned from Component::build().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<W> FocusApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn focus_node(self, node: FocusNode) -> WithFocus<Self>

Attach a focus node. This enables focus-ring rendering and explicit neighbor wiring.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<W> HeroApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn hero_tag(self, tag: impl Into<String>) -> Hero<Self>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> OverlayApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn dropdown( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn sheet( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn dialog( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn rich_tooltip( self, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn toast( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

impl<W> PressApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn on_press(self, f: impl Fn() + Send + Sync + 'static) -> Pressable<Self>

Source§

fn on_long_press( self, f: impl Fn() + Send + Sync + 'static, ) -> LongPressable<Self>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<W> WidgetExt for W
where W: Widget + 'static,

Source§

fn tooltip(self, label: impl Into<String>) -> Tooltip

Show label while the pointer hovers this widget.