pub struct Modal {
title: String,
min_width: Option<f32>,
min_height: Option<f32>,
default_height: Option<f32>,
full_span_content: bool,
}
Expand description
Show a modal window with Rerun style.
Modal
fakes as a modal window, since egui doesn’t have them yet.
This done by dimming the background and capturing clicks outside the window.
The positioning of the modal is as follows:
┌─rerun window─────▲─────────────────────┐
│ │ 75px / 10% │
│ ╔═modal═▼══════════╗ ▲ │
│ ║ ▲ ║ │ │
│ ║ actual height │ ║ │ │
│ ║ based on │ ║ │ max │
│ ║ content │ ║ │ height│
│ ║ │ ║ │ │
│ ║ ▼ ║ │ │
│ ╚══════════════════╝ │ │
│ │ │ │ │
│ └───────▲──────────┘ ▼ │
│ │ 75px / 10% │
└──────────────────▼─────────────────────┘
The modal sets the clip rect such as to allow full-span highlighting behavior (e.g. with
crate::list_item::ListItem
). Consider using crate::UiExt::full_span_separator
to draw a
separator that spans the full width of the modal instead of the usual [egui::Ui::separator
]
method.
Note that Modal
are typically used via the ModalHandler
helper object to reduce
boilerplate.
Fields§
§title: String
§min_width: Option<f32>
§min_height: Option<f32>
§default_height: Option<f32>
§full_span_content: bool
Implementations§
source§impl Modal
impl Modal
sourcepub fn min_height(self, min_height: f32) -> Self
pub fn min_height(self, min_height: f32) -> Self
Set the minimum height of the modal window.
sourcepub fn default_height(self, default_height: f32) -> Self
pub fn default_height(self, default_height: f32) -> Self
Set the default height of the modal window.
sourcepub fn full_span_content(self, full_span_content: bool) -> Self
pub fn full_span_content(self, full_span_content: bool) -> Self
Configure the content area of the modal for full span highlighting.
This includes:
- setting the vertical spacing to 0.0
- removing any padding at the bottom of the area
In this mode, the user code is responsible for adding spacing between items.
sourcepub fn ui<R>(
&mut self,
ctx: &Context,
content_ui: impl FnOnce(&mut Ui, &mut bool) -> R
) -> ModalResponse<R>
pub fn ui<R>( &mut self, ctx: &Context, content_ui: impl FnOnce(&mut Ui, &mut bool) -> R ) -> ModalResponse<R>
Show the modal window.
Typically called by ModalHandler::ui
.
sourcefn dim_background(ctx: &Context)
fn dim_background(ctx: &Context)
Dim the background to indicate that the window is modal.
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§
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more