pub trait LayoutEngine<Id: Copy + Eq + Ord> {
// Required methods
fn layout(&self, area: LayoutRect) -> Vec<(Id, LayoutRect)>;
fn insert_leaf(
&mut self,
target: Id,
insert: Id,
position: InsertPosition,
area: LayoutRect,
constraints: &SizeConstraints,
) -> Result<(), LayoutError>;
fn remove_leaf(&mut self, id: Id) -> Result<(), LayoutError>;
fn all_leaf_ids(&self) -> Vec<Id>;
fn subtree_any(&self, predicate: &mut impl FnMut(Id) -> bool) -> bool;
fn apply_drag(
&mut self,
area: LayoutRect,
path: &[usize],
index: usize,
orientation: Orientation,
delta: i16,
constraints: &SizeConstraints,
) -> bool;
}Expand description
Common interface for tree-based layout engines (BSP and N-ary).
All mutation methods accept SizeConstraints to enforce minimum
dimensions and return Result<(), LayoutError> on violation.
Required Methods§
fn layout(&self, area: LayoutRect) -> Vec<(Id, LayoutRect)>
fn insert_leaf( &mut self, target: Id, insert: Id, position: InsertPosition, area: LayoutRect, constraints: &SizeConstraints, ) -> Result<(), LayoutError>
fn remove_leaf(&mut self, id: Id) -> Result<(), LayoutError>
fn all_leaf_ids(&self) -> Vec<Id>
fn subtree_any(&self, predicate: &mut impl FnMut(Id) -> bool) -> bool
fn apply_drag( &mut self, area: LayoutRect, path: &[usize], index: usize, orientation: Orientation, delta: i16, constraints: &SizeConstraints, ) -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".