Skip to main content

LayoutTree

Struct LayoutTree 

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

Arena-based mutable layout tree.

Implementations§

Source§

impl LayoutTree

Source

pub fn new() -> Self

Create an empty tree with no nodes.

Source

pub fn add_panel( &mut self, kind: impl Into<Arc<str>>, constraints: Constraints, ) -> Result<(PanelId, NodeId), PaneError>

Add a panel node. Returns the generated PanelId and the arena NodeId.

Source

pub fn add_row( &mut self, gap: f32, children: Vec<NodeId>, ) -> Result<NodeId, PaneError>

Add a row container with the given gap and children.

Source

pub fn add_col( &mut self, gap: f32, children: Vec<NodeId>, ) -> Result<NodeId, PaneError>

Add a column container with the given gap and children.

Source

pub fn add_taffy_node( &mut self, style: Style, children: Vec<NodeId>, ) -> Result<NodeId, PaneError>

Add a raw Taffy passthrough node.

Source

pub fn set_root(&mut self, id: NodeId)

Set the root node of the tree.

Source

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

Return the root node id, if set.

Source

pub fn node(&self, id: NodeId) -> Option<&Node>

Look up a node by id.

Source

pub fn is_dirty(&self) -> bool

Whether the tree structure has changed since last compile.

Source

pub fn clear_dirty(&mut self)

Clear the dirty flag after a successful compile.

Source

pub fn panel_id_high_water(&self) -> u32

One past the highest issued PanelId. Used to size Vec-indexed storage.

Source

pub fn arena_len(&self) -> usize

Total slots in the node arena (including tombstones).

Source

pub fn node_count(&self) -> usize

Total number of live nodes in the arena.

Source

pub fn panel_count(&self) -> usize

Total number of panel nodes in the tree.

Source

pub fn window_size(&self) -> usize

How many panels the active window shows at once. Default is 1. Scrollable sets this to 2.

Source

pub fn set_window_size(&mut self, size: usize)

Set the active window size.

Source

pub fn kind_count(&self) -> usize

Total number of distinct panel kinds.

Source

pub fn kinds(&self) -> impl Iterator<Item = &Arc<str>>

All distinct panel kinds.

Source

pub fn panels_by_kind(&self, kind: &str) -> &[PanelId]

All PanelIds with the given kind.

Source

pub fn set_constraints( &mut self, pid: PanelId, constraints: Constraints, ) -> Result<(), PaneError>

Update a panel’s constraints.

Source

pub fn panel_constraints(&self, pid: PanelId) -> Result<Constraints, PaneError>

Get a panel’s current constraints.

Source

pub fn panel_kind(&self, pid: PanelId) -> Result<&str, PaneError>

Get a panel’s kind.

Source

pub fn children(&self, id: NodeId) -> Result<&[NodeId], PaneError>

Get the children of a node. Returns an empty slice for leaf nodes.

Source

pub fn parent(&self, id: NodeId) -> Result<Option<NodeId>, PaneError>

Get the parent of a node. Returns None for root nodes.

Source

pub fn node_for_panel(&self, pid: PanelId) -> Option<NodeId>

Resolve a PanelId to its arena NodeId, if present.

Source

pub fn insert_child_at( &mut self, container: NodeId, idx: usize, child: NodeId, ) -> Result<(), PaneError>

Insert a child into a container at the given index, updating parent_map.

Source

pub fn remove_panel(&mut self, pid: PanelId) -> Result<(), PaneError>

Remove a panel from the tree entirely.

Source

pub fn move_panel( &mut self, pid: PanelId, position: Position, ) -> Result<(), PaneError>

Move a panel to a new position (possibly in a different container).

Source

pub fn validate(&self) -> Result<(), PaneError>

Check structural integrity of the tree.

Source

pub fn insert_node( &mut self, node_id: NodeId, container_id: NodeId, position: Position, ) -> Result<(), PaneError>

Insert a node into a container at a position relative to an anchor.

Source

pub fn resolve( &self, width: f32, height: f32, ) -> Result<ResolvedLayout, PaneError>

Compile, compute, and resolve in one call.

Trait Implementations§

Source§

impl Default for LayoutTree

Source§

fn default() -> Self

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

impl From<Layout> for LayoutTree

Source§

fn from(layout: Layout) -> Self

Converts to this type from the input type.
Source§

impl From<LayoutTree> for LayoutRuntime

Source§

fn from(tree: LayoutTree) -> Self

Converts to this type from the input type.

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.