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
impl SidebarDrawer
pub fn new() -> 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
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
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
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
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
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
pub fn rail_width(self, px: f64) -> SidebarDrawer
0.0 hides it entirely. An icon rail: ui_scale only.
pub fn closed(self) -> SidebarDrawer
pub fn closed(self) -> SidebarDrawer
A summon-on-demand panel.
pub fn overlay_only(self) -> SidebarDrawer
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
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)
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
pub fn resolved_breakpoint(&self) -> f64
The breakpoint as laid out (text-sized).
pub fn resolved_docked_width(&self) -> f64
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
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
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
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)
pub fn toggle(&mut self)
Flip open/closed and remember the person’s choice for this size class.
pub fn open(&mut self)
pub fn open(&mut self)
Force open (remembering the choice).
pub fn close(&mut self)
pub fn close(&mut self)
Force closed (scrim / Esc / a choice made in the drawer).
pub fn snap(&mut self, open: bool)
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 is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
true while the slide hasn’t settled.
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
pub fn content_rect(&self) -> Rect
The usable area beside/under the drawer.
pub fn scrim_rect(&self) -> Rect
pub fn scrim_rect(&self) -> Rect
Overlay mode only; Rect::ZERO when absent.
pub fn rail_rect(&self) -> Rect
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 header(&mut self, area: Rect, theme: &Theme) -> HeaderRowFace
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
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
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)
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
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,
)
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>
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
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
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
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
pub fn is_resizing(&self) -> bool
Whether the shared divider owns the current pointer drag.
pub fn take_resize_redraw(&mut self) -> bool
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)
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>
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
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>
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)
pub fn paint_resize(&self, scene: &mut Scene, transform: Affine, theme: &Theme)
Paint the existing shared divider using the sidebar’s theme ground.
Whether p is over the drawer panel.
pub fn scrim_contains(&self, p: Point) -> bool
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
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)
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
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
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,
)
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
impl Clone for SidebarDrawer
§fn clone(&self) -> SidebarDrawer
fn clone(&self) -> SidebarDrawer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for SidebarDrawer
impl Debug for SidebarDrawer
§impl Default for SidebarDrawer
impl Default for SidebarDrawer
§fn default() -> SidebarDrawer
fn default() -> SidebarDrawer
Auto Trait Implementations§
impl Freeze for SidebarDrawer
impl RefUnwindSafe for SidebarDrawer
impl Send for SidebarDrawer
impl Sync for SidebarDrawer
impl Unpin for SidebarDrawer
impl UnsafeUnpin for SidebarDrawer
impl UnwindSafe for SidebarDrawer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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