Skip to main content

Crate slint_node_editor

Crate slint_node_editor 

Source
Expand description

§Slint Node Editor Library

A flexible, generic Slint component library for building visual graph editors. Supports data flow diagrams, state machines, shader graphs, and any visual node-based interface.

§Features

  • Generic Design - Works with any node and link data structures
  • Trait-Based Architecture - Zero coupling via NodeGeometry and LinkModel traits
  • Callback-Based Computation - Delegates expensive operations to Rust for performance
  • Opaque Pin IDs - Library never prescribes pin encoding; applications choose
  • Extensible - Easy to customize pins, styling, node types, and behaviors

§Quick Start

This is a composition fragment. The compiled downstream quick start contains the Cargo manifest, build script, Slint UI and Rust host.

import { NodeEditor, BaseNode, Pin, PinTypes } from "@nodeeditor";

export component MainWindow inherits Window {
    NodeEditor {
        // Your nodes and links here
    }
}

§Core Components

These are Slint components, imported from @nodeeditor. Only the top-level editor has a generated Rust counterpart (nodeeditor::NodeEditor); the rest exist solely in .slint.

  • NodeEditor - Main graph editor component
  • BaseNode - Base component for creating custom nodes
  • Pin - Connection point component
  • Link - Bezier curve link component
  • BaseGroup / GroupSheet - Backing sheet behind a group of nodes
  • Minimap - Bird’s-eye view component

§Accessibility

Library components include accessibility roles for screen readers and MCP introspection. When creating custom node components, set accessible-label to the node’s display title:

component MyNode inherits BaseNode {
    in property <string> title;
    accessible-label: title;  // override default "Node <id>"
}

§Rust Helpers

This crate provides Rust helper functions for common operations:

§Limitations

One NodeEditor per window. The library uses Slint globals (ViewportState, DragState, NodeEditorInternalCallbacks, etc.) for internal communication between BaseNode/Pin components and the NodeEditor. Since Slint globals are window-level singletons, only one NodeEditor instance per Window is supported. Multiple editors in separate windows work fine. This limitation will be lifted once Slint introduces component-scoped globals.

See the README for detailed documentation and examples.

Re-exports§

pub use nodeeditor::BoxSelectionModifier;
pub use nodeeditor::GroupData;
pub use nodeeditor::LinkCreationState;
pub use nodeeditor::LinkData;
pub use nodeeditor::LinkPath;
pub use nodeeditor::MinimapNode;
pub use nodeeditor::MinimapPosition;
pub use grid::generate_grid_commands;
pub use hit_test::distance_to_polyline;
pub use hit_test::find_pin_at;
pub use hit_test::nodes_in_selection_box;
pub use hit_test::BezierLinkRoute;
pub use hit_test::LinkGeometry;
pub use hit_test::LinkRoute;
pub use hit_test::NodeGeometry;
pub use hit_test::PinGeometry;
pub use hit_test::PolylineLinkRoute;
pub use hit_test::SimpleLinkGeometry;
pub use hit_test::SimpleNodeGeometry;
pub use path::generate_bezier_path;
pub use path::generate_partial_bezier_path;
pub use state::GeometryCache;
pub use state::StoredPin;
pub use controller::NodeEditorController;
pub use graph::BasicLinkValidator;
pub use graph::CompositeValidator;
pub use graph::GraphLogic;
pub use graph::LinkModel;
pub use graph::LinkValidator;
pub use graph::MovableNode;
pub use graph::NoDuplicatesValidator;
pub use graph::ValidationError;
pub use graph::ValidationResult;
pub use groups::Bounds;
pub use groups::Dragged;
pub use groups::GroupLogic;
pub use groups::GroupMember;
pub use groups::GroupModel;
pub use layout::sugiyama_layout;
pub use layout::sugiyama_layout_from_cache;
pub use layout::Direction;
pub use layout::NodePosition;
pub use layout::RankAlignment;
pub use layout::SugiyamaConfig;
pub use links::LinkManager;
pub use setup::NodeEditorSetup;
pub use tracking::GeometryTracker;

Modules§

controller
High-level controller for node editor applications.
graph
grid
groups
Host-side group helpers.
hit_test
layout
Sugiyama hierarchical graph layout.
links
Link management for the node editor.
nodeeditor
The Slint components, compiled as a library module.
path
selection
Host-side selection helpers.
setup
Simplified setup helpers for NodeEditor with globals architecture.
state
tracking
Convenience helpers for geometry tracking setup.

Macros§

wire_groups
Wire node groups for a host with one node model and one group model.
wire_node_editor
Wire up all NodeEditor callbacks with a single macro call.
wire_selection
Wire the editor’s selection intents, using your model rows as the store.