Trait taffy::tree::LayoutTree
source · pub trait LayoutTree {
type ChildIter<'a>: Iterator<Item = &'a DefaultKey>
where Self: 'a;
// Required methods
fn children(&self, node: Node) -> Self::ChildIter<'_>;
fn child_count(&self, node: Node) -> usize;
fn is_childless(&self, node: Node) -> bool;
fn child(&self, node: Node, index: usize) -> Node;
fn parent(&self, node: Node) -> Option<Node>;
fn style(&self, node: Node) -> &Style;
fn layout(&self, node: Node) -> &Layout;
fn layout_mut(&mut self, node: Node) -> &mut Layout;
fn mark_dirty(&mut self, node: Node) -> TaffyResult<()>;
fn measure_node(
&self,
node: Node,
known_dimensions: Size<Option<f32>>,
available_space: Size<AvailableSpace>
) -> Size<f32>;
fn needs_measure(&self, node: Node) -> bool;
fn cache_mut(&mut self, node: Node, index: usize) -> &mut Option<Cache>;
}
Expand description
Any item that implements the LayoutTree can be layed out using Taffy’s algorithms.
Generally, Taffy expects your Node tree to be indexable by stable indices. A “stable” index means that the Node’s ID remains the same between re-layouts.
Required Associated Types§
sourcetype ChildIter<'a>: Iterator<Item = &'a DefaultKey>
where
Self: 'a
type ChildIter<'a>: Iterator<Item = &'a DefaultKey> where Self: 'a
Type representing an iterator of the children of a node
Required Methods§
sourcefn children(&self, node: Node) -> Self::ChildIter<'_>
fn children(&self, node: Node) -> Self::ChildIter<'_>
Get the list of children IDs for the given node
sourcefn child_count(&self, node: Node) -> usize
fn child_count(&self, node: Node) -> usize
Get the number of children for the given node
sourcefn is_childless(&self, node: Node) -> bool
fn is_childless(&self, node: Node) -> bool
Returns true if the node has no children
sourcefn child(&self, node: Node, index: usize) -> Node
fn child(&self, node: Node, index: usize) -> Node
Get a specific child of a node, where the index represents the nth child
sourcefn layout_mut(&mut self, node: Node) -> &mut Layout
fn layout_mut(&mut self, node: Node) -> &mut Layout
Modify the node’s output layout
sourcefn mark_dirty(&mut self, node: Node) -> TaffyResult<()>
fn mark_dirty(&mut self, node: Node) -> TaffyResult<()>
Mark a node as dirty to tell Taffy that something has changed and it needs to be recomputed.
Commonly done if the style of the node has changed.
sourcefn measure_node(
&self,
node: Node,
known_dimensions: Size<Option<f32>>,
available_space: Size<AvailableSpace>
) -> Size<f32>
fn measure_node( &self, node: Node, known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace> ) -> Size<f32>
Measure a node. Taffy uses this to force reflows of things like text and overflowing content.
sourcefn needs_measure(&self, node: Node) -> bool
fn needs_measure(&self, node: Node) -> bool
Node needs to be measured