rokups / ImNodes

Node graph implementation for Dear ImGui. Used in https://github.com/rokups/rbfx
MIT License
656 stars 57 forks source link

Nodes with only output slots? Assertion error #4

Closed sphaero closed 4 years ago

sphaero commented 5 years ago

Just comment a line which renders the input slots in sample.cpp:

ImNodes::Ez::InputSlots(node->input_slots.data(), node->input_slots.size());
ImNodes: /home/arnaud/src/build-ImNodes-Desktop-Default/imgui-1.70/imgui.cpp:6779: void ImGui::EndGroup(): Assertion `!window->DC.GroupStack.empty()' failed.
sphaero commented 5 years ago

It's because of this line I guess:

https://github.com/rokups/ImNodes/blob/e3431ce8bad2d68e52f728edd14aebaac7e8727b/ImNodesEz.cpp#L155

Which implies somewhere else a group has been started.

rokups commented 5 years ago

Right. You cant really skip this. Look: https://github.com/rokups/ImNodes/blob/e3431ce8bad2d68e52f728edd14aebaac7e8727b/ImNodesEz.cpp#L146-L155 They create a group for node content. So if you do not have any input nodes - call ImNodes::Ez::InputSlots(nullptr, 0);. Comments should probably clarify that.

sphaero commented 5 years ago

Indeed, or if you want an easy api just add a InputSlots() method with no arguments which does that. I'm not sure what is cleanest. You could also remove the BeginGroup in InputSlots and clarify in the docs that people are advised to group the node content.