Skip to main content

Dialog

Struct Dialog 

Source
pub struct Dialog<'a, Message, Base, Content, Theme = Theme, Renderer = Renderer>
where Theme: 'a + Catalog,
{ /* private fields */ }
Expand description

A message dialog.

Only the content is required, controls and the title are optional.

The dialog box’s maximum size is limited by default (see DEFAULT_MAX_WIDTH and DEFAULT_MAX_HEIGHT). This is so that controls can Fill (which the crate’s button helper does by default) without making the dialog cover everything.

Implementations§

Source§

impl<'a, Message, Base, Content, Theme, Renderer> Dialog<'a, Message, Base, Content, Theme, Renderer>
where Message: 'a + Clone, Theme: 'a + Catalog, Renderer: Renderer,

Source

pub fn new(is_open: bool, base: Base, content: Content) -> Self

Creates a new Dialog with the given base and dialog content.

Source

pub fn with_controls( is_open: bool, base: Base, content: Content, controls: Vec<Element<'a, Message, Theme, Renderer>>, ) -> Self

Creates a new Dialog with the given base, dialog content and controls.

Source

pub fn title(self, title: impl IntoFragment<'a>) -> Self

Sets the Dialog’s title.

Source

pub fn on_press(self, on_press: Message) -> Self

Sets the message that will be produced when the Dialog’s backdrop is pressed.

Source

pub fn on_press_with(self, on_press: impl Fn() -> Message + 'a) -> Self

Sets the message that will be produced when the Dialog’s backdrop is pressed.

This is analogous to Dialog::on_press, but using a closure to produce the message.

Source

pub fn on_press_maybe(self, on_press: Option<Message>) -> Self

Sets the message that will be produced when the Dialog’s backdrop is pressed, if Some.

Source

pub fn width(self, width: impl Into<Length>) -> Self

Sets the Dialog’s width.

Source

pub fn height(self, height: impl Into<Length>) -> Self

Sets the Dialog’s height.

Source

pub fn align_left(self) -> Self

Aligns the Dialog to the left.

Source

pub fn align_right(self) -> Self

Aligns the Dialog to the right.

Source

pub fn align_top(self) -> Self

Aligns the Dialog to the top.

Source

pub fn align_bottom(self) -> Self

Aligns the Dialog to the bottom.

Source

pub fn align_x(self, alignment: impl Into<Horizontal>) -> Self

Sets the Dialog’s alignment for the horizontal axis.

Dialogs are horizontally centered by default.

Source

pub fn align_y(self, alignment: impl Into<Vertical>) -> Self

Sets the Dialog’s alignment for the vertical axis.

Dialogs are vertically centered by default.

Source

pub fn box_padding(self, padding: impl Into<Padding>) -> Self

Sets the Dialog’s inner padding.

Source

pub fn backdrop_padding(self, padding: impl Into<Padding>) -> Self

Sets the padding between the Dialog and its backdrop.

Source

pub fn spacing(self, spacing: impl Into<Pixels>) -> Self

Sets the Dialog’s spacing.

Source

pub fn align_controls(self, align: impl Into<Vertical>) -> Self

Sets the vertical alignment of the Dialog’s controls.

Source

pub fn font(self, font: Font) -> Self

Sets the Font of the Dialog’s title.

Source

pub fn push_control( self, control: Element<'a, Message, Theme, Renderer>, ) -> Self

Adds a control to the Dialog.

Source

pub fn push_control_maybe( self, control: Option<Element<'a, Message, Theme, Renderer>>, ) -> Self

Adds a control to the Dialog, if Some.

Source

pub fn extend_controls( self, controls: impl IntoIterator<Item = Element<'a, Message, Theme, Renderer>>, ) -> Self

Extends the Dialog with the given controls.

Source

pub fn backdrop(self, color: impl Into<Color>) -> Self
where <Theme as Catalog>::Class<'a>: From<StyleFn<'a, Theme>>,

Sets the backdrop color of the Dialog.

Source

pub fn style(self, style: impl Fn(&Theme) -> Style + 'a) -> Self
where <Theme as Catalog>::Class<'a>: From<StyleFn<'a, Theme>>,

Sets the style of the Dialog.

Source

pub fn title_style(self, style: impl Fn(&Theme) -> Style + 'a) -> Self
where <Theme as Catalog>::Class<'a>: From<StyleFn<'a, Theme>>,

Sets the style of the Dialog’s title.

Source

pub fn container_style(self, style: impl Fn(&Theme) -> Style + 'a) -> Self
where <Theme as Catalog>::Class<'a>: From<StyleFn<'a, Theme>>,

Sets the style of the Dialog’s container.

Source

pub fn class(self, class: impl Into<<Theme as Catalog>::Class<'a>>) -> Self

Sets the style class of the Dialog.

Source

pub fn title_class( self, class: impl Into<<Theme as Catalog>::Class<'a>>, ) -> Self

Sets the style class of the Dialog’s title.

Source

pub fn container_class( self, class: impl Into<<Theme as Catalog>::Class<'a>>, ) -> Self

Sets the style class of the Dialog’s container.

Source

pub fn to_widget(self) -> impl Widget<Message, Theme, Renderer>
where Base: Widget<Message, Theme, Renderer> + 'a, Content: Widget<Message, Theme, Renderer> + 'a, <Theme as Catalog>::Class<'a>: From<StyleFn<'a, Theme>>,

Turns the Dialog into an iced Widget.

Auto Trait Implementations§

§

impl<'a, Message, Base, Content, Theme = Theme, Renderer = ()> !RefUnwindSafe for Dialog<'a, Message, Base, Content, Theme, Renderer>

§

impl<'a, Message, Base, Content, Theme = Theme, Renderer = ()> !Send for Dialog<'a, Message, Base, Content, Theme, Renderer>

§

impl<'a, Message, Base, Content, Theme = Theme, Renderer = ()> !Sync for Dialog<'a, Message, Base, Content, Theme, Renderer>

§

impl<'a, Message, Base, Content, Theme = Theme, Renderer = ()> !UnwindSafe for Dialog<'a, Message, Base, Content, Theme, Renderer>

§

impl<'a, Message, Base, Content, Theme, Renderer> Freeze for Dialog<'a, Message, Base, Content, Theme, Renderer>
where Base: Freeze, Content: Freeze, Vec<Element<'a, Message, Theme, Renderer>>: Freeze, Option<Box<dyn Fn() -> Message + 'a>>: Freeze, <Theme as Catalog>::Class<'a>: Freeze, <Theme as Catalog>::Class<'a>: Freeze, <Theme as Catalog>::Class<'a>: Freeze,

§

impl<'a, Message, Base, Content, Theme, Renderer> Unpin for Dialog<'a, Message, Base, Content, Theme, Renderer>
where Base: Unpin, Content: Unpin, Vec<Element<'a, Message, Theme, Renderer>>: Unpin, Option<Box<dyn Fn() -> Message + 'a>>: Unpin, <Theme as Catalog>::Class<'a>: Unpin, <Theme as Catalog>::Class<'a>: Unpin, <Theme as Catalog>::Class<'a>: Unpin,

§

impl<'a, Message, Base, Content, Theme, Renderer> UnsafeUnpin for Dialog<'a, Message, Base, Content, Theme, Renderer>
where Base: UnsafeUnpin, Content: UnsafeUnpin, Vec<Element<'a, Message, Theme, Renderer>>: UnsafeUnpin, Option<Box<dyn Fn() -> Message + 'a>>: UnsafeUnpin, <Theme as Catalog>::Class<'a>: UnsafeUnpin, <Theme as Catalog>::Class<'a>: UnsafeUnpin, <Theme as Catalog>::Class<'a>: UnsafeUnpin,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.