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§

source

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

Type representing an iterator of the children of a node

Required Methods§

source

fn children(&self, node: Node) -> Self::ChildIter<'_>

Get the list of children IDs for the given node

source

fn child_count(&self, node: Node) -> usize

Get the number of children for the given node

source

fn is_childless(&self, node: Node) -> bool

Returns true if the node has no children

source

fn child(&self, node: Node, index: usize) -> Node

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

source

fn parent(&self, node: Node) -> Option<Node>

Get any available parent for this node

source

fn style(&self, node: Node) -> &Style

Get the Style for this Node.

source

fn layout(&self, node: Node) -> &Layout

Get the node’s output “Final Layout”

source

fn layout_mut(&mut self, node: Node) -> &mut Layout

Modify the node’s output layout

source

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.

source

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.

source

fn needs_measure(&self, node: Node) -> bool

Node needs to be measured

source

fn cache_mut(&mut self, node: Node, index: usize) -> &mut Option<Cache>

Get a cache entry for this Node by index

Object Safety§

This trait is not object safe.

Implementors§