Gazpatcho

A Rust library providing a graphical node-based graph editor.

Example

This library can be used as to draw a user interface, allowing users to model graphs that would be later interpreed and acted upon by the backend of the application.

There are four main parts of the API:

Documentation:

Usage

Add the following to your Cargo.toml:

toml [dependencies] gazpatcho = "1.4"

The following code runs an instance of Gazpatcho UI. There will be a single type of node available, with one input and one output pin, and with switch that can be set on or off by the user. When the user performs any changes, a new report will be sent to the run callback, desribing the current state of the graph. In a real application, the dbg! call would be replaced by something more useful:

``` rust use gazpatcho::config::*;

fn main() { let config = Config { nodetemplates: vec![ NodeTemplate { label: "Example node".toowned(), class: "examplenode".toowned(), pins: vec![ Pin { label: "Input".toowned(), class: "in".toowned(), direction: Input, }, Pin { label: "Output".toowned(), class: "out".toowned(), direction: Output, }, ], widgets: vec![Switch { label: "Switch".toowned(), key: "switch".toowned(), }], } ], };

gazpatcho::run_with_callback("Application Name", config, |report| {
    // Act upon the current report
    dbg!(report);

    // Respond with change requests
    vec![
        // Request::SetValue { ... }
    ]
});

} ```

See the documentation to learn more about the Config and Report structures. If you prefer tinkering with code over reading documentation, see and try included examples:

shell cargo run --example main

License

Gazpatcho is distributed under the terms of the General Public License version 3. See LICENSE for details.

Changelog

Read the CHANGELOG.md to learn about changes introduced in each release.