Fattorino / ImNodeFlow

Node based editor/blueprints for ImGui
MIT License
145 stars 18 forks source link

Recursive Node Editors #33

Open avlec opened 1 month ago

avlec commented 1 month ago

I was pleasantly surprised that node editors within nodes worked pretty well.

There are a few quirks though listed below, and possibly others. I will refer to the node editor within a node as the "inner node editor" and the editor that contains that node the "outer node editor"

Fattorino commented 1 month ago

ok wow, this is uncharted territory, I'm surprised this works at all, to be honest. As per the nodes being rendered outside, this is because all the nodes always get drawn and then clipped by ImGui, I've tried in the past to determine the bounding box of the visible area but failed and then had no more time to dedicate to it. So that's the source of that problem. And for the highlighting, this is a fun bug, would have to look into it, but as I said in the other issue, I wont be able to for at least one month

avlec commented 1 month ago

Yes I had the crazy idea and great job for you on it working so well out of the box! Sounds good if I have some free time I might look into it a bit. I've got some interesting ideas and things I'll be playing around with.

avlec commented 1 month ago

Infinite recursion does as expected and crashes instantly. But limited recursion (32) does not so bad but it's kinda hard to see if part of the rendering here is breaking or if the zoom-level is not rendering the grids? Resizable nodes or unrestricted zoom would make viewing this easier but might not be useful for anything else. glhf Code for testing

struct NodeEditor : ImFlow::BaseNode
{
    ImFlow::ImNodeFlow mINF;
    NodeEditor(float d, std::size_t r) : BaseNode()
    {
        setTitle("glhf");
        mINF.setSize({d,d});
        if (r != 0)
        {
          mINF.addNode<NodeEditor>({0,0}, d, r - 1);
        }
    }
    void draw()
    {
        mINF.update();
    }
};

An interesting quirk of the zoom limitations is that you can actually make the nodes inside bigger than the outer-most node.

elbadcode commented 5 days ago

this is incredible lol

It may actually fit my use case which involves namespaced objects representing d3d command queues and resource views. Most of the time you'd only open one object window at a time but occasionally they'd reference a variable from another object. Now I never have to write logic to spawn a property from another object inside each window, it seems like it will just work. Not having a shared canvas is also nice for a game overlay. Would be crazy if I could get multiviewport working and have node windows on my other monitor connecting to the game overlay

What would be the criteria for the bounding box fix to be doable? I'm fairly new to imgui, but using it with reshade I think I could try to handle it in a compute shader which have mem pooling capabilities. Not entirely sure I view this quirk as a bug yet

Already have a limit of 64 recursion. I had raised it to 96 but I'm backing off again if I try this

Fattorino commented 3 days ago

honestly, I don't even know where to start to make all of this into an actual polished feature

elbadcode commented 3 days ago

All good lol if it goes anywhere maybe I'll come back with a couple changes but don't sweat it