pub struct SidePanel<'a, Msg> { /* private fields */ }Expand description
A panel docked to the left or right of a body, on its own surface.
The application owns whether the panel is open, how wide it is and which view it shows. The plain panel is just a surface next to the body; capabilities are opt-in:
SidePanel::on_togglemakes the edge between panel and body interactive. The edge is a tone difference, never a line: on hover it brightens one step and a two-cell toggle appears at its middle, a‹or›on a raised surface reaching one cell into the body. Pointing at the toggle raises it a step more and shows the pillar▌in its first cell, pressing it raises it one more; clicking toggles. Tab reaches the edge and shows the same toggle, where Enter or Space toggles, and the global actiontoggle-panel(alt+bby default) toggles from anywhere inside the panel or the body. Opening and closing slide over twicemotion.enter. Dragging a closed edge half the minimum width into the body opens the panel.SidePanel::on_resizelets the edge be dragged, and moved with ←/→ while focused, withinSidePanel::limits.SidePanel::stripadds an activity bar: a column of view icons at the outer edge, beside the open panel and left behind when it collapses.SidePanel::active_viewmarks the shown view’s icon, raised with the pillar. Clicking another icon switches to its view (opening the panel if it is closed); clicking the shown view’s icon closes the panel. Tab reaches the strip, where ↑/↓ move and Enter or Space act like a click.SidePanel::closedchooses what closing leaves: the strip (Closed::Collapse, the default) or only an invisible edge column (Closed::Hide).
Style keys: side-panel (bg), side-strip (bg), side-strip-item (fg, bg, pillar)
with hover, selected, focus and pressed, split-handle for the edge and side-toggle
(bg, fg, pillar) with hover, focus and pressed for the toggle. Icons: edge-left,
edge-right.
Implementations§
Source§impl<'a, Msg: 'static> SidePanel<'a, Msg>
impl<'a, Msg: 'static> SidePanel<'a, Msg>
Sourcepub fn closed(self, closed: Closed) -> Self
pub fn closed(self, closed: Closed) -> Self
What closing leaves behind: Closed::Collapse (the default) keeps the icon strip,
Closed::Hide hides the strip too and leaves only the edge column.
Sourcepub fn on_toggle(self, message: impl Fn(bool) -> Msg + 'static) -> Self
pub fn on_toggle(self, message: impl Fn(bool) -> Msg + 'static) -> Self
Makes the edge toggle the panel; the message carries the new open state.
Sourcepub fn on_resize(self, message: impl Fn(u16) -> Msg + 'static) -> Self
pub fn on_resize(self, message: impl Fn(u16) -> Msg + 'static) -> Self
Makes the edge resize the panel; the message carries the new width within the limits.
Sourcepub fn limits(self, min: u16, max: impl Into<Option<u16>>) -> Self
pub fn limits(self, min: u16, max: impl Into<Option<u16>>) -> Self
The narrowest and widest the panel can be, in columns: limits(18, 48) for a range, or
limits(18, None) for no upper limit. By default 8 and no upper limit; whatever the
limits, the body keeps at least a quarter of the area. A max below min counts as min.
Sourcepub fn strip(
self,
icons: impl IntoIterator<Item = impl Into<String>>,
message: impl Fn(u16) -> Msg + 'static,
) -> Self
pub fn strip( self, icons: impl IntoIterator<Item = impl Into<String>>, message: impl Fn(u16) -> Msg + 'static, ) -> Self
Adds an activity bar of these view icons at the outer edge. Clicking an icon sends its
index, meaning “show this view”: set the view and open the panel in update. The icon of
the active_view instead closes the open panel through
on_toggle.
Sourcepub fn active_view(self, index: u16) -> Self
pub fn active_view(self, index: u16) -> Self
The index of the strip icon whose view the panel shows; it is raised with the pillar while the panel is open.
Auto Trait Implementations§
impl<'a, Msg> !RefUnwindSafe for SidePanel<'a, Msg>
impl<'a, Msg> !Send for SidePanel<'a, Msg>
impl<'a, Msg> !Sync for SidePanel<'a, Msg>
impl<'a, Msg> !UnwindSafe for SidePanel<'a, Msg>
impl<'a, Msg> Freeze for SidePanel<'a, Msg>
impl<'a, Msg> Unpin for SidePanel<'a, Msg>
impl<'a, Msg> UnsafeUnpin for SidePanel<'a, Msg>where
Option<Rc<dyn Fn(bool) -> Msg>>: UnsafeUnpin,
Option<Box<dyn Fn(u16) -> Msg>>: UnsafeUnpin,
Option<Rc<dyn Fn(u16) -> Msg>>: UnsafeUnpin,
Option<Box<dyn FnOnce(&mut View<'_, Msg>) + 'a>>: UnsafeUnpin,
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> 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