Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to render nodes over top of links. #56

Closed
jonathan2222 opened this issue Sep 24, 2020 · 3 comments
Closed

Option to render nodes over top of links. #56

jonathan2222 opened this issue Sep 24, 2020 · 3 comments

Comments

@jonathan2222
Copy link

When rendering a complex node graph, the links will often be in the way of editing the nodes. If there was an option to render the links under everything else it would fix many problems I am having when changing node attributes.

I know this might be too hard to implement because of the immediate nature of imgui.

@Nelarius
Copy link
Owner

Hi @jonathan2222 ! It should be doable, just requires some trickery with the draw channels. I'll see what I can do once I make some progress on one of the previous issues 👍

If you're itching to try it out, I think the following change inside the EndNodeEditor function should work:

diff --git a/imnodes.cpp b/imnodes.cpp
index 286abc6..6535738 100644
--- a/imnodes.cpp
+++ b/imnodes.cpp
@@ -2107,7 +2107,7 @@ void EndNodeEditor()
     object_pool_update(editor.pins);
 
     draw_list_sort_channels_by_depth(editor.node_depth_order);
-    draw_list_merge_channels();
+    g.canvas_draw_list->ChannelsSetCurrent(0);
 
     for (int link_idx = 0; link_idx < editor.links.pool.size(); ++link_idx)
     {
@@ -2117,6 +2117,8 @@ void EndNodeEditor()
         }
     }
 
+    g.canvas_draw_list->ChannelsMerge();
+
     // After the links have been rendered, the link pool can be updated as well.
     object_pool_update(editor.links);

I'm going to have to do some more testing on my end though and clean up the code a bit!

@jonathan2222
Copy link
Author

Hi @Nelarius! Thank you for the fast reply!

That change inside the EndNodeEditor function worked really nice, the only problem is that I can still interact with the links when hovering over the nodes. I will use this for the time being and wait for the update.
I really appreciate the work you have put into this, thank you! 👌

@Nelarius
Copy link
Owner

@jonathan2222 I pushed the change in 8ecdd39. Added some additional logic to inhibit link interaction when overlapped with a node. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants