pub struct DockTree { /* private fields */ }Expand description
A tree of splits and tab groups covering one workbench area.
Implementations§
Source§impl DockTree
impl DockTree
Sourcepub fn insert(
&mut self,
panel: impl Into<String>,
target: Option<&str>,
zone: DropZone,
) -> Option<SplitId>
pub fn insert( &mut self, panel: impl Into<String>, target: Option<&str>, zone: DropZone, ) -> Option<SplitId>
Adds panel to the tree relative to target.
Center joins target’s tab group; the edge zones split it. A panel
already in the tree is moved rather than duplicated, which is what makes
this the single entry point for a drag-and-drop rearrange.
With no target — or a target that isn’t in the tree — the panel
splits the root, or becomes the root if the dock is empty.
Returns the SplitId of the divider this created, so a caller
building a default layout can set its ratio without having to guess at
allocation order. None when the panel joined a tab group instead.
Sourcepub fn remove(&mut self, panel: &str) -> bool
pub fn remove(&mut self, panel: &str) -> bool
Removes panel. An emptied tab group collapses, and its parent split is
replaced by the surviving sibling so no blank area is left behind.
Returns whether the panel was there.
Sourcepub fn activate(&mut self, panel: &str) -> bool
pub fn activate(&mut self, panel: &str) -> bool
Makes panel the visible tab of its group. No-op if it isn’t in the
tree.
Sourcepub fn set_ratio(&mut self, id: SplitId, ratio: f32) -> bool
pub fn set_ratio(&mut self, id: SplitId, ratio: f32) -> bool
Sets a split’s ratio, clamped to 0.05..=0.95 so a divider dragged to
the edge leaves the pane recoverable.
Sourcepub fn layout(&self, area: DockRect) -> DockLayout
pub fn layout(&self, area: DockRect) -> DockLayout
Places every group and divider inside area.