Trait tree_layout::NodeInfo

source ·
pub trait NodeInfo<N>where
    Self::Key: Eq + Hash,
    N: Clone,{
    type Key;

    // Required methods
    fn key(&self, node: N) -> Self::Key;
    fn children(&self, node: N) -> impl Iterator<Item = N>;

    // Provided methods
    fn dimensions(&self, node: N) -> TreeBox { ... }
    fn border(&self, node: N) -> TreeBox { ... }
}

Required Associated Types§

Required Methods§

source

fn key(&self, node: N) -> Self::Key

Returns a key that will be used to uniquely identify a given node.

source

fn children(&self, node: N) -> impl Iterator<Item = N>

Returns the children that a given node has.

Provided Methods§

source

fn dimensions(&self, node: N) -> TreeBox

Returns the dimensions of a given node.

This is the padding that you want around the centre point of the node so that you can line things up as you want to (e.g. nodes aligned by their top border vs being aligned by their centres).

This value is generic over units (but all nodes must use the same unit) and the layout that this crate calculates will be given in terms of this unit. For example if you give this value in pixels then the layout will be given in terms of number of pixels from the left of the tree. Alternatively you might want to give this value in terms of the proportion of the width of your window (though note that this does not guarantee that the tree will fit in your window).

Default

By default the algorithm assumes that each node is point-like (i.e. has no width or height).

source

fn border(&self, node: N) -> TreeBox

Returns the desired border around a given node.

See the dimensions method for a description of what units this has.

Default

By default the algorithm assumes that each node has a border of 0.5 on every side.

Object Safety§

This trait is not object safe.

Implementors§