feat(shaders_lab): visual node editor (imgui-node-editor) + multi-source
- cpp/vendor/imgui-node-editor: vendorized thedmd/imgui-node-editor v0.9.4 - cpp/functions/gfx/dag_node_editor: new visual pipeline editor replacing dag_panel - DagStep: source_ids[4] + editor_pos + editor_uid (multi-input support) - DagNodeDef: num_inputs explicit; circle reclassified as Op - dag_compile: N inputs per node, topological ordering preserved - main: use node editor; destroy on shutdown - patch imgui_extra_math.inl: guard operator*(float, ImVec2) for imgui >= 18955 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+289
@@ -0,0 +1,289 @@
|
||||
v0.9.4 (WIP):
|
||||
|
||||
NEW: Editor: Add smooth zoom (#266)
|
||||
|
||||
BUGFIX: Canvas: Remember index of first command buffer to not miss updating any used (#260)
|
||||
|
||||
BUGFIX: Editor: Don't duplicated ImVec2/ImVec3 == != operators defined since ImGui r19002 (#268)
|
||||
|
||||
BUGFIX: Examples: Use imgui_impl_opengl3_loader.h instead of gl3w (#264)
|
||||
|
||||
v0.9.3 (2023-10-14):
|
||||
|
||||
CHANGE: Canvas: Use ImDrawCallback_ImCanvas macro as draw callback sentinel (#256), thanks @nspitko
|
||||
|
||||
BUGFIX: Canvas: Ensure SentinelDrawCallback cleanup (#255)
|
||||
|
||||
BUGFIX: Editor: Don't call Reasume/Suspend on invisible canvas (#255)
|
||||
|
||||
v0.9.2 (2023-09-01):
|
||||
|
||||
NEW: Editor: Add offset of hover/select to style (thanks @MultiPain)
|
||||
|
||||
NEW: Editor: Add IMGUI_NODE_EDITOR_API to support building editor as a shared library (#189)
|
||||
|
||||
NEW: Canvas: Add IMGUIEX_CANVAS_API to support building canvas as a shared library (#189)
|
||||
|
||||
CHANGE: Editor: Support ImGui r18836 after SetItemUsingMouseWheel removal (#218), thanks @ocornut
|
||||
|
||||
CHANGE: Editor: Define IMGUI_DEFINE_MATH_OPERATORS before <imgui.h> (#209), thanks @ocornut
|
||||
|
||||
CHANGE: Examples: Define IMGUI_DEFINE_MATH_OPERATORS before <imgui.h> (#209), thanks @ocornut
|
||||
|
||||
CHANGE: Canvas: Don't use deprecated SetItemAllowOverlap (#250)
|
||||
|
||||
CHANGE: Examples: Don't use deprecated SetItemAllowOverlap (#250)
|
||||
|
||||
CHANGE: Editor: Define IMGUI_DEFINE_MATH_OPERATORS before <imgui.h> (#209), thanks @ocornut
|
||||
|
||||
CHANGE: Editor: Unary operator- for ImVec2 is defined by ImGui since r18955 (#248)
|
||||
|
||||
BUGFIX: Editor: Correctly initialize 'width' for view resize code (thx @gnif)
|
||||
|
||||
BUGFIX: Examples: Handle node deletion before links (#182)
|
||||
Deleting node queue connected links for deletion.
|
||||
|
||||
BUGFIX: Examples: Simplify and fix drawing of node header line (#180)
|
||||
|
||||
BUGFIX: Editor: Cleanup tabs.
|
||||
|
||||
BUGFIX: Editor: Use ImGuiKey directly with ImGui r18822 (#183)
|
||||
|
||||
BUGFIX: Examples: Use ImGuiKey directly with ImGui r18822 (#183)
|
||||
|
||||
BUGFIX: Examples: Use ImGuiKey_KeypadEnter with ImGui r18604 (#183)
|
||||
|
||||
BUGFIX: Examples: Add missing <cstdint> include for std::intptr_t (#199)
|
||||
|
||||
BUGFIX: Examples: Don't use empty string as identifier
|
||||
|
||||
BUGFIX: Editor: Clean long to int implicit cast warning in crude_json
|
||||
|
||||
BUGFIX: Canvas: Ensure canvas draw commands are separated from other ImGui draw commands (#205, #250)
|
||||
|
||||
BUGFIX: Editor: Don't call Canvas.End() when Canvas.Begin() failed (#186), thanks @pthom, @TheZoc
|
||||
|
||||
|
||||
v0.9.1 (2022-08-27):
|
||||
|
||||
CHANGE: Remove unwanted extra frame height from node bottom
|
||||
|
||||
CHANGE: Allow to specify if links of deleted node should also be automatically deleted
|
||||
Now it is possible to delete only node without automatically serving links,
|
||||
application can choose to do this operation by itself and for example
|
||||
short circuit flow links ot do any other special operation.
|
||||
|
||||
CHANGE: Canvas: Allow to overlap canvas widget
|
||||
|
||||
CHANGE: Natvis: Move crude_json natvis to separate file
|
||||
|
||||
CHANGE: Natvis: Show readable NodeId/PinId/LinkId
|
||||
|
||||
CHANGE: Make Navigate action to honor duration
|
||||
|
||||
CHANGE: Travis: Use Ubuntu Bionic (18.04) for CI, to get newer version of GLFW3
|
||||
|
||||
CHANGE: Editor: Make action button internally configurable
|
||||
|
||||
CHANGE: Make Node Editor forward compatible with ImGui 1.80+ (#112)
|
||||
We're keeping backward compatibility with pre 1.8x versions.
|
||||
|
||||
CHANGE: Update internal copy ImGui to 1.84 (WIP) (3512f2c2c283ec86) (#107)
|
||||
Internal copy has two PR's merged:
|
||||
https://github.com/thedmd/imgui/tree/feature/layout - used in blueprints example only
|
||||
https://github.com/thedmd/imgui/tree/feature/extra-keys - optional: used by Node Editor if present
|
||||
|
||||
CHANGE: Use github actions instead of Travis and AppVeyor (#113)
|
||||
|
||||
CHANGE: Delete operation on node/link will remove internal object (#173)
|
||||
|
||||
CHANGE: Natvis: Add crude_json::value visualization
|
||||
|
||||
NEW: All source components are now versioned
|
||||
|
||||
NEW: Make view state independent of window resolution.
|
||||
|
||||
NEW: Editor can now break links connected specified node or pin
|
||||
New API:
|
||||
int BreakLinks(NodeId nodeId);
|
||||
int BreakLinks(PinId pinId);
|
||||
|
||||
NEW: Editor can now tell if node or pin has any links attached
|
||||
New API:
|
||||
bool HasAnyLinks(NodeId nodeId);
|
||||
bool HasAnyLinks(PinId pinId);
|
||||
|
||||
NEW: Editor can be queried if particular node or link is selected
|
||||
New API:
|
||||
bool IsNodeSelected(NodeId nodeId);
|
||||
bool IsLinkSelected(LinkId linkId);
|
||||
|
||||
NEW: Editor now can return pins of the link
|
||||
New API:
|
||||
bool GetLinkPins(LinkId linkId, PinId* startPinId, PinId* endPinId);
|
||||
|
||||
`startPinId` and `endPinId` may be null if caller is not interested
|
||||
in particular id.
|
||||
|
||||
NEW: Editor now return ids of hovered node/pin/link
|
||||
New API:
|
||||
NodeId GetHoveredNode();
|
||||
PinId GetHoveredPin();
|
||||
LinkId GetHoveredLink();
|
||||
|
||||
NEW: Add SetGroupSize() to explicitly set group size
|
||||
New API:
|
||||
void SetGroupSize(NodeId nodeId, const ImVec2& size);
|
||||
|
||||
NEW: crude_json: Add save() and load()
|
||||
|
||||
When CRUDE_JSON_IO == 1 value will have load() and save()
|
||||
function implemented using stdio.h FILE.
|
||||
|
||||
NEW: crude_json: Add erase() and get_ptr()
|
||||
|
||||
NEW: Application overhaul
|
||||
- Convert from function based to inheritable class
|
||||
- Add ability to close app and change title from code
|
||||
- Add ability to control main window flags (ex. show menubar)
|
||||
- Save ImGui state to ini file
|
||||
- Render using pre-multiplied alpha textures
|
||||
- Add extra fonts to examples.
|
||||
|
||||
NEW: Reintegrate Widgets example from @crolando (#77)
|
||||
|
||||
NEW: User can now override button indices for various actions (#88)
|
||||
New API in Config:
|
||||
int DragButtonIndex; // Mouse button index drag action will react to (0-left, 1-right, 2-middle)
|
||||
int SelectButtonIndex; // Mouse button index select action will react to (0-left, 1-right, 2-middle)
|
||||
int NavigateButtonIndex; // Mouse button index navigate action will react to (0-left, 1-right, 2-middle)
|
||||
int ContextMenuButtonIndex; // Mouse button index context menu action will react to (0-left, 1-right, 2-middle)
|
||||
|
||||
NEW: Flow direction can now be picked per flow (#104)
|
||||
New API:
|
||||
enum class FlowDirection
|
||||
{
|
||||
Forward,
|
||||
Backward
|
||||
};
|
||||
|
||||
void Flow(LinkId linkId, FlowDirection direction = FlowDirection::Forward);
|
||||
|
||||
NEW: Editor can now return number of submitted nodes (#81)
|
||||
New API:
|
||||
int GetNodeCount(); // Returns number of submitted nodes since Begin() call
|
||||
|
||||
NEW: Editor can now return nodes in order they are drawn (#81)
|
||||
New API:
|
||||
int GetOrderedNodeIds(NodeId* nodes, int size); // Fills an array with node id's in order they're drawn; up to 'size` elements are set. Returns actual size of filled id's.
|
||||
|
||||
NEW: Editor now allow to set Z position for nodes (#109)
|
||||
|
||||
Nodes with higher Z position are drawn on top of ones with lower.
|
||||
|
||||
New API:
|
||||
void SetNodeZPosition(NodeId nodeId, float z); // Sets node z position, nodes with higher value are drawn over nodes with lower value
|
||||
float GetNodeZPosition(NodeId nodeId); // Returns node z position, defaults is 0.0f
|
||||
|
||||
NEW: Editor: SaveReasonFlags now inform about node creation/deletion
|
||||
|
||||
NEW: Editor: Expose button index background was clicked with
|
||||
New API:
|
||||
ImGuiMouseButton GetBackgroundClickButtonIndex(); // -1 if none
|
||||
ImGuiMouseButton GetBackgroundDoubleClickButtonIndex(); // -1 if none
|
||||
|
||||
NEW: Editor: Expose configuration editor was created with
|
||||
New API:
|
||||
const Config& GetConfig(EditorContext* ctx = nullptr);
|
||||
|
||||
NEW: Editor: Add highlighting of Links connected to selected Node (#175)
|
||||
New API:
|
||||
StyleColor_HighlightLinkBorder
|
||||
StyleVar_HighlightConnectedLinks
|
||||
|
||||
NEW: Editor: Add ability to snap link origin to pin direction (#167)
|
||||
New API:
|
||||
StyleVar_SnapLinkToPinDir
|
||||
|
||||
NEW: Editor: Add way to override default zoom levels (#174)
|
||||
New API:
|
||||
ImVector<float> Config::CustomZoomLevels;
|
||||
|
||||
NEW: Editor: Add canvas size mode (#170)
|
||||
|
||||
Config can now decide how editor should resize view when changing size.
|
||||
|
||||
New API:
|
||||
enum class CanvasSizeMode;
|
||||
Config::CanvasSizeMode;
|
||||
|
||||
BUGFIX: Avoid crash while destroying editor.
|
||||
|
||||
BUGFIX: Save draw list used by editor between Begin() and End()
|
||||
There is a chance ImGui::GetWindowDrawList() will return different draw list
|
||||
while nodes are being composed. To avoid troubles of manipulating incorrect
|
||||
draw list one obtained in Begin() is remembered and used.
|
||||
|
||||
BUGFIX: Avoid division by zero in ImCubicBezierBoundingRect
|
||||
|
||||
BUGFIX: Don't stuck in delete action if user does not handle it
|
||||
|
||||
BUGFIX: Enable use channel splitter inside Begin/End for node and pin. #28
|
||||
|
||||
BUGFIX: Don't manipulate channels when editor is suspended #28
|
||||
|
||||
BUGFIX: Fix ObjectId serialization
|
||||
|
||||
BUGFIX: GroupNode resize instead of move on low zoom #87
|
||||
|
||||
BUGFIX: Make Canvas work with Viewports (#91, #90)
|
||||
|
||||
BUGFIX: Explicitly choose embedded GL3W as OpenGL extension loader (#96)
|
||||
|
||||
BUGFIX: Application: Don't apply HiDPI logic for (-FLT_MAX,-FLT_MAX) mouse position
|
||||
|
||||
BUGFIX: Editor: Clamp over-the-edge drag distance to prevent scrolling to infinity on focus lost
|
||||
|
||||
BUGFIX: Editor: Consume scroll event (#73) (require ImGui 17909 or later)
|
||||
|
||||
BUGFIX: Editor: Respect window focus while handling actions (#99)
|
||||
|
||||
BUGFIX: Examples: Correct case of `data` directory (#97)
|
||||
|
||||
BUGFIX: Canvas: Save/Restore CursorMaxPos only in Begin/End (#101)
|
||||
|
||||
BUGFIX: Editor: Don't implicitly capture keyboard (#83)
|
||||
|
||||
BUGFIX: Application: Reset key down state after loosing keyboard focus
|
||||
|
||||
BUGFIX: Editor: Make off-screen dragging work again
|
||||
|
||||
BUGFIX: ImGui: Disable obsolete functions (#103)
|
||||
|
||||
BUGFIX: Editor: Allow nodes with zero size (#134)
|
||||
|
||||
BUGFIX: Canvas: Update call ImGui::IsClippedEx() on ImGui > 18415 (#138)
|
||||
|
||||
BUGFIX: Canvas: Disable pink debug outline around widget (#150)
|
||||
|
||||
BUGFIX: Editor: Remove node settings when it is explicitly deleted (#153)
|
||||
|
||||
BUGFIX: Editor: Improve link dragging with fast movement (#156)
|
||||
|
||||
BUGFIX: Editor: Make selection rect start at click point
|
||||
|
||||
BUGFIX: Editor: Make selection rect sharp
|
||||
|
||||
BUGFIX: Editor: Don't populate unused channels with empty draw command, fixes memory leak (#168, #165)
|
||||
|
||||
BUGFIX: Application: Correctly set DX11 View for NULL textures (#162)
|
||||
|
||||
BUGFIX: Application: Recreate DX11 resources lazily (related to #162)
|
||||
|
||||
BUGFIX: Editor: Don't steal input from active user widget (#172)
|
||||
|
||||
BUGFIX: Editor: Delete item from internal list only when action accepts (#178)
|
||||
|
||||
BUGFIX: Editor: Cycle canvas to correctly restore view on first frame (#159)
|
||||
|
||||
BUGFIX: Editor: Don't relay on ImGui CursorMaxPos to apply padding (https://github.com/ocornut/imgui/issues/5548)
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
# Node Editor in ImGui
|
||||
|
||||
[](https://github.com/thedmd/imgui-node-editor/actions/workflows/build.yml)
|
||||
|
||||
## About
|
||||
|
||||
An implementation of node editor with ImGui-like API.
|
||||
|
||||
Project purpose is to serve as a basis for more complex solutions like blueprint editors.
|
||||
|
||||

|
||||
|
||||
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 queried 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 styled, default theme is modeled after UE4 blueprints
|
||||
- Flexible enough to produce such nodes:
|
||||
|
||||

|
||||

|
||||

|
||||
- Customizable links based on Bézier curves:
|
||||
|
||||

|
||||

|
||||

|
||||
* Automatic highlights for nodes, pins and links:
|
||||
|
||||

|
||||
* 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.
|
||||
|
||||
Note: Project recently was restructured to mimic ImGui layout.
|
||||
|
||||
Please report issues or questions if something isn't clear.
|
||||
|
||||
## Dependencies
|
||||
|
||||
* Vanilla ImGui 1.72+
|
||||
* C++14
|
||||
|
||||
### Dependencies for examples:
|
||||
* https://github.com/thedmd/imgui/tree/feature/layout (used in blueprints sample only)
|
||||
|
||||
### Optional extension you can pull into your local copy of ImGui node editor can take advantage of:
|
||||
* ~~https://github.com/thedmd/imgui/tree/feature/draw-list-fringe-scale (for sharp rendering, while zooming)~~ It is part of ImGui since 1.80 release
|
||||
* https://github.com/thedmd/imgui/tree/feature/extra-keys (for extra shortcuts)
|
||||
|
||||
## Building / Installing
|
||||
|
||||
Node Editor sources are located in root project directory. To use it, simply copy&paste sources into your project. Exactly like you can do with ImGui.
|
||||
|
||||
### Examples
|
||||
[Examples](../examples) can be build with CMake:
|
||||
```
|
||||
Windows:
|
||||
cmake -S examples -B build -G "Visual Studio 15 2017 Win64"
|
||||
or
|
||||
cmake -S examples -B build -G "Visual Studio 16 2019" -A x64
|
||||
|
||||
macOS:
|
||||
cmake -S examples -B build -G "Xcode"
|
||||
|
||||
Linux:
|
||||
cmake -S examples -B build -G "Unix Makefiles"
|
||||
|
||||
Build:
|
||||
cmake --build build --config Release
|
||||
```
|
||||
Executables will be located in `build\bin` directory.
|
||||
|
||||
### Quick Start
|
||||
|
||||
Main node editor header is located in [imgui_node_editor.h](../imgui_node_editor.h).
|
||||
|
||||
Minimal example of one node can be found in [simple-example.cpp](../examples/simple-example/simple-example.cpp).
|
||||
Press 'F' in editor to focus on editor content if you see only grid.
|
||||
```cpp
|
||||
# include <imgui.h>
|
||||
# include <imgui_node_editor.h>
|
||||
# include <application.h>
|
||||
|
||||
namespace ed = ax::NodeEditor;
|
||||
|
||||
struct Example:
|
||||
public Application
|
||||
{
|
||||
using Application::Application;
|
||||
|
||||
void OnStart() override
|
||||
{
|
||||
ed::Config config;
|
||||
config.SettingsFile = "Simple.json";
|
||||
m_Context = ed::CreateEditor(&config);
|
||||
}
|
||||
|
||||
void OnStop() override
|
||||
{
|
||||
ed::DestroyEditor(m_Context);
|
||||
}
|
||||
|
||||
void OnFrame(float deltaTime) override
|
||||
{
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
ImGui::Text("FPS: %.2f (%.2gms)", io.Framerate, io.Framerate ? 1000.0f / io.Framerate : 0.0f);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ed::SetCurrentEditor(m_Context);
|
||||
ed::Begin("My Editor", ImVec2(0.0, 0.0f));
|
||||
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();
|
||||
ed::SetCurrentEditor(nullptr);
|
||||
|
||||
//ImGui::ShowMetricsWindow();
|
||||
}
|
||||
|
||||
ed::EditorContext* m_Context = nullptr;
|
||||
};
|
||||
|
||||
int Main(int argc, char** argv)
|
||||
{
|
||||
Example exampe("Simple", argc, argv);
|
||||
|
||||
if (exampe.Create())
|
||||
return exampe.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||

|
||||
|
||||
For more details please visit [examples](../examples) folder.
|
||||
|
||||
### Blueprints Example
|
||||
|
||||

|
||||
|
||||
### Here is Node Editor at work in Spark CE
|
||||

|
||||

|
||||
+14
@@ -0,0 +1,14 @@
|
||||
In random order:
|
||||
* Documentation: Make one
|
||||
|
||||
Done:
|
||||
* ~~ImGui: Factor out changes to ImGui to use vanilla version.~~
|
||||
* ~~Editor: Fix variable naming (mainly add `m_` prefix)~~
|
||||
* ~~Editor: Split NodeEditorImpl.cpp to multiple files, file has grown too big.~~
|
||||
* ~~Editor: Factor out use of `picojson.h`~~
|
||||
* ~~Editor: Move use of `<optional>` to optional code extensions~~
|
||||
|
||||
|
||||
|
||||
|
||||
#57 - join `ax::NodeEditor::EditorContext` with `struct EditorContext` and remove `reinterpret_cast<>`
|
||||
Reference in New Issue
Block a user