[][src]Trait polyhorn_ui::layout::algorithm::Algorithm

pub trait Algorithm {
    type Node: Copy + Clone + Hash + Eq;
    fn new() -> Self;
fn new_node(
        &mut self,
        style: ViewStyle,
        children: &[Self::Node]
    ) -> Self::Node;
fn new_leaf(&mut self, style: ViewStyle, measure: MeasureFunc) -> Self::Node;
fn add_child(&mut self, parent: Self::Node, child: Self::Node);
fn remove_child(&mut self, parent: Self::Node, child: Self::Node);
fn child_count(&self, parent: Self::Node) -> usize;
fn remove(&mut self, node: Self::Node);
fn set_style(&mut self, node: Self::Node, style: ViewStyle);
fn set_measure(&mut self, node: Self::Node, measure: MeasureFunc);
fn compute_layout(&mut self, node: Self::Node, size: Size<Dimension<f32>>);
fn layout(&self, node: Self::Node) -> Layout; }

Abstract interface of a flexbox algorithm.

Associated Types

type Node: Copy + Clone + Hash + Eq

Represents the type of a node within this flexbox.

Loading content...

Required methods

fn new() -> Self

Create a new instance of the flexbox (i.e. root).

fn new_node(&mut self, style: ViewStyle, children: &[Self::Node]) -> Self::Node

Create a new node with the given child nodes.

fn new_leaf(&mut self, style: ViewStyle, measure: MeasureFunc) -> Self::Node

Create a new leaf with an intrinsic content size that is determined by the given measure function.

fn add_child(&mut self, parent: Self::Node, child: Self::Node)

Add a child node to a parent node.

fn remove_child(&mut self, parent: Self::Node, child: Self::Node)

Remove a child node from a parent node.

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

Returns the number of child nodes of a specific parent node.

fn remove(&mut self, node: Self::Node)

Removes the given node from this flexbox.

fn set_style(&mut self, node: Self::Node, style: ViewStyle)

Updates the style of a specific node within this flexbox.

fn set_measure(&mut self, node: Self::Node, measure: MeasureFunc)

Updates the measure function of a specific node within this flexbox.

fn compute_layout(&mut self, node: Self::Node, size: Size<Dimension<f32>>)

Computes the layout of a node within this flexbox within the given size.

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

Returns the computed layout of a node within this flexbox.

Loading content...

Implementors

impl Algorithm for Flexbox[src]

type Node = Node

Loading content...