Skip to content

About

Advanced Node Editor is a modular C++ node editor built with ImGui. It features nodes, pins, groups, custom styling, connections, and full interaction logic. Ideal for integration in rendering tools, visual scripting, or procedural editors.

Resources

Stars

7 stars

Watchers

2 watching

Forks

Latest commit

 

History

63 Commits

Folders and files

Repository files navigation

Advanced Node Editor

License: MIT C++20 Version Downloads

A modern C++20 framework for creating interactive graphical node editors with hierarchical subgraph support, real-time evaluation, and a customizable ImGui interface.

Features

  • Complete Node Management: Creation, deletion, selection, and manipulation
  • Connection System: Node-to-node connections with type validation
  • Hierarchical Subgraphs: Full support for nested graph structures
  • Real-time Evaluation: Dependency-ordered evaluation system
  • Modern Interface: Interactive view with zoom, pan, and automatic centering
  • Visual Groups: Logical organization of nodes into groups
  • Connection Rerouting: Redirection points for complex connections
  • Parameter Metadata: Optional node parameter descriptors for editor-side controls
  • Event System: Real-time event notifications via callbacks
  • Clean API: Intuitive interface for seamless integration

(Figure 1 : Little game engine made with advanced node editor)

image

Installation

Prerequisites

  • C++20 compatible compiler (GCC 10+, Clang 10+, MSVC 2019+)
  • CMake 3.31+
  • OpenGL support
  • ImGui, SDL2, and GoogleTest are fetched by CMake by default

Build

cmake -S . -B cmake-build-debug -DBUILD_TESTS=ON "-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
cmake --build cmake-build-debug --target AdvancedNodeEditor
cmake --build cmake-build-debug --target node_editor_tests
ctest --test-dir cmake-build-debug --output-on-failure

On Windows, the demo executable is generated as cmake-build-debug/AdvancedNodeEditor.exe or in the build directory selected with -B.

Integration

#include "AdvancedNodeEditor/NodeEditorAPI.h"
using namespace NodeEditorCore;

Quick Start

Basic Initialization

NodeEditorAPI editor;
editor.initialize();
editor.setWindowSize(1280, 720);

Node Type Definition

NodeEditorAPI::NodeDefinition mathNode;
mathNode.type = "math_add";
mathNode.name = "Addition";
mathNode.category = "Math";
mathNode.description = "Adds two numeric values";
mathNode.iconSymbol = "+";
mathNode.inputs = {{"A", PinType::Blue}, {"B", PinType::Blue}};
mathNode.outputs = {{"Result", PinType::Green}};

editor.registerNodeType(mathNode);

Node Creation and Connection

UUID nodeA = editor.createNode("math_add", "Addition 1", Vec2(100, 100));
UUID nodeB = editor.createNode("math_add", "Addition 2", Vec2(300, 100));

UUID connection = editor.connectNodes(nodeA, "Result", nodeB, "A");

Render Loop

while (running) {
    editor.beginFrame();
    editor.render();
    editor.endFrame();
}

API Reference

Node Management

  • createNode(type, name, position) - Creates a new node
  • removeNode(nodeId) - Removes a node
  • selectNode(nodeId, append) - Selects a node
  • deselectAllNodes() - Deselects all nodes
  • getSelectedNodes() - Gets selected nodes

Connection Management

  • connectNodes(startNode, outputPin, endNode, inputPin) - Connects two nodes
  • disconnectNodes(connectionId) - Disconnects nodes
  • addRerouteToConnection(connectionId, position) - Adds reroute point

View Management

  • centerView() - Centers view on all nodes
  • centerOnNode(nodeId) - Centers view on specific node
  • zoomToFit(padding) - Fits all nodes in view
  • zoomToFitSelected(padding) - Fits selected nodes in view
  • setViewPosition(position) - Sets view position
  • setViewScale(scale) - Sets zoom level

Subgraph Management

  • createGraph(name) - Creates new graph
  • switchToGraph(graphId) - Switches to graph
  • enterSubgraph(subgraphId) - Enters subgraph
  • exitSubgraph() - Exits current subgraph

