Trait taffy::PartialLayoutTree

source ·
pub trait PartialLayoutTree {
    type ChildIter<'a>: Iterator<Item = NodeId>
       where Self: 'a;

    // Required methods
    fn child_ids(&self, parent_node_id: NodeId) -> Self::ChildIter<'_>;
    fn child_count(&self, parent_node_id: NodeId) -> usize;
    fn get_child_id(&self, parent_node_id: NodeId, child_index: usize) -> NodeId;
    fn get_style(&self, node_id: NodeId) -> &Style;
    fn set_unrounded_layout(&mut self, node_id: NodeId, layout: &Layout);
    fn get_cache_mut(&mut self, node_id: NodeId) -> &mut Cache;
    fn compute_child_layout(
        &mut self,
        node_id: NodeId,
        inputs: LayoutInput,
    ) -> LayoutOutput;
}
Expand description

This if the core abstraction in Taffy. Any type that correctly implements PartialLayoutTree can be laid out using Taffy’s algorithms.

The type implementing PartialLayoutTree would typically be an entire tree of nodes (or a view over an entire tree of nodes). However, PartialLayoutTree and Taffy’s algorithm implementations have been designed such that they can be used for a laying out a single node that only has access to it’s immediate children.

Required Associated Types§

source

type ChildIter<'a>: Iterator<Item = NodeId> where Self: 'a

Type representing an iterator of the children of a node

Required Methods§

source

fn child_ids(&self, parent_node_id: NodeId) -> Self::ChildIter<'_>

Get the list of children IDs for the given node

source

fn child_count(&self, parent_node_id: NodeId) -> usize

Get the number of children for the given node

source

fn get_child_id(&self, parent_node_id: NodeId, child_index: usize) -> NodeId

Get a specific child of a node, where the index represents the nth child

source

fn get_style(&self, node_id: NodeId) -> &Style

Get a reference to the Style for this node.

source

fn set_unrounded_layout(&mut self, node_id: NodeId, layout: &Layout)

Set the node’s unrounded layout

source

fn get_cache_mut(&mut self, node_id: NodeId) -> &mut Cache

Get a mutable reference to the Cache for this node.

source

fn compute_child_layout( &mut self, node_id: NodeId, inputs: LayoutInput, ) -> LayoutOutput

Compute the specified node’s size or full layout given the specified constraints

Object Safety§

This trait is not object safe.

Implementors§