Skip to main content

LayoutEngine

Trait LayoutEngine 

Source
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§

Source

fn layout(&self, area: LayoutRect) -> Vec<(Id, LayoutRect)>

Source

fn insert_leaf( &mut self, target: Id, insert: Id, position: InsertPosition, area: LayoutRect, constraints: &SizeConstraints, ) -> Result<(), LayoutError>

Source

fn remove_leaf(&mut self, id: Id) -> Result<(), LayoutError>

Source

fn all_leaf_ids(&self) -> Vec<Id>

Source

fn subtree_any(&self, predicate: &mut impl FnMut(Id) -> bool) -> bool

Source

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

Implementors§

Source§

impl<Id: Copy + Eq + Ord> LayoutEngine<Id> for BspNode<Id>

Source§

impl<Id: Copy + Eq + Ord> LayoutEngine<Id> for NaryNode<Id>