[][src]Struct nannou::ui::graph::Graph

pub struct Graph { /* fields omitted */ }

Stores the dynamic state of a UI tree of Widgets.

Methods

impl Graph[src]

pub fn new() -> Graph[src]

A new empty Graph.

pub fn with_node_capacity(n_nodes: usize) -> Graph[src]

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.

pub fn clear(&mut self)[src]

Removes all Nodes and Edges from the Graph.

pub fn node_count(&self) -> usize[src]

The total number of Nodes in the Graph.

pub fn widget_count(&self) -> usize[src]

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

pub fn edge_count(&self) -> usize[src]

The total number of Edges in the Graph.

pub fn node_capacity(&self) -> usize[src]

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

pub fn add_placeholder(&mut self) -> NodeIndex<u32>[src]

Add a new placeholder node and return it's widget::Id into the Graph.

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

pub fn node(&self, idx: NodeIndex<u32>) -> Option<&Node>[src]

Borrow the node at the given widget::Id if there is one.

pub fn node_mut(&mut self, idx: NodeIndex<u32>) -> Option<&mut Node>[src]

Mutably borrow the node at the given widget::Id if there is one.

pub fn edge(&self, idx: EdgeIndex<u32>) -> Option<&Edge>[src]

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

pub fn edge_mut(&mut self, idx: EdgeIndex<u32>) -> Option<&mut Edge>[src]

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

pub fn edge_endpoints(
    &self,
    idx: EdgeIndex<u32>
) -> Option<(NodeIndex<u32>, NodeIndex<u32>)>
[src]

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

pub fn widget(&self, idx: NodeIndex<u32>) -> Option<&Container>[src]

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

pub fn widget_mut(&mut self, idx: NodeIndex<u32>) -> Option<&mut Container>[src]

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

pub fn parents(&self, child: NodeIndex<u32>) -> Parents<Node, Edge, u32>[src]

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

pub fn recursive_walk<F>(
    &self,
    start: NodeIndex<u32>,
    recursive_fn: F
) -> Recursive<Graph, u32, F> where
    F: FnMut(&Graph, NodeIndex<u32>) -> Option<(EdgeIndex<u32>, NodeIndex<u32>)>, 
[src]

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.

pub fn edge_parent(
    &self,
    idx: NodeIndex<u32>,
    edge: Edge
) -> Option<NodeIndex<u32>>
[src]

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

pub fn depth_parent(&self, idx: NodeIndex<u32>) -> Option<NodeIndex<u32>>[src]

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

pub fn x_position_parent(&self, idx: NodeIndex<u32>) -> Option<NodeIndex<u32>>[src]

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

pub fn y_position_parent(&self, idx: NodeIndex<u32>) -> Option<NodeIndex<u32>>[src]

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

pub fn position_parents(
    &self,
    idx: NodeIndex<u32>
) -> Chain<IntoIter<NodeIndex<u32>>, IntoIter<NodeIndex<u32>>>
[src]

Produces an iterator yielding the parents along both the X and Y Position Edges respectively.

pub fn graphic_parent(&self, idx: NodeIndex<u32>) -> Option<NodeIndex<u32>>[src]

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

pub fn depth_parent_recursion(
    &self,
    idx: NodeIndex<u32>
) -> Recursive<Graph, u32, fn(&Graph, NodeIndex<u32>) -> Option<(EdgeIndex<u32>, NodeIndex<u32>)>>
[src]

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

pub fn x_position_parent_recursion(
    &self,
    idx: NodeIndex<u32>
) -> Recursive<Graph, u32, fn(&Graph, NodeIndex<u32>) -> Option<(EdgeIndex<u32>, NodeIndex<u32>)>>
[src]

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

pub fn y_position_parent_recursion(
    &self,
    idx: NodeIndex<u32>
) -> Recursive<Graph, u32, fn(&Graph, NodeIndex<u32>) -> Option<(EdgeIndex<u32>, NodeIndex<u32>)>>
[src]

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

pub fn graphic_parent_recursion(
    &self,
    idx: NodeIndex<u32>
) -> Recursive<Graph, u32, fn(&Graph, NodeIndex<u32>) -> Option<(EdgeIndex<u32>, NodeIndex<u32>)>>
[src]

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

