Modal

Struct Modal 

Source
pub struct Modal {
    pub open: bool,
    pub size: ModalSize,
    pub backdrop: BackdropBehavior,
    pub close_on_escape: bool,
    pub title: Option<String>,
    pub show_close_button: bool,
    pub backdrop_color: Color,
    pub background_color: Color,
    pub border_radius: f32,
    pub padding: f32,
    /* private fields */
}
Expand description

Modal dialog widget.

Fields§

§open: bool

Whether modal is open

§size: ModalSize

Modal size

§backdrop: BackdropBehavior

Backdrop behavior

§close_on_escape: bool

Close on escape key

§title: Option<String>

Optional title

§show_close_button: bool

Show close button

§backdrop_color: Color

Backdrop color

§background_color: Color

Modal background color

§border_radius: f32

Border radius

§padding: f32

Padding

Implementations§

Source§

impl Modal

Source

pub fn new() -> Self

Create a new modal dialog.

Source

pub const fn open(self, open: bool) -> Self

Set modal open state.

Source

pub const fn size(self, size: ModalSize) -> Self

Set modal size.

Source

pub const fn backdrop(self, behavior: BackdropBehavior) -> Self

Set backdrop behavior.

Source

pub const fn close_on_escape(self, enabled: bool) -> Self

Set close on escape.

Source

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

Set the title.

Source

pub const fn show_close_button(self, show: bool) -> Self

Set show close button.

Source

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

Set backdrop color.

Source

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

Set background color.

Source

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

Set border radius.

Source

pub const fn padding(self, padding: f32) -> Self

Set padding.

Source

pub fn content(self, widget: impl Widget + 'static) -> Self

Set the content widget.

Source

pub fn footer(self, widget: impl Widget + 'static) -> Self

Set the footer widget.

Source

pub fn with_test_id(self, id: impl Into<String>) -> Self

Set the test ID.

Source

pub fn show(&mut self)

Open the modal.

Source

pub fn hide(&mut self)

Close the modal.

Source

pub fn toggle(&mut self)

Toggle the modal.

Source

pub const fn is_open(&self) -> bool

Check if modal is open.

Source

pub const fn animation_progress(&self) -> f32

Get animation progress.

Source

pub const fn content_bounds(&self) -> Rect

Get content bounds.

Trait Implementations§

Source§

impl Default for Modal

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Modal

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Modal

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Widget for Modal

Source§

fn type_id(&self) -> TypeId

Get the type identifier for this widget type.
Source§

fn measure(&self, constraints: Constraints) -> Size

Compute intrinsic size constraints. Read more
Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Position children within allocated bounds. Read more
Source§

fn paint(&self, canvas: &mut dyn Canvas)

Generate draw commands for rendering. Read more
Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Handle input events. Read more
Source§

fn children(&self) -> &[Box<dyn Widget>]

Get child widgets for tree traversal.
Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Get mutable child widgets.
Source§

fn is_focusable(&self) -> bool

Check if this widget can receive keyboard focus.
Source§

fn test_id(&self) -> Option<&str>

Get the test ID for this widget (if any).
Source§

fn bounds(&self) -> Rect

Get the current bounds of this widget. Read more
Source§

fn is_interactive(&self) -> bool

Check if this widget is interactive (can receive focus/events).
Source§

fn accessible_name(&self) -> Option<&str>

Get the accessible name for screen readers.
Source§

fn accessible_role(&self) -> AccessibleRole

Get the accessible role.

Auto Trait Implementations§

§

impl Freeze for Modal

§

impl !RefUnwindSafe for Modal

§

impl Send for Modal

§

impl Sync for Modal

§

impl Unpin for Modal

§

impl !UnwindSafe for Modal

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,