Struct Context

Source
pub struct Context {
    pub io: IO,
    pub style: Style,
    /* private fields */
}
Expand description

The Context that tracks the state of the node editor

Fields§

§io: IO§style: Style

Implementations§

Source§

impl Context

Source

pub fn show<'a>( &mut self, nodes: impl IntoIterator<Item = NodeConstructor<'a>>, links: impl IntoIterator<Item = (usize, usize, usize, LinkArgs)>, ui: &mut Ui, ) -> Response

Displays the current state of the editor on a give Egui Ui as well as updating user input to the context

Source

pub fn attribute_flag_push(&mut self, flag: AttributeFlags)

Push a sigle AttributeFlags value, by default only None is set. Used for pins that don’t have a specific attribute flag specified

Source

pub fn attribute_flag_pop(&mut self)

Remove the last added AttributeFlags value

Source

pub fn color_style_push(&mut self, item: ColorStyle, color: Color32)

Changes the current colors used by the editor

Source

pub fn color_style_pop(&mut self)

Revert the last color change

Source

pub fn style_var_push(&mut self, item: StyleVar, value: f32)

Change a context style value

Source

pub fn style_var_pop(&mut self)

Revert the last context style change

Source

pub fn set_node_pos_screen_space( &mut self, node_id: usize, screen_space_pos: Pos2, )

Source

pub fn set_node_pos_editor_space( &mut self, node_id: usize, editor_space_pos: Pos2, )

Source

pub fn set_node_pos_grid_space(&mut self, node_id: usize, grid_pos: Pos2)

Source

pub fn set_node_draggable(&mut self, node_id: usize, draggable: bool)

Source

pub fn get_node_pos_screen_space(&self, node_id: usize) -> Option<Pos2>

Source

pub fn get_node_pos_editor_space(&self, node_id: usize) -> Option<Pos2>

Source

pub fn get_node_pos_grid_space(&self, node_id: usize) -> Option<Pos2>

Source

pub fn node_hovered(&self) -> Option<usize>

Check if there is a node that is hovered by the pointer

Check if there is a link that is hovered by the pointer

Source

pub fn pin_hovered(&self) -> Option<usize>

Check if there is a pin that is hovered by the pointer

Source

pub fn num_selected_nodes(&self) -> usize

Source

pub fn get_selected_nodes(&self) -> Vec<usize>

Source

pub fn clear_node_selection(&mut self)

Source

pub fn active_attribute(&self) -> Option<usize>

Check if an attribute is currently being interacted with

Has a new link been created from a pin?

Has a link been dropped? if including_detached_links then links that were detached then dropped are included

Has a new link been created? -> Option<start_pin, end_pin created_from_snap>

Has a new link been created? Includes start and end node -> Option<start_pin, start_node, end_pin, end_node created_from_snap>

Source

pub fn get_panning(&self) -> Vec2

Source

pub fn reset_panniing(&mut self, panning: Vec2)

Source

pub fn get_node_dimensions(&self, id: usize) -> Option<Vec2>

Trait Implementations§

Source§

impl Debug for Context

Source§

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

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

impl Default for Context

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> 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, 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.