pub enum LayoutNode<Id: Copy + Eq + Ord> {
Leaf(Id),
Void(usize),
Split {
direction: Direction,
children: Vec<LayoutNode<Id>>,
weights: Vec<u16>,
resizable: bool,
},
}Variants§
Implementations§
Source§impl<Id: Copy + Eq + Ord> LayoutNode<Id>
impl<Id: Copy + Eq + Ord> LayoutNode<Id>
pub fn leaf(id: Id) -> Self
pub fn void() -> Self
pub fn split(direction: Direction, children: Vec<LayoutNode<Id>>) -> Self
pub fn split_resizable( direction: Direction, children: Vec<LayoutNode<Id>>, resizable: bool, ) -> Self
pub fn unwrap_leaf(&self) -> Option<Id>
pub fn layout_rects(&self, area: LayoutRect) -> Vec<(Id, LayoutRect)>
pub fn layout_with_gaps( &self, area: LayoutRect, ) -> (Vec<(Id, LayoutRect)>, Vec<SplitGap>)
pub fn node_at_path(&self, path: &[usize]) -> Option<&LayoutNode<Id>>
pub fn collect_leaves(&self) -> Vec<Id>
pub fn swap_leaves(&mut self, source: &Id, target: &Id) -> bool
pub fn build_flat(direction: Direction, ids: Vec<Id>) -> Self
pub fn subtree_any<F>(&self, predicate: F) -> bool
pub fn hit_test_gap( &self, area: LayoutRect, column: u16, row: u16, ) -> Option<SplitGap>
pub fn apply_drag( &mut self, area: LayoutRect, path: &[usize], index: usize, direction: Direction, delta: i16, min_size: i16, ) -> bool
pub fn remove_leaf(&mut self, id: Id) -> bool
pub fn clear_leaf(&mut self, id: Id) -> bool
Sourcepub fn replace_leaf_with_void(&mut self, id: Id) -> Option<usize>
pub fn replace_leaf_with_void(&mut self, id: Id) -> Option<usize>
Replace a leaf identified by id with a Void placeholder, preserving
the tree structure and split weights. Returns the fresh void_id, or
None if the leaf was not found.
pub fn insert_leaf( &mut self, target: Id, insert: Id, position: InsertPosition, ) -> bool
pub fn void_regions(&self, area: LayoutRect) -> Vec<(usize, LayoutRect)>
pub fn cleanup_after_removal(&mut self)
pub fn normalize_weights(&mut self)
pub fn replace_void_by_id( &mut self, void_id: usize, new_leaf: LayoutNode<Id>, ) -> bool
Sourcepub fn remove_void_by_id(&mut self, void_id: usize) -> bool
pub fn remove_void_by_id(&mut self, void_id: usize) -> bool
Remove a Void node by its ID from the tree. Returns true if the void was found and removed, false otherwise. Cleans up empty parent splits.
pub fn is_empty(&self) -> bool
Sourcepub fn from_rects(rects: &[(Id, LayoutRect)]) -> Self
pub fn from_rects(rects: &[(Id, LayoutRect)]) -> Self
Build a BSP tree from rectangles using straddle-tolerant cut selection. Straddled windows are assigned to the side containing more of their area. Weights are count-based to ensure each window gets equal space. Fallback uses aspect-aware direction for the sort axis.
pub fn split_root(&mut self, insert: Id, position: InsertPosition)
pub fn project_insert( &self, target: Option<Id>, insert: Id, position: InsertPosition, area: LayoutRect, ) -> Option<LayoutRect>
pub fn project_insert_void( &self, insert: Id, void_id: usize, area: LayoutRect, ) -> Option<LayoutRect>
Trait Implementations§
Source§impl<Id: Clone + Copy + Eq + Ord> Clone for LayoutNode<Id>
impl<Id: Clone + Copy + Eq + Ord> Clone for LayoutNode<Id>
Source§fn clone(&self) -> LayoutNode<Id>
fn clone(&self) -> LayoutNode<Id>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<Id> Freeze for LayoutNode<Id>where
Id: Freeze,
impl<Id> RefUnwindSafe for LayoutNode<Id>where
Id: RefUnwindSafe,
impl<Id> Send for LayoutNode<Id>where
Id: Send,
impl<Id> Sync for LayoutNode<Id>where
Id: Sync,
impl<Id> Unpin for LayoutNode<Id>where
Id: Unpin,
impl<Id> UnsafeUnpin for LayoutNode<Id>where
Id: UnsafeUnpin,
impl<Id> UnwindSafe for LayoutNode<Id>where
Id: UnwindSafe,
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
Mutably borrows from an owned value. Read more