pub fn scrollable_y_parent_recursion(
    &self,
    idx: NodeIndex<u32>
) -> Recursive<Graph, u32, fn(&Graph, NodeIndex<u32>) -> Option<(EdgeIndex<u32>, NodeIndex<u32>)>>
[src]

A Walker type that recursively walks Depth parents that are scrollable along the y axis for the given node.

pub fn scrollable_x_parent_recursion(
    &self,
    idx: NodeIndex<u32>
) -> Recursive<Graph, u32, fn(&Graph, NodeIndex<u32>) -> Option<(EdgeIndex<u32>, NodeIndex<u32>)>>
[src]

A Walker type that recursively walks Depth parents that are scrollable along the x axis for the given node.

pub fn children(&self, parent: NodeIndex<u32>) -> Children<Node, Edge, u32>[src]

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

pub fn depth_children(
    &self,
    idx: NodeIndex<u32>
) -> Filter<Children<Node, Edge, u32>, fn(&Graph, EdgeIndex<u32>, NodeIndex<u32>) -> bool>
[src]

For walking the Depth children of the given parent node.

pub fn x_position_children(
    &self,
    idx: NodeIndex<u32>
) -> Filter<Children<Node, Edge, u32>, fn(&Graph, EdgeIndex<u32>, NodeIndex<u32>) -> bool>
[src]

For walking the Position(X) children of the given parent node.

pub fn y_position_children(
    &self,
    idx: NodeIndex<u32>
) -> Filter<Children<Node, Edge, u32>, fn(&Graph, EdgeIndex<u32>, NodeIndex<u32>) -> bool>
[src]

For walking the Position(Y) children of the given parent node.

pub fn position_children(
    &self,
    idx: NodeIndex<u32>
) -> Chain<Graph, u32, Filter<Children<Node, Edge, u32>, fn(&Graph, EdgeIndex<u32>, NodeIndex<u32>) -> bool>, Filter<Children<Node, Edge, u32>, fn(&Graph, EdgeIndex<u32>, NodeIndex<u32>) -> bool>>
[src]

For walking the Position children of the given parent node.

This first walks the Axis::X children, before walking the Axis::Y children.

pub fn graphic_children(
    &self,
    idx: NodeIndex<u32>
) -> Filter<Children<Node, Edge, u32>, fn(&Graph, EdgeIndex<u32>, NodeIndex<u32>) -> bool>
[src]

For walking the Graphic children of the given parent node.

pub fn does_edge_exist<F>(
    &self,
    parent: NodeIndex<u32>,
    child: NodeIndex<u32>,
    is_edge: F
) -> bool where
    F: Fn(Edge) -> bool
[src]

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

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

pub fn does_depth_edge_exist(
    &self,
    parent: NodeIndex<u32>,
    child: NodeIndex<u32>
) -> bool
[src]

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

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

pub fn does_position_edge_exist(
    &self,
    parent: NodeIndex<u32>,
    child: NodeIndex<u32>
) -> bool
[src]

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

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

pub fn does_graphic_edge_exist(
    &self,
    parent: NodeIndex<u32>,
    child: NodeIndex<u32>
) -> bool
[src]

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

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

pub fn does_recursive_edge_exist<F>(
    &self,
    parent: NodeIndex<u32>,
    child: NodeIndex<u32>,
    is_edge: F
) -> bool where
    F: Fn(Edge) -> bool
[src]

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.

pub fn does_recursive_depth_edge_exist(
    &self,
    parent: NodeIndex<u32>,
    child: NodeIndex<u32>
) -> bool
[src]

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.

pub fn does_recursive_graphic_edge_exist(
    &self,
    parent: NodeIndex<u32>,
    child: NodeIndex<u32>
) -> bool
[src]

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.

pub fn pre_update_cache(
    &mut self,
    root: NodeIndex<u32>,
    widget: PreUpdateCache,
    instantiation_order_idx: usize
)
[src]

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.

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

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 IndexMut<NodeIndex<u32>> for Graph[src]

impl IndexMut<EdgeIndex<u32>> for Graph[src]

impl Debug for Graph[src]

impl Index<EdgeIndex<u32>> for Graph[src]

type Output = Edge

The returned type after indexing.

impl Index<NodeIndex<u32>> for Graph[src]

type Output = Node

The returned type after indexing.

