Nelarius / imnodes

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

New hierarchical hover-detection code, hidden pins can no longer be hovered over #84

Closed Nelarius closed 3 years ago

Nelarius commented 3 years ago

There were some issues with the hover-detection code related to pins. These two issues reported that you could start a link at a pin hidden underneath a node: https://github.com/Nelarius/imnodes/issues/77, https://github.com/Nelarius/imnodes/issues/73.

I fixed the pin hovering detection, and it should no longer be possible to create links from hidden pins. The change is in this branch: https://github.com/Nelarius/imnodes/tree/hover-pass @francesco-cattoglio and @Moi78 since you reported the issues in the first place, I was wondering if you could try it on your end to make sure things work as expected πŸ™

What it does not fix

This does not change the fact that clicking and dragging a node will affect the ImGui widget of a node underneath. That's a more complicated issue πŸ˜…

Why was hover detection completely rewritten?

The way that UI elements are detected as near the mouse had to be changed. Before, hover detection was a local algorithm, and the hover detection was done at the same time as the UI element was rendered. It was possible for multiple pins and links to be graphically detected as hovered as a result.

Now, hover detection is done in a separate pass, and all pins, nodes, and links are inspected before making a decision on what is being hovered over:

Moi78 commented 3 years ago

Well, tested it (tortured it) and it works like a charm on my end πŸ‘Œ Thanks for the fix ^^

Nelarius commented 3 years ago

Merged in 50a696d1c8a22ad25e2a84d8a9fb1a181d5b60da