imgui-node-editor

Node Editor using ImGui prototype

Github星跟踪图

Node Editor in ImGui

Appveyor status
Travis status

About

This is an implementaion of node editor with ImGui-like API.

Project purpose is to serve as a basis for more complex solutions like blueprint editors.

Preview

Node Editor is build around an idea "draw your content, we do the rest", which mean interactions are handled by editor, content rendering is handled by user. Editor will take care of:

  • placing your node in the word
  • dragging nodes
  • zoom and scrolling
  • selection
  • various interaction that can be quieried by API (creation, deletion, selection changes, etc.)

Here are some highlights:

  • Node movement and selection is handled internally

  • Node and pin contents are fully customizable

  • Fully stylled, default theme is modeled after UE4 blueprints

    • Flexibe enough to produce such nodes:

      image
      image
      image

    • Customizable links based on Bézier curves:

      image
      image
      image

  • Automatic highlights for nodes, pins and links:

    image

  • Smooth navigation and selection

  • Node state can be saved in user context, so layout will not break

  • Selection rectangles and group dragging

  • Context menu support

  • Basic shortcuts support (cut/copy/paste/delete)

  • ImGui style API

Editor is used to implement blueprint editor in Spark CE engine, it proved itself there by allowing to do everything we needed. Therefore it is now slowly moving into stable state from beeing a prototype.

Please report issues or questions if something isn't clear.

Dependencies

Code

Editor code is in NodeEditor directory alone and can be build with CMake:

Windows:
    cmake -H. -BBuild -G "Visual Studio 15 2017 Win64"

macOS:
    cmake -H. -BBuild -G "Xcode"

Linux:
    cmake -H. -BBuild -G "Unix Makefiles"

Build:
    cmake --build Build --config Release

You will find examples in Build\Bin directory.

Source code target to be comatible with C++14.

Example

Main node editor header is located in imgui_node_editor.h.

Minimal example of one node can be found in Simple.cpp.
Press 'F' in editor to focus on editor content if you see only grid.

# include "Application.h"
# include <imgui_node_editor.h>

namespace ed = ax::NodeEditor;

static ed::EditorContext* g_Context = nullptr;

void Application_Initialize()
{
    g_Context = ed::CreateEditor();
}

void Application_Finalize()
{
    ed::DestroyEditor(g_Context);
}

void Application_Frame()
{
    ed::SetCurrentEditor(g_Context);

    ed::Begin("My Editor");

    int uniqueId = 1;

    // Start drawing nodes.
    ed::BeginNode(uniqueId++);
        ImGui::Text("Node A");
        ed::BeginPin(uniqueId++, ed::PinKind::Input);
            ImGui::Text("-> In");
        ed::EndPin();
        ImGui::SameLine();
        ed::BeginPin(uniqueId++, ed::PinKind::Output);
            ImGui::Text("Out ->");
        ed::EndPin();
    ed::EndNode();

    ed::End();
}

Result:

00-Simple.png

For more details please visit Examples folder.

Blueprints Example

Preview2

Here is Node Editor at work in Spark CE

image
image

主要指标

概览
名称与所有者thedmd/imgui-node-editor
主编程语言C++
编程语言C++ (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2017-12-10 14:25:36
推送于2024-07-21 23:47:56
最后一次提交2023-12-27 13:15:30
发布数4
最新版本名称v0.9.3 (发布于 )
第一版名称v0.1-prototype (发布于 )
用户参与
星数4k
关注者数87
派生数579
提交数449
已启用问题?
问题数270
打开的问题数91
拉请求数8
打开的拉请求数14
关闭的拉请求数30
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?