pub struct Dialog { /* private fields */ }Expand description
A named Material modal with optional structured slots or caller-defined content.
Implementations§
Source§impl Dialog
impl Dialog
Sourcepub fn new(
id: impl Into<ElementId>,
state: &Entity<DialogState>,
title: impl Into<SharedString>,
) -> Self
pub fn new( id: impl Into<ElementId>, state: &Entity<DialogState>, title: impl Into<SharedString>, ) -> Self
Creates a basic Material dialog bound to state with the given accessible title.
Sourcepub fn alert(
id: impl Into<ElementId>,
state: &Entity<DialogState>,
title: impl Into<SharedString>,
description: impl Into<SharedString>,
) -> Self
pub fn alert( id: impl Into<ElementId>, state: &Entity<DialogState>, title: impl Into<SharedString>, description: impl Into<SharedString>, ) -> Self
Creates a basic alert dialog with a description and no default cancel button.
Sourcepub fn unstructured(
id: impl Into<ElementId>,
state: &Entity<DialogState>,
accessibility_label: impl Into<SharedString>,
) -> Self
pub fn unstructured( id: impl Into<ElementId>, state: &Entity<DialogState>, accessibility_label: impl Into<SharedString>, ) -> Self
Creates a modal shell whose body owns the structure and scrolling.
Sourcepub fn open_window(
state: &Entity<DialogState>,
parent: &mut Window,
options: WindowOptions,
cx: &mut App,
build: impl Fn(&Entity<DialogState>, &mut Window, &mut App) -> Self + 'static,
) -> Result<Option<AnyWindowHandle>>
pub fn open_window( state: &Entity<DialogState>, parent: &mut Window, options: WindowOptions, cx: &mut App, build: impl Fn(&Entity<DialogState>, &mut Window, &mut App) -> Self + 'static, ) -> Result<Option<AnyWindowHandle>>
Opens a separate GPUI modal window, with the active window as its native parent. Supply the invoking window and build a fresh dialog on each render. An already open state returns its native window handle, or None for an in-window dialog.
Sourcepub fn variant(self, variant: DialogVariant) -> Self
pub fn variant(self, variant: DialogVariant) -> Self
Sets the presentation variant (default DialogVariant::Basic).
Sourcepub fn icon(self, icon: impl IntoElement) -> Self
pub fn icon(self, icon: impl IntoElement) -> Self
Adds a decorative icon above the dialog title.
Sourcepub fn title_content(self, title: impl IntoElement) -> Self
pub fn title_content(self, title: impl IntoElement) -> Self
Replaces the visual heading, keeping the constructor’s accessible name.
Sourcepub fn show_title(self, show: bool) -> Self
pub fn show_title(self, show: bool) -> Self
Shows or hides the visible title while preserving the accessible dialog name.
Sourcepub fn description(self, description: impl Into<SharedString>) -> Self
pub fn description(self, description: impl Into<SharedString>) -> Self
Sets the supporting text displayed beneath the dialog title.
Sourcepub fn body(self, body: impl IntoElement) -> Self
pub fn body(self, body: impl IntoElement) -> Self
Sets custom body content rendered inside the dialog’s scrollable body region.
Sourcepub fn body_content<E: IntoElement>(
self,
body: impl FnOnce(DialogAction, DialogAction) -> E + 'static,
) -> Self
pub fn body_content<E: IntoElement>( self, body: impl FnOnce(DialogAction, DialogAction) -> E + 'static, ) -> Self
Builds the body with the confirmation and cancellation activation handles.
Sourcepub fn confirm(
self,
label: impl Into<SharedString>,
action: impl Fn(&mut Window, &mut App) -> bool + 'static,
) -> Self
pub fn confirm( self, label: impl Into<SharedString>, action: impl Fn(&mut Window, &mut App) -> bool + 'static, ) -> Self
Sets the default action and validation. Returning false keeps the dialog open.
Sourcepub fn on_confirm(
self,
label: impl Into<SharedString>,
action: impl Fn(&mut Window, &mut App) + 'static,
) -> Self
pub fn on_confirm( self, label: impl Into<SharedString>, action: impl Fn(&mut Window, &mut App) + 'static, ) -> Self
Sets a non-validating confirmation action that always closes the dialog after running.
Sourcepub fn confirm_tone(self, tone: SemanticTone) -> Self
pub fn confirm_tone(self, tone: SemanticTone) -> Self
Applies a Material 3 semantic tone to the default confirmation button.
Sourcepub fn confirm_disabled(self, disabled: bool) -> Self
pub fn confirm_disabled(self, disabled: bool) -> Self
Disables the default confirmation button and suppresses Enter confirmation.
Sourcepub fn confirm_loading(self, loading: bool) -> Self
pub fn confirm_loading(self, loading: bool) -> Self
Shows an inline busy spinner on the default confirmation button and suppresses Enter confirmation.
Sourcepub fn confirm_content<E: IntoElement>(
self,
content: impl FnOnce(DialogAction) -> E + 'static,
) -> Self
pub fn confirm_content<E: IntoElement>( self, content: impl FnOnce(DialogAction) -> E + 'static, ) -> Self
Builds a custom confirmation control. Wire its activation to the supplied action.
Sourcepub fn dismiss_content<E: IntoElement>(
self,
content: impl FnOnce(DialogAction) -> E + 'static,
) -> Self
pub fn dismiss_content<E: IntoElement>( self, content: impl FnOnce(DialogAction) -> E + 'static, ) -> Self
Builds a custom cancellation control. Wire its activation to the supplied action.
Sourcepub fn cancel_label(self, label: impl Into<SharedString>) -> Self
pub fn cancel_label(self, label: impl Into<SharedString>) -> Self
Overrides the label of the default cancellation button (defaults to
gpui_material_theme::MaterialStrings::cancel, "Cancel").
Sourcepub fn show_cancel(self, show: bool) -> Self
pub fn show_cancel(self, show: bool) -> Self
Sets whether to include a default cancellation control when there is no custom one.
Sourcepub fn layer(self, layer: usize) -> Self
pub fn layer(self, layer: usize) -> Self
Set a higher layer for a nested modal. Only the top modal can receive input.
Sourcepub fn properties(self, properties: DialogProperties) -> Self
pub fn properties(self, properties: DialogProperties) -> Self
Configures Escape and outside-click dismissal behavior.
Sourcepub fn on_dismiss_request(
self,
request: impl Fn(DialogCloseReason, &mut Window, &mut App) -> bool + 'static,
) -> Self
pub fn on_dismiss_request( self, request: impl Fn(DialogCloseReason, &mut Window, &mut App) -> bool + 'static, ) -> Self
Handles Escape, outside-click, and system window-close requests. Return false to veto.
Sourcepub fn on_closed(
self,
close: impl Fn(DialogCloseReason, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_closed( self, close: impl Fn(DialogCloseReason, &mut Window, &mut App) + 'static, ) -> Self
Reports one accepted user close after the visibility state has changed.
Sourcepub fn shape(self, shape: CornerShape) -> Self
pub fn shape(self, shape: CornerShape) -> Self
Overrides the corner shape of the dialog surface.
Sourcepub fn colors(self, colors: DialogColors) -> Self
pub fn colors(self, colors: DialogColors) -> Self
Overrides the dialog’s container, icon, title, and text colors.
Sourcepub fn tonal_elevation(self, elevation: Elevation) -> Self
pub fn tonal_elevation(self, elevation: Elevation) -> Self
Selects a tonal Material surface when the container color uses the theme.
Sourcepub fn shadow_elevation(self, elevation: Elevation) -> Self
pub fn shadow_elevation(self, elevation: Elevation) -> Self
Overrides the shadow elevation cast by the dialog surface.
Sourcepub fn scrim_color(self, color: Hsla) -> Self
pub fn scrim_color(self, color: Hsla) -> Self
Overrides the backdrop scrim color.
Sourcepub fn scrim_opacity(self, opacity: f32) -> Self
pub fn scrim_opacity(self, opacity: f32) -> Self
Sets in-window backdrop opacity, clamped to 0–1. NaN uses the default.
Trait Implementations§
Source§impl IntoElement for Dialog
impl IntoElement for Dialog
Source§type Element = ViewElement<Dialog>
type Element = ViewElement<Dialog>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Dialog
impl RenderOnce for Dialog
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Dialog
impl !Send for Dialog
impl !Sync for Dialog
impl !UnwindSafe for Dialog
impl Forget for Dialog
impl Freeze for Dialogwhere
NonZero<u32>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const ArcInner<Path> is !null: Freeze,
PhantomData<ArcInner<Path>>: Freeze,
*const str is !null: Freeze,
PhantomData<&'static str>: Freeze,
*const ArcInner<ElementId> is !null: Freeze,
PhantomData<ArcInner<ElementId>>: Freeze,
*const (): Freeze,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Freeze,
PhantomData<fn(DialogState) -> DialogState>: Freeze,
*mut dyn ElementObject: Freeze,
*const RcInner<Cell<bool>> is !null: Freeze,
PhantomData<RcInner<Cell<bool>>>: Freeze,
*const dyn FnOnce(DialogAction, DialogAction) -> AnyElement is !null: Freeze,
PhantomData<dyn FnOnce(DialogAction, DialogAction) -> AnyElement>: Freeze,
*const RcInner<dyn Fn(&mut Window, &mut App) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut Window, &mut App) -> bool>>: Freeze,
*const dyn FnOnce(DialogAction) -> AnyElement is !null: Freeze,
PhantomData<dyn FnOnce(DialogAction) -> AnyElement>: Freeze,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool>>: Freeze,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)>>: Freeze,
impl Move for Dialog
impl Unpin for Dialogwhere
NonZero<u32>: Unpin,
&'static str: Unpin,
Arc<str>: Unpin,
Arc<Path>: Unpin,
*const str is !null: Unpin,
Arc<ElementId>: Unpin,
*const (): Unpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Unpin,
*mut dyn ElementObject: Unpin,
Rc<Cell<bool>>: Unpin,
Box<dyn FnOnce(DialogAction, DialogAction) -> AnyElement>: Unpin,
Rc<dyn Fn(&mut Window, &mut App) -> bool>: Unpin,
Box<dyn FnOnce(DialogAction) -> AnyElement>: Unpin,
Rc<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool>: Unpin,
Rc<dyn Fn(DialogCloseReason, &mut Window, &mut App)>: Unpin,
impl UnsafeUnpin for Dialogwhere
NonZeroU32Inner: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const ArcInner<Path> is !null: UnsafeUnpin,
PhantomData<ArcInner<Path>>: UnsafeUnpin,
*const str is !null: UnsafeUnpin,
PhantomData<&'static str>: UnsafeUnpin,
*const ArcInner<ElementId> is !null: UnsafeUnpin,
PhantomData<ArcInner<ElementId>>: UnsafeUnpin,
*const (): UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: UnsafeUnpin,
PhantomData<fn(DialogState) -> DialogState>: UnsafeUnpin,
*mut dyn ElementObject: UnsafeUnpin,
*const RcInner<Cell<bool>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<bool>>>: UnsafeUnpin,
*const dyn FnOnce(DialogAction, DialogAction) -> AnyElement is !null: UnsafeUnpin,
PhantomData<dyn FnOnce(DialogAction, DialogAction) -> AnyElement>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut Window, &mut App) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut Window, &mut App) -> bool>>: UnsafeUnpin,
*const dyn FnOnce(DialogAction) -> AnyElement is !null: UnsafeUnpin,
PhantomData<dyn FnOnce(DialogAction) -> AnyElement>: UnsafeUnpin,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool>>: UnsafeUnpin,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(
self,
text: impl Into<SharedString>,
) -> ObservedText<Self::Element>
fn test_alt_text( self, text: impl Into<SharedString>, ) -> ObservedText<Self::Element>
Self::test_text for an image’s alternative text, which
stands in for what the element draws.