Trait TaffyTreeExt
pub trait TaffyTreeExt {
// Required methods
fn leaf_node(&mut self, style: Style) -> NodeId;
fn parent_node(&mut self, style: Style, children: &[NodeId]) -> NodeId;
// Provided methods
fn widget_leaf(
&mut self,
style: Style,
node_map: &mut HashMap<NodeId, *mut dyn Widget>,
widget: &mut (dyn Widget + 'static),
) -> NodeId { ... }
fn fill_leaf(
&mut self,
node_map: &mut HashMap<NodeId, *mut dyn Widget>,
widget: &mut (dyn Widget + 'static),
) -> NodeId { ... }
fn widget_node(
&mut self,
style: Style,
children: &[NodeId],
node_map: &mut HashMap<NodeId, *mut dyn Widget>,
widget: &mut (dyn Widget + 'static),
) -> NodeId { ... }
fn fill_node(&mut self, child: NodeId) -> NodeId { ... }
}Expand description
Panic-free node construction, used by every build_layout implementation
in this module. TaffyTree::new_leaf and new_with_children are typed
-> TaffyResult<NodeId> for API generality, but taffy 0.10’s
implementation shows neither can return Err: new_leaf always
inserts and returns Ok, and new_with_children only fails for a child
NodeId belonging to a different tree, which never happens here since
every child passed in was just built in this same tree by the calls
immediately above each call site. Widget::build_layout returns a bare
NodeId (not a Result) across every implementor, so surfacing a
theoretical error here would mean threading a Result through the whole
toolkit for a branch that can’t be taken.
Required Methods§
fn parent_node(&mut self, style: Style, children: &[NodeId]) -> NodeId
fn parent_node(&mut self, style: Style, children: &[NodeId]) -> NodeId
Insert a parent whose child ids were built in this same tree.
Provided Methods§
fn widget_leaf(
&mut self,
style: Style,
node_map: &mut HashMap<NodeId, *mut dyn Widget>,
widget: &mut (dyn Widget + 'static),
) -> NodeId
fn widget_leaf( &mut self, style: Style, node_map: &mut HashMap<NodeId, *mut dyn Widget>, widget: &mut (dyn Widget + 'static), ) -> NodeId
Insert a leaf node for widget and register it in node_map: the
whole of a leaf widget’s build_layout.
fn fill_leaf(
&mut self,
node_map: &mut HashMap<NodeId, *mut dyn Widget>,
widget: &mut (dyn Widget + 'static),
) -> NodeId
fn fill_leaf( &mut self, node_map: &mut HashMap<NodeId, *mut dyn Widget>, widget: &mut (dyn Widget + 'static), ) -> NodeId
Self::widget_leaf for a leaf that fills its parent’s box: a
canvas, viewport or overlay that sizes and lays out its own content.