impl Walker<Graph> for Children<Node, Edge, u32>[src]

type Index = u32

The unsigned integer type used for node and edge indices.

fn next_edge(&mut self, graph: &G) -> Option<EdgeIndex<Self::Index>>[src]

The next edge in our walk for the given Graph.

fn next_node(&mut self, graph: &G) -> Option<NodeIndex<Self::Index>>[src]

The next node in our walk for the given Graph.

fn count(self, graph: &G) -> usize[src]

Counts all the steps in the entire walk of the given graph.

fn last(
    self,
    graph: &G
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>
[src]

Walks the whole walk until reaching and returning the last edge node pair.

fn last_edge(self, graph: &G) -> Option<EdgeIndex<Self::Index>>[src]

Walks the whole walk until reaching and returning the last edge.

fn last_node(self, graph: &G) -> Option<NodeIndex<Self::Index>>[src]

Walks the whole walk until reaching and returning the last node.

fn nth(
    self,
    graph: &G,
    n: usize
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>
[src]

Walks "n" number of steps and produces the resulting edge node pair.

fn nth_edge(self, graph: &G, n: usize) -> Option<EdgeIndex<Self::Index>>[src]

Walks "n" number of steps and produces the resulting edge.

fn nth_node(self, graph: &G, n: usize) -> Option<NodeIndex<Self::Index>>[src]

Walks "n" number of steps and produces the resulting node.

fn chain<O>(self, other: O) -> Chain<G, Self::Index, Self, O> where
    O: Walker<G, Index = Self::Index>, 
[src]

Produces a walker that will walk the entirey of self before walking the entirey of other.

fn filter<P>(self, predicate: P) -> Filter<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Creates a walker that applies the predicate to each element returned by this walker. The only elements that will be yielded are those that make the predicate evaluate to true. Read more

fn peekable(self) -> Peekable<G, Self::Index, Self>[src]

Creates a walker that has a .peek(&graph) method that returns an optional next neighbor.

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Creates a walker that invokes the predicate on elements until it returns false. Once the predicate returns false, that element and all further elements are yielded. Read more

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Creates a walker that yields elements so long as the predicate returns true. After the predicate returns false for the first time, no further elements will be yielded. Read more

fn skip(self, n: usize) -> Skip<G, Self::Index, Self>[src]

Creates a walker that skips the first n steps of this walk, and then yields all further steps. Read more

fn take(self, n: usize) -> Take<G, Self::Index, Self>[src]

Creates a walker that yields the first n steps of this walk.

fn all<P>(&mut self, graph: &G, predicate: P) -> bool where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Tests whether the predicate holds true for all steps in the walk.

fn any<P>(&mut self, graph: &G, predicate: P) -> bool where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Tests whether any step in the walk satisfies the given predicate. Read more

fn find<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Returns the first edge node index pair satisfying the specified predicate. Read more

fn find_edge<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<EdgeIndex<Self::Index>> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Returns the edge index satisfying the specified predicate. Read more

fn find_node<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<NodeIndex<Self::Index>> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Returns the node index satisfying the specified predicate. Read more

fn cycle(self) -> Cycle<G, Self::Index, Self> where
    Self: Clone
[src]

Repeats the walker endlessly.

fn fold<B, F>(self, init: B, graph: &G, f: F) -> B where
    F: FnMut(B, &G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> B, 
[src]

Performs a fold operation over the entire walker, returning the eventual state at the end of the walk. Read more

fn inspect<F>(self, f: F) -> Inspect<Self, F> where
    F: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>), 
[src]

Creates a walker that calls a function with a reference to each index pair before yielding them. This is often useful for debugging a walker pipeline. Read more

fn iter(self, graph: &G) -> Iter<G, Self::Index, Self>[src]

Converts the walker into an iterator yielding index pairs. Read more

fn iter_weights(self, graph: &G) -> IterWeights<G, Self::Index, Self>[src]

Converts the walker into an iterator yielding (&e, &n), where e is the edge weight for the next EdgeIndex and n is the node weight for the next NodeIndex. Read more

impl Walker<Graph> for Parents<Node, Edge, u32>[src]

type Index = u32

The unsigned integer type used for node and edge indices.

fn next_edge(&mut self, graph: &G) -> Option<EdgeIndex<Self::Index>>[src]

The next edge in our walk for the given Graph.

fn next_node(&mut self, graph: &G) -> Option<NodeIndex<Self::Index>>[src]

The next node in our walk for the given Graph.

fn count(self, graph: &G) -> usize[src]

Counts all the steps in the entire walk of the given graph.

fn last(
    self,
    graph: &G
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>
[src]

Walks the whole walk until reaching and returning the last edge node pair.

fn last_edge(self, graph: &G) -> Option<EdgeIndex<Self::Index>>[src]

Walks the whole walk until reaching and returning the last edge.

fn last_node(self, graph: &G) -> Option<NodeIndex<Self::Index>>[src]

Walks the whole walk until reaching and returning the last node.

fn nth(
    self,
    graph: &G,
    n: usize
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>
[src]

Walks "n" number of steps and produces the resulting edge node pair.

fn nth_edge(self, graph: &G, n: usize) -> Option<EdgeIndex<Self::Index>>[src]

Walks "n" number of steps and produces the resulting edge.

fn nth_node(self, graph: &G, n: usize) -> Option<NodeIndex<Self::Index>>[src]

Walks "n" number of steps and produces the resulting node.

fn chain<O>(self, other: O) -> Chain<G, Self::Index, Self, O> where
    O: Walker<G, Index = Self::Index>, 
[src]

Produces a walker that will walk the entirey of self before walking the entirey of other.

fn filter<P>(self, predicate: P) -> Filter<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Creates a walker that applies the predicate to each element returned by this walker. The only elements that will be yielded are those that make the predicate evaluate to true. Read more

fn peekable(self) -> Peekable<G, Self::Index, Self>[src]

Creates a walker that has a .peek(&graph) method that returns an optional next neighbor.

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Creates a walker that invokes the predicate on elements until it returns false. Once the predicate returns false, that element and all further elements are yielded. Read more

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Creates a walker that yields elements so long as the predicate returns true. After the predicate returns false for the first time, no further elements will be yielded. Read more

fn skip(self, n: usize) -> Skip<G, Self::Index, Self>[src]

Creates a walker that skips the first n steps of this walk, and then yields all further steps. Read more

fn take(self, n: usize) -> Take<G, Self::Index, Self>[src]

Creates a walker that yields the first n steps of this walk.

fn all<P>(&mut self, graph: &G, predicate: P) -> bool where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Tests whether the predicate holds true for all steps in the walk.

fn any<P>(&mut self, graph: &G, predicate: P) -> bool where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Tests whether any step in the walk satisfies the given predicate. Read more

fn find<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Returns the first edge node index pair satisfying the specified predicate. Read more

fn find_edge<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<EdgeIndex<Self::Index>> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Returns the edge index satisfying the specified predicate. Read more

fn find_node<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<NodeIndex<Self::Index>> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
[src]

Returns the node index satisfying the specified predicate. Read more

fn cycle(self) -> Cycle<G, Self::Index, Self> where
    Self: Clone
[src]

Repeats the walker endlessly.

fn fold<B, F>(self, init: B, graph: &G, f: F) -> B where
    F: FnMut(B, &G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> B, 
[src]

Performs a fold operation over the entire walker, returning the eventual state at the end of the walk. Read more

fn inspect<F>(self, f: F) -> Inspect<Self, F> where
    F: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>), 
[src]

Creates a walker that calls a function with a reference to each index pair before yielding them. This is often useful for debugging a walker pipeline. Read more

fn iter(self, graph: &G) -> Iter<G, Self::Index, Self>[src]

Converts the walker into an iterator yielding index pairs. Read more

fn iter_weights(self, graph: &G) -> IterWeights<G, Self::Index, Self>[src]

Converts the walker into an iterator yielding (&e, &n), where e is the edge weight for the next EdgeIndex and n is the node weight for the next NodeIndex. Read more

Auto Trait Implementations

impl Send for Graph

impl !Sync for Graph

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Content for T[src]

impl<T> SafeBorrow<T> for T[src]

impl<T> Erased for T

impl<S> FromSample<S> for S[src]

impl<T, U> ToSample<U> for T where
    U: FromSample<T>, 
[src]

impl<S, T> Duplex<S> for T where
    T: FromSample<S> + ToSample<S>, 
[src]

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.