Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
2.01k stars 244 forks source link

Adds function to get node IDs from link ID #92

Closed briancairl closed 3 years ago

briancairl commented 3 years ago

In this PR, I've added a simple function that I used to gather a pair IDs associated with nodes connected by a link, given the link's ID.

I'm currently using the function in order to draw linkages in a navigation mini-map, which are then used to lookup the node positions with:

ImGui::GetNodeScreenSpacePos(...);

My aim was to do so without having to mirror the ID managing structures outside of imnodes::EditorContext

Do you think this type of structural introspection function has a place in this library? If not, is there an alternative I might be overlooking?

briancairl commented 3 years ago

@Nelarius First off, thanks for this great imgui add-on library.

To add some context to my pr: I'm currently working with your library in a small side project. One thing I thought would be useful is a way of quickly navigating to nodes in some sort of "zoomed out" context. I searched through some old repo issues to find that this has been brought up in the past, but isn't practically achievable with ImGui in its current state.

One alternative to zooming in the editor panel that I wanted to try was a navigable mini-map of the node editor context panel. To give more details, the mini-map:

I started to implement a janky prototype of this: image but in order to do so, I need some extra functionality (as far as I can currently see).

If cleaned up a good amount, is this something you think could be a useful feature to add to this library? Its probably not everyone's cup of tea because since it does take up additional screen real-estate and render time. However, its something that seems to be readily doable with ImGui in its current state.

Nelarius commented 3 years ago

Hi @briancairl !

First off, thanks for sharing the context, that minimap is a really cool idea actually. I haven't seen something quite like it, and it seems like it could help navigating large node graphs, especially if the concept of a viewport could be introduced.

I'm not convinced adding the helper function is the right move. If it does something which can be done outside the imnodes API, then it seems like that could be in the wrong place 🤔 One of my goals is to keep the API relatively simple.

The minimap, on the other hand, would be a substantial piece of functionality which could be integrated later on, especially if it looks like supporting zooming is not doable (experimenting with the fringe-scaling has been on my todo list for a long time, but I really would like to fix some of the internal complexities of the library before doing that 🙈 ) Maybe you could share your experiences with this prototype in an issue?

briancairl commented 3 years ago

@Nelarius https://github.com/Nelarius/imnodes/issues/94