Skip to main content

Drawer

Struct Drawer 

Source
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>

Source

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.

Source

pub fn side(self, side: DrawerSide) -> Self

Anchor the drawer to the left or right edge. Default: DrawerSide::Right.

Source

pub fn width(self, width: f32) -> Self

Set the panel width in points. Default: 420. Clamped to at least 120.

Source

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.

Source

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.

Source

pub fn close_on_backdrop(self, close: bool) -> Self

Whether clicking the dimmed backdrop dismisses the drawer. Default: true.

Source

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

Whether pressing Esc dismisses the drawer. Default: true.

Source

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.

Trait Implementations§

Source§

impl<'a> Debug for Drawer<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Drawer<'a>

§

impl<'a> RefUnwindSafe for Drawer<'a>

§

impl<'a> Send for Drawer<'a>

§

impl<'a> Sync for Drawer<'a>

§

impl<'a> Unpin for Drawer<'a>

§

impl<'a> UnsafeUnpin for Drawer<'a>

§

impl<'a> !UnwindSafe for Drawer<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.