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§
Required Methods§
sourcefn child_ids(&self, parent_node_id: NodeId) -> Self::ChildIter<'_>
fn child_ids(&self, parent_node_id: NodeId) -> Self::ChildIter<'_>
Get the list of children IDs for the given node
sourcefn child_count(&self, parent_node_id: NodeId) -> usize
fn child_count(&self, parent_node_id: NodeId) -> usize
Get the number of children for the given node
sourcefn get_child_id(&self, parent_node_id: NodeId, child_index: usize) -> NodeId
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
sourcefn set_unrounded_layout(&mut self, node_id: NodeId, layout: &Layout)
fn set_unrounded_layout(&mut self, node_id: NodeId, layout: &Layout)
Set the node’s unrounded layout
sourcefn get_cache_mut(&mut self, node_id: NodeId) -> &mut Cache
fn get_cache_mut(&mut self, node_id: NodeId) -> &mut Cache
Get a mutable reference to the Cache
for this node.
sourcefn compute_child_layout(
&mut self,
node_id: NodeId,
inputs: LayoutInput,
) -> LayoutOutput
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