Struct conrod::graph::Graph [] [src]

pub struct Graph {
    // some fields omitted
}

Stores the dynamic state of a UI tree of Widgets.

Methods

impl Graph
[src]

fn new() -> Self

A new empty Graph.

fn with_node_capacity(n_nodes: usize) -> Self

A new Graph with the given node capacity.

We know that there can be no more than three parents per node as the public API enforces a maximum of one Depth, Position and Graphic parent each. Thus, we can assume an edge capacity of exactly three times the given node capacity.

fn clear(&mut self)

Removes all Nodes and Edges from the Graph.

fn node_count(&self) -> usize

The total number of Nodes in the Graph.

fn widget_count(&self) -> usize

The total number of Node::Widgets in the Graph.

fn edge_count(&self) -> usize

The total number of Edges in the Graph.

fn node_capacity(&self) -> usize

The current capacity for the Graph's internal node Vec.

fn convert_idx<I, J>(&self, idx: I) -> Option<J> where I: GraphIndex, J: GraphIndex

Converts the given GraphIndex into an index of type J.

Returns None if there is no direct mapping from the given index to an index of type J.

fn node_index<I: GraphIndex>(&self, idx: I) -> Option<NodeIndex>

Get the NodeIndex for the given GraphIndex.

fn widget_id<I: GraphIndex>(&self, idx: I) -> Option<Id>

Get the WidgetId for the given GraphIndex.

fn widget_index<I: GraphIndex>(&self, idx: I) -> Option<Index>

Get the widget::Index for the given GraphIndex.

First attempts to produce a WidgetId, then tries to produce a NodeIndex.

fn add_placeholder(&mut self) -> NodeIndex

Add a new placeholder node and return it's NodeIndex into the Graph.

This method is used by the widget::set_widget function when some internal widget does not yet have it's own NodeIndex.

fn node<I: GraphIndex>(&self, idx: I) -> Option<&Node>

Borrow the node at the given GraphIndex if there is one.

fn node_mut<I: GraphIndex>(&mut self, idx: I) -> Option<&mut Node>

Mutably borrow the node at the given GraphIndex if there is one.

fn edge(&self, idx: EdgeIndex) -> Option<&Edge>

Borrow the edge at the given EdgeIndex if there is one.

fn edge_mut(&mut self, idx: EdgeIndex) -> Option<&mut Edge>

Mutably borrow the edge at the given EdgeIndex if there is one.

fn edge_endpoints(&self, idx: EdgeIndex) -> Option<(NodeIndex, NodeIndex)>

Return the parent and child nodes on either end of the Edge at the given index.

fn widget<I: GraphIndex>(&self, idx: I) -> Option<&Container>

If there is a Widget for the given index, return a reference to it.

fn widget_mut<I: GraphIndex>(&mut self, idx: I) -> Option<&mut Container>

If there is a Widget for the given Id, return a mutable reference to it.

fn widget_scroll_state<I: GraphIndex>(&self, idx: I) -> Option<&State>

If there is a scrollable widget at the given index, return a reference to the widget's scroll state.

fn parents<I: GraphIndex>(&self, child: I) -> Parents

A Walker type that may be used to step through the parents of the given child node.

fn recursive_walk<I, F>(&self, start: I, recursive_fn: F) -> RecursiveWalk<F> where I: GraphIndex, F: FnMut(&Self, NodeIndex) -> Option<(EdgeIndex, NodeIndex)>

A Walker type that recursively walks the Graph using the given recursive_fn.

Panics If the given start index does not exist within the Graph.

fn edge_parent<I, J>(&self, idx: I, edge: Edge) -> Option<J> where I: GraphIndex, J: GraphIndex

If the widget at the given index has some parent along an Edge of the given variant, return an index to it.

fn depth_parent<I, J = NodeIndex>(&self, idx: I) -> Option<J> where I: GraphIndex, J: GraphIndex

Return the index of the parent along the given widget's Depth Edge.

fn position_parent<I, J = NodeIndex>(&self, idx: I) -> Option<J> where I: GraphIndex, J: GraphIndex

Return the index of the parent along the given widget's Position Edge.

fn graphic_parent<I, J = NodeIndex>(&self, idx: I) -> Option<J> where I: GraphIndex, J: GraphIndex

Return the index of the parent along the given widget's Graphic Edge.

fn depth_parent_recursion<I: GraphIndex>(&self, idx: I) -> RecursiveWalk<fn(&Graph, NodeIndex) -> Option<IndexPair>>

A Walker type that recursively walks Depth parents starting from the given node.

fn position_parent_recursion<I: GraphIndex>(&self, idx: I) -> RecursiveWalk<fn(&Graph, NodeIndex) -> Option<IndexPair>>

