pub struct Layers<'a, M> { /* private fields */ }Expand description
A base component with Layers over it (#480): modal dialogs and
popovers. The top layer takes the keys; a modal also traps focus (Tab
cycles inside it) and dims the base. Escape dismisses the top layer when
the layer does not use it, and a layer that cancels is dismissed rather
than cancelling the host. With no layer open, the host is its base.
Implementations§
Source§impl<'a, M> Layers<'a, M>
impl<'a, M> Layers<'a, M>
pub fn new(base: impl Component<Output = M> + 'a) -> Layers<'a, M>
Sourcepub fn handle(&self) -> LayerHandle<'a, M>
pub fn handle(&self) -> LayerHandle<'a, M>
A handle that opens and closes layers here.
Sourcepub fn open_on(
self,
action: &str,
keys: impl IntoIterator<Item = Key>,
description: &str,
layer: impl FnMut() -> Layer<'a, M> + 'a,
) -> Selfwhere
M: 'a,
pub fn open_on(
self,
action: &str,
keys: impl IntoIterator<Item = Key>,
description: &str,
layer: impl FnMut() -> Layer<'a, M> + 'a,
) -> Selfwhere
M: 'a,
Open a layer made by layer when one of keys reaches the host
unused, with no layer open: a help dialog on ?, a palette on
Ctrl+P.
Sourcepub fn backdrop_style(self, style: Style) -> Self
pub fn backdrop_style(self, style: Style) -> Self
The style put over the base under a modal (default: dim).
Sourcepub fn border_style(self, style: Style) -> Self
pub fn border_style(self, style: Style) -> Self
The style of a layer’s border (default: none).
Sourcepub fn on(
self,
action: &str,
keys: impl IntoIterator<Item = Key>,
description: &str,
handler: impl FnMut() -> Flow<M> + 'a,
) -> Self
pub fn on( self, action: &str, keys: impl IntoIterator<Item = Key>, description: &str, handler: impl FnMut() -> Flow<M> + 'a, ) -> Self
Run handler when one of keys bubbles up unused by the
focused child: an action of yours, listed in the keymap under
this container’s context.
Sourcepub fn shortcut(
self,
action: &str,
keys: impl IntoIterator<Item = Key>,
description: &str,
handler: impl FnMut() -> Flow<M> + 'a,
) -> Self
pub fn shortcut( self, action: &str, keys: impl IntoIterator<Item = Key>, description: &str, handler: impl FnMut() -> Flow<M> + 'a, ) -> Self
Run handler when one of keys is pressed, before the focused
child sees it.
Sourcepub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
pub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
Make keys do this container’s action (focus-next, and the
container’s own); no keys unbinds it.
Sourcepub fn own_keymap(&self) -> &Keymap
pub fn own_keymap(&self) -> &Keymap
This container’s own bindings, without its children’s.
Sourcepub fn with_mouse(self, on: bool) -> Self
pub fn with_mouse(self, on: bool) -> Self
Report the mouse even when no child asks for it: for a click to focus a child, or a border to drag.
pub fn base(&self) -> &(dyn Component<Output = M> + 'a)
pub fn base_mut(&mut self) -> &mut (dyn Component<Output = M> + 'a)
Trait Implementations§
Source§impl<M> Component for Layers<'_, M>
impl<M> Component for Layers<'_, M>
type Output = M
Source§fn start(&mut self, context: &Context<'_>) -> Flow<M>
fn start(&mut self, context: &Context<'_>) -> Flow<M>
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<M>
fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<M>
Outcome::Interrupted.Source§fn tick(&self) -> Option<Duration>
fn tick(&self) -> Option<Duration>
Event::Tick, for a spinner or a
countdown. None (the default): never.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
run then enables mouse reporting
for the session.Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn focusable(&self) -> bool
fn focusable(&self) -> bool
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
forward) or previous focus stop inside
this component, for Tab and Shift+Tab. false when there is none
after the current one, so the container moves on to its next
child. The default, for a component that is one stop: false.Source§fn focus_enter(&mut self, forward: bool) -> bool
fn focus_enter(&mut self, forward: bool) -> bool
forward,
at the last otherwise. false when nothing in it can take focus.
The default: whether the component is focusable.Source§fn default_value(&self) -> Option<M>
fn default_value(&self) -> Option<M>
None: there is none.Auto Trait Implementations§
impl<'a, M> !RefUnwindSafe for Layers<'a, M>
impl<'a, M> !Send for Layers<'a, M>
impl<'a, M> !Sync for Layers<'a, M>
impl<'a, M> !UnwindSafe for Layers<'a, M>
impl<'a, M> Freeze for Layers<'a, M>
impl<'a, M> Unpin for Layers<'a, M>
impl<'a, M> UnsafeUnpin for Layers<'a, M>where
Box<dyn Component<Output = M> + 'a>: UnsafeUnpin,
Vec<Layer<'a, M>>: UnsafeUnpin,
Rc<RefCell<Vec<Request<'a, M>>>>: UnsafeUnpin,
Bindings<'a, M>: 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<C> ComponentExt for Cwhere
C: Component,
impl<C> ComponentExt for Cwhere
C: Component,
Source§fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
M’s flow: Flow::Done(m) to
finish the whole composition with m, Flow::Continue to carry on
(the component stays, showing its answer, and focus moves past it).
Cancelling cancels the composition unless
on_cancel says otherwise.