pub struct LayoutEngine { /* private fields */ }Expand description
The layout engine manages the binary tree of pane arrangements.
Implementations§
Source§impl LayoutEngine
impl LayoutEngine
Sourcepub fn add_pane(&mut self, pane_id: PaneId)
pub fn add_pane(&mut self, pane_id: PaneId)
Add a pane as a leaf. If the layout is empty, this becomes the root. If non-empty, splits the last pane vertically (fallback behavior).
Sourcepub fn split(
&mut self,
target_pane_id: PaneId,
new_pane_id: PaneId,
direction: SplitDirection,
) -> bool
pub fn split( &mut self, target_pane_id: PaneId, new_pane_id: PaneId, direction: SplitDirection, ) -> bool
Split a target pane, creating a new split node.
Sourcepub fn remove_pane(&mut self, pane_id: PaneId) -> bool
pub fn remove_pane(&mut self, pane_id: PaneId) -> bool
Remove a pane from the layout, collapsing the tree.
Sourcepub fn compute_positions(
&self,
total_cols: usize,
total_rows: usize,
) -> Vec<(PaneId, PanePosition)>
pub fn compute_positions( &self, total_cols: usize, total_rows: usize, ) -> Vec<(PaneId, PanePosition)>
Compute the absolute position of every pane given the total tab area.
Sourcepub fn adjust_ratio(
&mut self,
target: PaneId,
axis: SplitDirection,
delta: f32,
) -> bool
pub fn adjust_ratio( &mut self, target: PaneId, axis: SplitDirection, delta: f32, ) -> bool
Adjust the split ratio for the nearest ancestor of target on the given axis.
Sourcepub fn swap_leaves(&mut self, a: PaneId, b: PaneId) -> bool
pub fn swap_leaves(&mut self, a: PaneId, b: PaneId) -> bool
Swap two pane IDs in the layout tree.
Sourcepub fn root(&self) -> Option<&LayoutNode>
pub fn root(&self) -> Option<&LayoutNode>
Get the root node (for inspection).
Sourcepub fn set_root(&mut self, root: LayoutNode)
pub fn set_root(&mut self, root: LayoutNode)
Replace the entire layout tree with a new root. This is used by swap layouts to apply a template.
Sourcepub fn apply_template(&mut self, template: &LayoutNode, pane_ids: &[PaneId])
pub fn apply_template(&mut self, template: &LayoutNode, pane_ids: &[PaneId])
Apply a layout template to the current set of pane IDs. The template tree’s leaf IDs are replaced with the actual pane IDs in left-to-right order. If the template has fewer leaves than panes, extra panes are split off the last leaf. If more leaves, extra leaves are trimmed.