pub struct Drawer<'a> { /* private fields */ }Expand description
A side-anchored slide-in overlay panel.
The open flag drives visibility. While it transitions from false to
true the panel slides in from its anchored edge; the reverse plays in
reverse. Pressing Esc, clicking the dimmed backdrop, or clicking the
built-in close “×” button flips it back to false.
Implementations§
Source§impl<'a> Drawer<'a>
impl<'a> Drawer<'a>
Sourcepub fn new(id_salt: impl Hash, open: &'a mut bool) -> Self
pub fn new(id_salt: impl Hash, open: &'a mut bool) -> Self
Create a drawer keyed by id_salt whose visibility is bound to open.
Defaults: anchored to the right, 420 pt wide, no title, dismisses on
Esc and backdrop click.
Sourcepub fn side(self, side: DrawerSide) -> Self
pub fn side(self, side: DrawerSide) -> Self
Anchor the drawer to the left or right edge. Default: DrawerSide::Right.
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Set the panel width in points. Default: 420. Clamped to at least 120.
Sourcepub fn title(self, title: impl Into<WidgetText>) -> Self
pub fn title(self, title: impl Into<WidgetText>) -> Self
Show a strong title at the top of the drawer, alongside the close “×” button. When unset, no automatic chrome is rendered and the body closure receives the full panel area.
Sourcepub fn subtitle(self, subtitle: impl Into<WidgetText>) -> Self
pub fn subtitle(self, subtitle: impl Into<WidgetText>) -> Self
Show a muted subtitle line below the title. Has no effect when
Drawer::title is unset.
Sourcepub fn close_on_backdrop(self, close: bool) -> Self
pub fn close_on_backdrop(self, close: bool) -> Self
Whether clicking the dimmed backdrop dismisses the drawer. Default: true.
Sourcepub fn close_on_escape(self, close: bool) -> Self
pub fn close_on_escape(self, close: bool) -> Self
Whether pressing Esc dismisses the drawer. Default: true.
Sourcepub fn show<R>(
self,
ctx: &Context,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<R>
pub fn show<R>( self, ctx: &Context, add_contents: impl FnOnce(&mut Ui) -> R, ) -> Option<R>
Render the drawer. Returns None while the drawer is fully closed
(off-screen and not animating); otherwise Some(R) with the body
closure’s return value.
The closure is invoked every frame the panel is on-screen, including
while it slides in or out. Treat the body as ordinary layout — the
slide animation is applied by translating the parent Area.