Crate egui_nodes

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§

Context
The Context that tracks the state of the node editor
IO
This controls the modifers needed for certain mouse interactions
LinkArgs
The Color Style of a Link. If feilds are None then the Context style is used
NodeArgs
The Style of a Node. If feilds are None then the Context style is used
NodeConstructor
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
PinArgs
The Visual Style of a Link. If feilds are None then the Context style is used. shape defualts to CircleFilled
Style
The style used by a context Example:

Enums§

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