Evaluation System

  • registerEvaluator(nodeType, evaluator) - Registers evaluation function
  • evaluateGraph(outputNodeId) - Evaluates graph
  • setConstantValue(nodeId, value) - Sets constant value
  • getConstantValue(nodeId) - Gets constant value
  • setPersistentOutputValue(nodeId, outputName, value) - Stores a named output value

Event Callbacks

  • addNodeCreatedListener(callback) - Node creation listener
  • addNodeRemovedListener(callback) - Node removal listener
  • addConnectionCreatedListener(callback) - Connection creation listener
  • addConnectionRemovedListener(callback) - Connection removal listener
  • removeNodeCreatedListener(handle) - Removes a registered node listener
  • removeConnectionCreatedListener(handle) - Removes a registered connection listener

Data Types

NodeDefinition

struct NodeDefinition {
    struct ParameterDescriptor {
        std::string name;                    // Stable parameter id
        std::string label;                   // Display label
        ParameterType type;                  // Float, Int, Bool, String, Vec3, File, Color, Enum
        std::any defaultValue;               // Optional default value
        std::string drivenPin;               // Optional pin controlled by this parameter
    };

    std::string type;                                             // Unique node type
    std::string name;                                             // Display name
    std::string category;                                         // Organization category
    std::string description;                                      // Tooltip description
    std::string iconSymbol;                                       // Display icon
    std::vector<std::pair<std::string, PinType>> inputs;         // Input pins
    std::vector<std::pair<std::string, PinType>> outputs;        // Output pins
    std::vector<ParameterDescriptor> parameters;                  // Optional UI parameters
};

EvaluationResult

struct EvaluationResult {
    std::any value;                      // Result value
    std::vector<UUID> evaluationOrder;   // Evaluation order
};

Advanced Examples

Mathematical Evaluation System

editor.registerEvaluator("math_add", [](const std::vector<std::any>& inputs) -> std::any {
    if (inputs.size() >= 2) {
        try {
            float a = std::any_cast<float>(inputs[0]);
            float b = std::any_cast<float>(inputs[1]);
            return a + b;
        } catch (const std::bad_any_cast&) {
            return 0.0f;
        }
    }
    return 0.0f;
});

Connection Path Tracing

std::vector<UUID> path = editor.traceConnectionPath(
    startNodeId, "output",
    endNodeId, "input"
);

for (const auto& connectionId : path) {
    // Process each connection in path
}

Group Management

UUID groupId = editor.createGroup("Math Operations", Vec2(50, 50), Vec2(400, 300));
editor.addNodeToGroup(nodeA, groupId);
editor.addNodeToGroup(nodeB, groupId);

Event Handling

ListenerHandle nodeCreated = editor.addNodeCreatedListener([](const UUID& nodeId) {
    std::cout << "Node created: " << nodeId << std::endl;
});

ListenerHandle connectionCreated = editor.addConnectionCreatedListener([](const UUID& connectionId) {
    std::cout << "Connection created: " << connectionId << std::endl;
});

Advanced Configuration

Custom Pin Types

The framework supports various pin types through the PinType enumeration. You can extend the system to support custom types.

Command System

editor.executeCommand("custom_command", customData);

Direct Editor Access

NodeEditor* underlyingEditor = editor.getUnderlyingEditor();
// Direct access to advanced functionality

Customization

The framework is designed to be extensible:

  • Custom Rendering: Implement custom renderers
  • Node Types: Create complex node types
  • Evaluators: Flexible evaluation system
  • Interface: Full UI customization

Performance

  • Optimizations: Efficient rendering with automatic culling
  • Memory: Intelligent resource management
  • Multithreading: Parallel evaluation support

Error Handling

Exception Management

try {
    editor.zoomToFit();
} catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
}

Validation

  • Automatic connection validation
  • Pin type checking
  • Cycle detection in graphs

Contributing

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Create a Pull Request

License

MIT License

Copyright (c) 2025 Theo Baudoin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Links


Advanced Node Editor Framework - Build powerful and intuitive node editors with C++20

About

Advanced Node Editor is a modular C++ node editor built with ImGui. It features nodes, pins, groups, custom styling, connections, and full interaction logic. Ideal for integration in rendering tools, visual scripting, or procedural editors.

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages