Skip to main content

SidebarDrawer

Struct SidebarDrawer 

pub struct SidebarDrawer { /* private fields */ }
Expand description

A collapsible sidebar or inspector for a painted app. See the module docs.

Implementations§

§

impl SidebarDrawer

pub fn new() -> SidebarDrawer

A leading navigation drawer, open when docked, at the shell metrics.

pub fn side(self, side: SidebarSide) -> SidebarDrawer

pub fn left(self) -> SidebarDrawer

pub fn right(self) -> SidebarDrawer

pub fn breakpoint(self, px: f64) -> SidebarDrawer

Authored at 1× (text-sized); see Self::scale_for.

pub fn content_min_width(self, px: f64) -> SidebarDrawer

Dock only while the content column keeps this authored minimum. The actual sidebar and icon rail widths remain independently scaled.

pub fn docked_width(self, px: f64) -> SidebarDrawer

Docked width of a text-sized drawer (a page or destination list), authored at 1×.

pub fn icon_docked_width(self, px: f64) -> SidebarDrawer

Docked width of an icon rail: follows ui_scale, never the text.

pub fn overlay_width(self, px: f64) -> SidebarDrawer

Overlay width of the text-sized drawer, authored at 1×.

pub fn rail_width(self, px: f64) -> SidebarDrawer

0.0 hides it entirely. An icon rail: ui_scale only.

pub fn closed(self) -> SidebarDrawer

A summon-on-demand panel.

pub fn overlay_only(self) -> SidebarDrawer

A drawer over the content at every width, never docked (controls over full-bleed media: a player’s queue, a viewer’s info).

pub fn with_rail(self) -> SidebarDrawer

An icon rail beside the text list in the one drawer (workspaces beside a workspace’s channels). The rail is metrics.rail_width wide, following ui_scale; the drawer grows by it, and Self::rail_rect and Self::list_rect split the panel.

pub fn set_docked_width(&mut self, px: f64)

pub fn set_breakpoint(&mut self, px: f64)

pub fn scale_for(&mut self, theme: &Theme)

Adopt the theme’s scale so the authored breakpoint and the text-sized widths grow by Theme::responsive_scale, an icon rail by ui_scale (HIG §9.6), and the overlay drawer floats inside the theme’s s2. Call it from the host’s build_layout with the theme it receives. Never called ⇒ authored geometry.

pub fn resolved_breakpoint(&self) -> f64

The breakpoint as laid out (text-sized).

pub fn resolved_docked_width(&self) -> f64

The docked width as laid out (with the rail, where it has one).

pub fn resolved_overlay_width(&self) -> f64

The overlay width as laid out (text-sized, with the rail).

pub fn resolved_rail_width(&self) -> f64

The collapsed rail width as laid out (icon-sized: ui_scale only).

pub fn layout_for(&self, width: f64) -> SplitLayout

Docked at/above the (resolved) breakpoint; always an overlay for Self::overlay_only.

pub fn layout(&self) -> SplitLayout

pub fn is_overlay(&self) -> bool

pub fn is_docked(&self) -> bool

pub fn is_open(&self) -> bool

pub fn toggle(&mut self)

Flip open/closed and remember the person’s choice for this size class.

pub fn open(&mut self)

Force open (remembering the choice).

pub fn close(&mut self)

Force closed (scrim / Esc / a choice made in the drawer).

pub fn snap(&mut self, open: bool)

Snap to open with NO animation — deterministic --shots / tests. Before the first Self::resolve the snap is kept until the layout is known, so it lands in the size class the drawer is shown in.

pub fn reveal(&self) -> f64

The eased reveal in 0..=1 (scrim strength, docked inset).

pub fn is_animating(&self) -> bool

true while the slide hasn’t settled.

pub fn sidebar_rect(&self) -> Rect

The sidebar panel. An overlay drawer floats s2 inside the outer rect; its contents lay out inside this rect.

pub fn content_rect(&self) -> Rect

The usable area beside/under the drawer.

pub fn scrim_rect(&self) -> Rect

Overlay mode only; Rect::ZERO when absent.

pub fn rail_rect(&self) -> Rect

The icon rail inside the panel (Self::with_rail): its leading strip (trailing, for a right drawer), or Rect::ZERO.

pub fn list_rect(&self) -> Rect

The text list inside the panel: the panel beside the rail.

pub fn header(&mut self, area: Rect, theme: &Theme) -> HeaderRowFace

The window’s header row across the top of area, with this drawer’s toggle in it: at the leading corner for a sidebar, the trailing one for an inspector. A floating drawer then opens under the row, which stays live. Paint the toggle with Self::paint_toggle and route events to it with Self::handle_event.

pub fn header_with_history( &mut self, area: Rect, theme: &Theme, history: bool, ) -> HeaderRowFace

Self::header with the window’s History control in the row’s trailing corner (history: the host offered it, crate::widget::HistoryOpener::is_shown).

pub fn toggle_rect(&self) -> Rect

The toggle’s rect in the header row, or Rect::ZERO before Self::header.

pub fn set_platform_conventions(&mut self, conventions: PlatformConventions)

Spell the show/hide shortcut for conventions.

pub fn handle_event( &mut self, event: &WindowEvent, ctx: &mut EventCtx<'_>, ) -> bool

Route event to the drawer’s own parts: the toggle (hover, a press and release on it), HostShortcut::Sidebar for a sidebar, Escape and a press on the scrim for an open floating drawer. Returns whether the drawer took the event; call Self::resolve first so the rects match the last paint.

pub fn paint_toggle( &self, scene: &mut Scene, transform: Affine, text_renderer: &mut TextRenderer, theme: &Theme, )

Paint the toggle at its place in the header row, with the theme of the ground it stands on.

pub fn toggle_accessibility(&self) -> Option<AccessNode>

The toggle’s node in the window’s semantic tree: a button named for what it does (“Show sidebar”), with its shortcut. Route an Activate on it back with Self::perform_toggle_action.

pub fn perform_toggle_action( &mut self, action: &Action, key_path: &[u64], ) -> bool

Toggle from the toggle’s node (key_path from Widget::perform_action); returns whether it did.

pub fn tick(&mut self, theme: &Theme) -> bool

Advance the eased reveal off a real wall-clock delta over the theme’s motion.durations.base. Call once per draw. Under reduced motion the reveal jumps to its target. The first tick establishes the clock (dt == 0); later deltas are clamped to MAX_FRAME_DT. Returns whether it is still animating.

pub fn resolve(&mut self, outer: Rect) -> Rect

Resolve the docked-vs-overlay layout + all rects for outer. Cheap and deterministic (no clock); call from both the draw and event paths. Returns the content rect.

pub fn is_resizing(&self) -> bool

Whether the shared divider owns the current pointer drag.

pub fn take_resize_redraw(&mut self) -> bool

Hover changes request a repaint without consuming pointer motion.

pub fn set_resize_focused(&mut self, focused: bool)

Follow the painted host’s focus without retaining a stale keyboard owner.

pub fn resize_accessibility(&self) -> Option<AccessNode>

The shared separator’s semantic door, available for a docked panel.

pub fn perform_resize_action(&mut self, target: &str, action: &Action) -> bool

Route the separator’s ordinary accessibility/semantic action.

pub fn resize_cursor(&self, point: Point) -> Option<CursorIcon>

The shared resize cursor for a docked sidebar or captured drag.

pub fn paint_resize(&self, scene: &mut Scene, transform: Affine, theme: &Theme)

Paint the existing shared divider using the sidebar’s theme ground.

pub fn sidebar_contains(&self, p: Point) -> bool

Whether p is over the drawer panel.

pub fn scrim_contains(&self, p: Point) -> bool

Whether p landed on the dismiss scrim of an open overlay drawer.

pub fn press_dismisses(&mut self, p: Point) -> bool

If p dismisses an open overlay drawer (a scrim tap), close it and report true.

pub fn draw_scrim(&self, scene: &mut Scene, transform: Affine, theme: &Theme)

Paint the scrim behind an open overlay drawer (surfaces.scrim at the one scrim strength, following the reveal). Call after the content is drawn and before Self::paint_panel. No-op when docked.

pub fn paint_panel( &self, scene: &mut Scene, transform: Affine, theme: &Theme, ) -> Theme

Paint the panel the drawer’s contents stand on and return the theme to draw them with. Docked, it is the window region (Region::Sidebar, or Region::Inspector for a trailing drawer) with no radius and no shadow; as an overlay it is the floating material with the panel radius and the floating shadow.

pub fn paint_panel_in( scene: &mut Scene, transform: Affine, rect: Rect, theme: &Theme, ) -> Theme

Paint the floating drawer panel at rect for a host that lays its panel out itself (a timeline’s bin over the canvas): the floating material, radii.panel and the floating shadow, as an open overlay drawer. Returns the theme to draw the panel’s contents with.

pub fn draw_toggle( &self, scene: &mut Scene, transform: Affine, text_renderer: &mut TextRenderer, theme: &Theme, rect: Rect, hovered: bool, )

Paint the show/hide control inside rect: the same Plain icon button NavShell draws (Icon::PanelLeft, or PanelRight for a trailing drawer), transparent at rest and lifted under the pointer. Draw it with the theme of the ground it stands on.

Trait Implementations§

§

impl Clone for SidebarDrawer

§

fn clone(&self) -> SidebarDrawer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for SidebarDrawer

§

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

Formats the value using the given formatter. Read more
§

impl Default for SidebarDrawer

§

fn default() -> SidebarDrawer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

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

§

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

§

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,