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 sheet_when_narrow(self) -> SidebarDrawer
pub fn sheet_when_narrow(self) -> SidebarDrawer
Too narrow to dock, the inspector rises as a sheet from the window’s
foot instead of floating beside the content: the content above it
stays live (a press there is the content’s, it puts nothing away)
and keeps the part the sheet rests on clear (Self::content_rect).
For a trailing drawer; a sidebar keeps its own narrow form.
pub fn rises_as_sheet(&self) -> bool
pub fn rises_as_sheet(&self) -> bool
Whether the drawer is a sheet now: narrow, and asked to be one.
pub fn sheet(&self) -> Option<&BottomSheet>
pub fn sheet(&self) -> Option<&BottomSheet>
The sheet while the drawer is one.
pub fn sheet_detent(&self) -> Option<SheetDetent>
pub fn sheet_detent(&self) -> Option<SheetDetent>
Where the sheet rests, while the drawer is one.
pub fn snap_sheet(&mut self, detent: SheetDetent)
pub fn snap_sheet(&mut self, detent: SheetDetent)
Rest the sheet at detent at once (a capture, a test).
pub fn lower_sheet(&mut self, motion: EffectiveMotion) -> bool
pub fn lower_sheet(&mut self, motion: EffectiveMotion) -> bool
Back’s step on the sheet while it shows (BottomSheet::lower):
from the whole window it comes down to half and this returns true;
otherwise false, and the holder puts the drawer away.
pub fn handle_sheet_event(
&mut self,
event: &WindowEvent,
ctx: &EventCtx<'_>,
motion: EffectiveMotion,
) -> SheetInput
pub fn handle_sheet_event( &mut self, event: &WindowEvent, ctx: &EventCtx<'_>, motion: EffectiveMotion, ) -> SheetInput
The sheet’s own events (a drag or press on its grip, the arrow keys
on it), while it shows; call Self::resolve first.
pub fn sheet_target(&self) -> &'static str
pub fn sheet_target(&self) -> &'static str
What routes the sheet’s actions back (Self::perform_sheet_action).
pub fn sheet_accessibility(&self, name: &str) -> Option<AccessNode>
pub fn sheet_accessibility(&self, name: &str) -> Option<AccessNode>
The sheet as a region named name, its grip a slider holding the
detent; None unless it shows.
pub fn perform_sheet_action(
&mut self,
target: &str,
action: &Action,
motion: EffectiveMotion,
) -> bool
pub fn perform_sheet_action( &mut self, target: &str, action: &Action, motion: EffectiveMotion, ) -> bool
Carry out action on the sheet’s grip, when target is it.
§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
An authored dock width instead of the panel’s own width beside the
content’s minimum (Self::content_min_width). Prefer stating what
the content is: a threshold written down beside the panel’s width and
the content it stands beside goes stale the moment either moves.
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 docked panel shrinks toward its minimum width first. The actual sidebar and icon rail widths remain independently scaled.
pub fn content_kind(self, kind: ContentKind) -> SidebarDrawer
pub fn content_kind(self, kind: ContentKind) -> SidebarDrawer
Dock while the content keeps the minimum its kind needs
(crate::widget::ContentKind), as NavShell does. Narrower, the
panel floats as a drawer over the content (Self::is_overlay): a
panel that states no content kind never takes the window over as a
screen of its own. Content that cannot spare the width for a drawer
over it (crate::widget::ContentKind::List) keeps the panel on the
push layout instead (Self::is_push, Self::with_push).
pub fn content_is_column(self, min_width: f64) -> SidebarDrawer
pub fn content_is_column(self, min_width: f64) -> SidebarDrawer
The content is a column in its own right — a page or a cheatsheet a
person keeps in view beside the panel — so the panel docks while it
fits beside that column at its own width (Self::panel_min_width),
and floats over it below that. The column then pans out of view
rather than becoming a phone width to make room for the panel.
pub fn panel_min_width(self, px: f64) -> SidebarDrawer
pub fn panel_min_width(self, px: f64) -> SidebarDrawer
The narrowest the docked panel shrinks to beside the content before
it floats: the panel’s own minimum (metrics.panel_min_width) unless
it states another. Each panel is authored at 1×; the resolved width
follows Theme::responsive_scale like every other text-sized one.
pub fn with_push(self) -> SidebarDrawer
pub fn with_push(self) -> SidebarDrawer
Too narrow to dock, the panel takes turns with the content as the
first screen of the window (the push layout, Self::is_push)
rather than floating over it: for content a drawer would cover, such
as a list of rows.
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 rail_labels(
&mut self,
labels: impl IntoIterator<Item = impl Into<String>>,
)
pub fn rail_labels( &mut self, labels: impl IntoIterator<Item = impl Into<String>>, )
The rail’s destination captions: the rail grows with the text, up to
its cap, so its longest word shows whole rather than as a fragment
(crate::chrome::rail_width_fitting). Takes effect at the next
Self::scale_for.
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): with a content minimum, the panel at its narrowest beside that minimum.
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_push(&self) -> bool
pub fn is_push(&self) -> bool
Too narrow to dock, a panel that asked for the push layout
(Self::with_push, or content of a kind that keeps it) takes turns
with the content: open, the panel fills the window under the header
row as the sidebar region (no float, no shadow); closed, the content
does. It is still the overlay size class (Self::is_overlay): a
choice in the list closes it, and narrowing lands on the content.
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
The content beside an open overlay drawer, where a press dismisses
it (nothing is painted there); 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 reveal on the standard panel slide
(FlapState::advance). Call once per draw. Under reduced motion the
reveal lands at once. 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.
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 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, and so is a push screen
(Self::is_push); as a floating drawer 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> 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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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