pub struct Dialog;Expand description
A modal dialog component with configurable buttons.
Dialog displays a centered overlay with a title, message, and
configurable buttons. It implements:
Componentfor update/view logicToggleablefor visibility control
§Visual Format
┌─────── Title ───────┐
│ │
│ Message text here │
│ │
│ [Cancel] [OK] │
└─────────────────────┘§Messages
FocusNext- Move focus to the next buttonFocusPrev- Move focus to the previous buttonPress- Press the currently focused buttonClose- Close the dialog without selectionOpen- Show the dialog
§Output
ButtonPressed(id)- A button was pressedClosed- The dialog was closed without selection
§Example
use envision::component::{
Dialog, DialogMessage, DialogOutput, DialogState, Component, Toggleable
};
// Create and show a confirmation dialog
let mut state = DialogState::confirm("Delete?", "This cannot be undone.");
Dialog::show(&mut state);
// Navigate to Cancel
Dialog::update(&mut state, DialogMessage::FocusPrev);
// Press Cancel
let output = Dialog::update(&mut state, DialogMessage::Press);
assert_eq!(output, Some(DialogOutput::ButtonPressed("cancel".into())));Trait Implementations§
Source§impl Component for Dialog
impl Component for Dialog
Source§type State = DialogState
type State = DialogState
The component’s internal state type. Read more
Source§type Message = DialogMessage
type Message = DialogMessage
Messages this component can receive. Read more
Source§type Output = DialogOutput
type Output = DialogOutput
Messages this component can emit to its parent. Read more
Source§fn update(state: &mut Self::State, msg: Self::Message) -> Option<Self::Output>
fn update(state: &mut Self::State, msg: Self::Message) -> Option<Self::Output>
Update component state based on a message. Read more
Source§fn handle_event(
state: &Self::State,
event: &Event,
_ctx: &EventContext,
) -> Option<Self::Message>
fn handle_event( state: &Self::State, event: &Event, _ctx: &EventContext, ) -> Option<Self::Message>
Maps an input event to a component message. Read more
Source§fn view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
fn view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
Render the component to the given area. Read more
Source§fn traced_view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
fn traced_view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
Renders the component with optional tracing instrumentation. Read more
Source§fn dispatch_event(
state: &mut Self::State,
event: &Event,
ctx: &EventContext,
) -> Option<Self::Output>
fn dispatch_event( state: &mut Self::State, event: &Event, ctx: &EventContext, ) -> Option<Self::Output>
Dispatches an event by mapping it to a message and updating state. Read more
Source§impl Toggleable for Dialog
impl Toggleable for Dialog
Source§fn is_visible(state: &Self::State) -> bool
fn is_visible(state: &Self::State) -> bool
Returns true if this component is currently visible.
Source§fn set_visible(state: &mut Self::State, visible: bool)
fn set_visible(state: &mut Self::State, visible: bool)
Sets the visibility of this component.
Auto Trait Implementations§
impl Freeze for Dialog
impl RefUnwindSafe for Dialog
impl Send for Dialog
impl Sync for Dialog
impl Unpin for Dialog
impl UnsafeUnpin for Dialog
impl UnwindSafe for Dialog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more