Skip to main content

LayoutEngine

Struct LayoutEngine 

Source
pub struct LayoutEngine { /* private fields */ }
Expand description

The layout engine manages the binary tree of pane arrangements.

Implementations§

Source§

impl LayoutEngine

Source

pub fn new() -> Self

Create an empty layout.

Source

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).

Source

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.

Source

pub fn remove_pane(&mut self, pane_id: PaneId) -> bool

Remove a pane from the layout, collapsing the tree.

Source

pub fn pane_ids(&self) -> Vec<PaneId>

List all pane IDs in the layout tree.

Source

pub fn count(&self) -> usize

Number of panes in the layout.

Source

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.

Source

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.

Source

pub fn swap_leaves(&mut self, a: PaneId, b: PaneId) -> bool

Swap two pane IDs in the layout tree.

Source

pub fn root(&self) -> Option<&LayoutNode>

Get the root node (for inspection).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for LayoutEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LayoutEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.