pub struct WidgetDock<Msg> { /* private fields */ }Expand description
A vertical stack of titled widgets filling the area it is given, like the side panel of an IDE: each widget opens and closes, and open widgets share the height between them.
Add one child per widget with View::add_with, in the
order they are shown. A widget that wants less than its share keeps its natural height; a
taller one, such as a List, gets an even share of what is left and scrolls
inside it. The application owns the order and the open state, so both can be saved and
restored: WidgetDock::on_toggle and WidgetDock::on_move report changes.
With on_move, dragging a title picks the widget up: its title follows the pointer as a
ghost and a tinted row shows where it will land. Keys while focused: ↑/↓, Home/End move
between titles, Enter or Space opens or closes, Ctrl+Shift+↑/↓ moves the widget.
Style keys are those of Accordion plus section-title.ghost for the
dragged title, section-drop (bg) for the landing row and section-empty (fg).
Implementations§
Source§impl<Msg: 'static> WidgetDock<Msg>
impl<Msg: 'static> WidgetDock<Msg>
Sourcepub fn new(sections: impl IntoIterator<Item = impl Into<Section>>) -> Self
pub fn new(sections: impl IntoIterator<Item = impl Into<Section>>) -> Self
A dock of sections in this order, all closed.
Sourcepub fn open(self, open: impl IntoIterator<Item = bool>) -> Self
pub fn open(self, open: impl IntoIterator<Item = bool>) -> Self
Which widgets are open; open[i] for widget i, missing entries are closed.
Sourcepub fn on_toggle(self, message: impl Fn(usize, bool) -> Msg + 'static) -> Self
pub fn on_toggle(self, message: impl Fn(usize, bool) -> Msg + 'static) -> Self
Message for opening (true) or closing (false) widget index.
Sourcepub fn on_move(self, message: impl Fn(usize, usize) -> Msg + 'static) -> Self
pub fn on_move(self, message: impl Fn(usize, usize) -> Msg + 'static) -> Self
Lets the user reorder widgets. The message carries the widget’s index and the index it
should have afterwards: remove it at from, then insert it at to.
Sourcepub fn empty_text(self, text: impl Into<String>) -> Self
pub fn empty_text(self, text: impl Into<String>) -> Self
Text shown when the dock has no widgets.
Trait Implementations§
Source§impl<Msg: 'static> Container<Msg> for WidgetDock<Msg>
impl<Msg: 'static> Container<Msg> for WidgetDock<Msg>
Source§fn set_children(&mut self, children: Vec<Node<Msg>>)
fn set_children(&mut self, children: Vec<Node<Msg>>)
Source§impl<Msg: 'static> Widget<Msg> for WidgetDock<Msg>
impl<Msg: 'static> Widget<Msg> for WidgetDock<Msg>
Source§fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Source§fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for WidgetDock<Msg>
impl<Msg> !Send for WidgetDock<Msg>
impl<Msg> !Sync for WidgetDock<Msg>
impl<Msg> !UnwindSafe for WidgetDock<Msg>
impl<Msg> Freeze for WidgetDock<Msg>where
Sections<Msg>: Freeze,
impl<Msg> Unpin for WidgetDock<Msg>where
Sections<Msg>: Unpin,
impl<Msg> UnsafeUnpin for WidgetDock<Msg>where
Sections<Msg>: 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