Treeize

Struct Treeize 

Source
pub struct Treeize<T> { /* private fields */ }
Expand description

Treeize is generic node-graph container.

It holds graph state - positioned nodes and wires between their pins. It can be rendered using Treeize::show.

Implementations§

Source§

impl<T> Treeize<T>

Source

pub fn show<V>( &mut self, viewer: &mut V, style: &TreeizeStyle, id_salt: impl Hash, ui: &mut Ui, )
where V: TreeizeViewer<T>,

Render Treeize using given viewer and style into the Ui.

Source§

impl<T> Treeize<T>

Source

pub fn new() -> Self

Create a new empty Treeize.

§Examples
let treeize = Treeize::<()>::new();
Source

pub fn insert_node(&mut self, pos: Pos2, node: T) -> NodeId

Adds a node to the Treeize. Returns the index of the node.

§Examples
let mut treeize = Treeize::<()>::new();
treeize.insert_node(egui::pos2(0.0, 0.0), ());
Source

pub fn insert_node_collapsed(&mut self, pos: Pos2, node: T) -> NodeId

Adds a node to the Treeize in collapsed state. Returns the index of the node.

§Examples
let mut treeize = Treeize::<()>::new();
treeize.insert_node_collapsed(egui::pos2(0.0, 0.0), ());
Source

pub fn open_node(&mut self, node: NodeId, open: bool)

Opens or collapses a node.

§Panics

Panics if the node does not exist.

Source

pub fn remove_node(&mut self, idx: NodeId) -> T

Removes a node from the Treeize. Returns the node if it was removed.

§Panics

Panics if the node does not exist.

§Examples
let mut treeize = Treeize::<()>::new();
let node = treeize.insert_node(egui::pos2(0.0, 0.0), ());
treeize.remove_node(node);
Source

pub fn clear(&mut self) -> usize

Removes all nodes from the Treeize. Returns number of removed nodes.

§Examples
let mut treeize = Treeize::<()>::new();
treeize.clear();
Source

pub fn connect(&mut self, from: OutPinId, to: InPinId) -> bool

Connects two nodes. Returns true if the connection was successful. Returns false if the connection already exists.

§Panics

Panics if either node does not exist.

Source

pub fn disconnect(&mut self, from: OutPinId, to: InPinId) -> bool

Disconnects two nodes. Returns true if the connection was removed.

§Panics

Panics if either node does not exist.

Source

pub fn drop_inputs(&mut self, pin: InPinId) -> usize

Removes all connections to the node’s pin.

Returns number of removed connections.

§Panics

Panics if the node does not exist.

Source

pub fn drop_outputs(&mut self, pin: OutPinId) -> usize

Removes all connections from the node’s pin. Returns number of removed connections.

§Panics

Panics if the node does not exist.

Source

pub fn get_node(&self, idx: NodeId) -> Option<&T>

Returns reference to the node.

Source

pub fn get_node_mut(&mut self, idx: NodeId) -> Option<&mut T>

Returns mutable reference to the node.

Source

pub fn get_node_info(&self, idx: NodeId) -> Option<&Node<T>>

Returns reference to the node data.

Source

pub fn get_node_info_mut(&mut self, idx: NodeId) -> Option<&mut Node<T>>

Returns mutable reference to the node data.

Source

pub fn nodes(&self) -> NodesIter<'_, T>

Iterates over shared references to each node.

Source

pub fn nodes_mut(&mut self) -> NodesIterMut<'_, T>

Iterates over mutable references to each node.

Source

pub fn nodes_pos(&self) -> NodesPosIter<'_, T>

Iterates over shared references to each node and its position.

Source

pub fn nodes_pos_mut(&mut self) -> NodesPosIterMut<'_, T>

Iterates over mutable references to each node and its position.

Source

pub fn node_ids(&self) -> NodesIdsIter<'_, T>

Iterates over shared references to each node and its identifier.

Source

pub fn nodes_ids_mut(&mut self) -> NodesIdsIterMut<'_, T>

Iterates over mutable references to each node and its identifier.

Source

pub fn nodes_pos_ids(&self) -> NodesPosIdsIter<'_, T>

Iterates over shared references to each node, its position and its identifier.

Source

pub fn nodes_pos_ids_mut(&mut self) -> NodesPosIdsIterMut<'_, T>

Iterates over mutable references to each node, its position and its identifier.

Source

pub fn nodes_info(&self) -> NodeInfoIter<'_, T>

Iterates over shared references to each node data.

Source

pub fn nodes_info_mut(&mut self) -> NodeInfoIterMut<'_, T>

Iterates over mutable references to each node data.

Source

pub fn nodes_ids_data(&self) -> NodeIdsDataIter<'_, T>

Iterates over shared references to each node id and data.

Source

pub fn nodes_ids_data_mut(&mut self) -> NodeIdsDataIterMut<'_, T>

Iterates over mutable references to each node id and data.

Source

pub fn wires(&self) -> impl Iterator<Item = (OutPinId, InPinId)> + '_

Iterates over wires.

Source

pub fn in_pin(&self, pin: InPinId) -> InPin

Returns input pin of the node.

Source

pub fn out_pin(&self, pin: OutPinId) -> OutPin

Returns output pin of the node.

Trait Implementations§

Source§

impl<T: Clone> Clone for Treeize<T>

Source§

fn clone(&self) -> Treeize<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Treeize<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Treeize<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Index<NodeId> for Treeize<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, idx: NodeId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<NodeId> for Treeize<T>

Source§

fn index_mut(&mut self, idx: NodeId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Treeize<T>

§

impl<T> RefUnwindSafe for Treeize<T>
where T: RefUnwindSafe,

§

impl<T> Send for Treeize<T>
where T: Send,

§

impl<T> Sync for Treeize<T>
where T: Sync,

§

impl<T> Unpin for Treeize<T>
where T: Unpin,

§

impl<T> UnwindSafe for Treeize<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,