Crate egui_nodes

Source
Expand description

egui_nodes: A Egui port of imnodes

§Using egui_nodes

There are some simple examples here

Here is the basic usage:

pub fn example_graph(ctx: &mut Context, links: &mut Vec<(usize, usize)>, ui: &mut Ui) {
    // add nodes with attributes
    let nodes = vec![
        NodeConstructor::new(0, Default::default())
            .with_title(|ui| ui.label("Example Node A"))
            .with_input_attribute(0, Default::default(), |ui| ui.label("Input"))
            .with_static_attribute(1, |ui| ui.label("Can't Connect to Me"))
            .with_output_attribute(2, Default::default(), |ui| ui.label("Output")),
        NodeConstructor::new(1, Default::default())
            .with_title(|ui| ui.label("Example Node B"))
            .with_static_attribute(3, |ui| ui.label("Can't Connect to Me"))
            .with_output_attribute(4, Default::default(), |ui| ui.label("Output"))
            .with_input_attribute(5, Default::default(), |ui| ui.label("Input"))
    ];
 
    // add them to the ui
    ctx.show(
        nodes,
        links.iter().enumerate().map(|(i, (start, end))| (i, *start, *end, LinkArgs::default())),
        ui
    );
     
    // remove destroyed links
    if let Some(idx) = ctx.link_destroyed() {
        links.remove(idx);
    }

    // add created links
    if let Some((start, end, _)) = ctx.link_created() {
        links.push((start, end))
    }
}

Structs§

  • The Context that tracks the state of the node editor
  • This controls the modifers needed for certain mouse interactions
  • The Color Style of a Link. If feilds are None then the Context style is used
  • The Style of a Node. If feilds are None then the Context style is used
  • Used to construct a node and stores the relevant ui code for its title and attributes This is used so that the nodes can be rendered in the context depth order
  • The Visual Style of a Link. If feilds are None then the Context style is used. shape defualts to CircleFilled
  • The style used by a context Example:

Enums§

  • Controls the way that attribute pins behave
  • Represents different color style values used by a Context
  • Used to track which Egui Modifier needs to be pressed for certain IO actions
  • Controls the shape of an attribut pin. Triangle and TriangleFilled are not currently implemented and will not be drawn
  • Controls some style aspects
  • Represents different style values used by a Context