A Walker type that recursively walks Position parents starting from the given node.

fn graphic_parent_recursion<I: GraphIndex>(&self, idx: I) -> RecursiveWalk<fn(&Graph, NodeIndex) -> Option<IndexPair>>

A Walker type that recursively walks Graphic parents starting from the given node.

fn children<I: GraphIndex>(&self, parent: I) -> Children

A Walker type that may be used to step through the children of the given parent node.

fn depth_children<I: GraphIndex>(&self, idx: I) -> DepthChildren

For walking the Depth children of the given parent node.

fn position_children<I: GraphIndex>(&self, idx: I) -> PositionChildren

For walking the Position children of the given parent node.

fn graphic_children<I: GraphIndex>(&self, idx: I) -> GraphicChildren

For walking the Graphic children of the given parent node.

fn does_edge_exist<P, C>(&self, parent: P, child: C, edge: Edge) -> bool where P: GraphIndex, C: GraphIndex

Does the given edge type exist between the nodes parent -> child.

Returns false if either of the given node indices do not exist.

fn does_depth_edge_exist<P, C>(&self, parent: P, child: C) -> bool where P: GraphIndex, C: GraphIndex

Does a Edge::Depth exist between the nodes parent -> child.

Returns false if either of the given node indices do not exist.

fn does_position_edge_exist<P, C>(&self, parent: P, child: C) -> bool where P: GraphIndex, C: GraphIndex

Does a Edge::Position exist between the nodes parent -> child.

Returns false if either of the given node indices do not exist.

fn does_graphic_edge_exist<P, C>(&self, parent: P, child: C) -> bool where P: GraphIndex, C: GraphIndex

Does a Edge::Graphic exist between the nodes parent -> child.

Returns false if either of the given node indices do not exist.

fn does_recursive_edge_exist<P, C>(&self, parent: P, child: C, edge: Edge) -> bool where P: GraphIndex, C: GraphIndex

Are the given parent and child nodes connected by a single chain of edges of the given kind?

i.e. parent -> x -> y -> child.

Returns false if either of the given node indices do not exist.

fn does_recursive_depth_edge_exist<P, C>(&self, parent: P, child: C) -> bool where P: GraphIndex, C: GraphIndex

Are the given parent and child nodes connected by a single chain of Depth edges?

i.e. parent -> x -> y -> child.

Returns false if either of the given node indices do not exist.

fn does_recursive_position_edge_exist<P, C>(&self, parent: P, child: C) -> bool where P: GraphIndex, C: GraphIndex

Are the given parent and child nodes connected by a single chain of Position edges?

i.e. parent -> x -> y -> child.

Returns false if either of the given node indices do not exist.

fn does_recursive_graphic_edge_exist<P, C>(&self, parent: P, child: C) -> bool where P: GraphIndex, C: GraphIndex

Are the given parent and child nodes connected by a single chain of Graphic edges?

i.e. parent -> x -> y -> child.

Returns false if either of the given node indices do not exist.

fn pre_update_cache(&mut self, root: NodeIndex, widget: PreUpdateCache, instantiation_order_idx: usize)

Cache some PreUpdateCache widget data into the graph.

This is called (via the ui module) from within the widget::set_widget function prior to the Widget::update method being called.

This is done so that if this Widget were to internally set some other Widgets within its own update method, this Widgets positioning and dimension data already exists within the Graph for reference.

fn post_update_cache<W>(&mut self, widget: PostUpdateCache<W>) where W: Widget, W::State: 'static, W::Style: 'static

Cache some PostUpdateCache widget data into the graph.

This is called (via the ui module) from within the widget::set_widget function after the Widget::update method is called and some new state is returned.

Trait Implementations

impl Debug for Graph
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<I: GraphIndex> Index<I> for Graph
[src]

type Output = Node

The returned type after indexing

fn index<'a>(&'a self, idx: I) -> &'a Node

The method for the indexing (Foo[Bar]) operation

impl<I: GraphIndex> IndexMut<I> for Graph
[src]

fn index_mut<'a>(&'a mut self, idx: I) -> &'a mut Node

The method for the indexing (Foo[Bar]) operation

impl Index<EdgeIndex> for Graph
[src]

type Output = Edge

The returned type after indexing

fn index<'a>(&'a self, idx: EdgeIndex) -> &'a Edge

The method for the indexing (Foo[Bar]) operation

impl IndexMut<EdgeIndex> for Graph
[src]

fn index_mut<'a>(&'a mut self, idx: EdgeIndex) -> &'a mut Edge

The method for the indexing (Foo[Bar]) operation