pub struct DockArea { /* private fields */ }Expand description
Panels in a tree of splits and groups of tabs, at the left, the right, the bottom and the center of a space. Bars between them resize with the pointer or the keyboard, docks collapse from the strips on their edges, and panels close and come back.
A tab goes anywhere with a drag, with the target marked: to another group, to one side of a group, or to a border that has no dock showing. Without a pointer, the arrows walk between tabs, Alt with an arrow moves one within its group, Alt and Shift with an arrow send it to a dock, the menu of a tab or of the button at the end of the strip has “Move to…”, and Delete closes.
The arrangement is a DockLayout in a Binding, which holds ids alone and can be saved as
text. What a panel shows is asked from the app, by id, for the panel at the front of each group:
that is all a change of tab builds, and what a panel must remember while behind others belongs in
the app. An id in the arrangement with no DockPanel is left out.
use ravenrs_reactive::State;
use ravenrs_widgets::{AnyView, DockArea, DockLayout, DockNode, DockPanel, Text, Ui};
let saved = None::<String>; // What the app kept the last time.
let start = DockLayout::new()
.center(DockNode::tabs(["photo"]))
.left(DockNode::tabs(["folders", "search"]), 240.0);
let layout = State::new(saved.and_then(|text| DockLayout::parse(&text).ok()).unwrap_or(start));
let area = DockArea::new(
layout.binding(),
vec![
DockPanel::new("photo", "Photo").closable(false),
DockPanel::new("folders", "Folders"),
DockPanel::new("search", "Search"),
],
|id| -> AnyView { Box::new(Text::new(format!("Panel {id}"))) },
)
.on_end(|now| println!("{}", now.to_text()));
let mut ui = Ui::new(area, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl DockArea
impl DockArea
Sourcepub fn new(
layout: Binding<DockLayout>,
panels: Vec<DockPanel>,
content: impl Fn(&str) -> Box<dyn View> + 'static,
) -> DockArea
pub fn new( layout: Binding<DockLayout>, panels: Vec<DockPanel>, content: impl Fn(&str) -> Box<dyn View> + 'static, ) -> DockArea
These panels in the arrangement of layout, each showing what content makes for its id.
Sourcepub fn height(self, height: f32) -> DockArea
pub fn height(self, height: f32) -> DockArea
Its height, in logical pixels. Without it, it takes the room its parent has.
Sourcepub fn dock_limits(self, side: DockSide, min: f32, max: f32) -> DockArea
pub fn dock_limits(self, side: DockSide, min: f32, max: f32) -> DockArea
The smallest and the largest a dock gets, in logical pixels.
Sourcepub fn center_min(self, width: f32, height: f32) -> DockArea
pub fn center_min(self, width: f32, height: f32) -> DockArea
The width and the height the center keeps, which the docks do not take from it.
Sourcepub fn pane_min(self, min: f32) -> DockArea
pub fn pane_min(self, min: f32) -> DockArea
The smallest a group gets when a bar inside a split moves.
Sourcepub fn movable(self, movable: bool) -> DockArea
pub fn movable(self, movable: bool) -> DockArea
Whether panels change places (they do by default). Without it the tabs stay where the app put them, and only the sizes, the docks and closing are left.
Sourcepub fn tab_bar(self, tab_bar: DockTabBar) -> DockArea
pub fn tab_bar(self, tab_bar: DockTabBar) -> DockArea
When a group shows its tabs (DockTabBar::Always by default).
Sourcepub fn edge_toggles(self, on: bool) -> DockArea
pub fn edge_toggles(self, on: bool) -> DockArea
Whether the strips that collapse the docks show (they do by default). Without them, the
app does it with DockLayout::set_open.
Sourcepub fn on_end(self, handler: impl Fn(&DockLayout) + 'static) -> DockArea
pub fn on_end(self, handler: impl Fn(&DockLayout) + 'static) -> DockArea
Runs when the arrangement settles: after a drop, a bar let go, a key, a tab, a dock or a panel. It is the moment to save.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DockArea
impl !Send for DockArea
impl !Sync for DockArea
impl !UnwindSafe for DockArea
impl Freeze for DockArea
impl Unpin for DockArea
impl UnsafeUnpin for DockArea
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.