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

Adds node editor MiniMap feature #99

Merged
merged 4 commits into from
May 12, 2021
Merged

Conversation

briancairl
Copy link
Contributor

@briancairl briancairl commented Apr 12, 2021

Adds mini map feature to be used between BeginNodeEditor and EndNodeEditor with following features:

  • provides "low detail" view of nodes/links in the graph as an overlay in the editor canvas
  • provides the ability to zoom in and out of this context to view more of the graph than is visible in the normal editor canvas viewport
  • scrolling, which scales with zoom (when zoomed out, scrolls the editor context at a faster rate)
  • node snapping when clicked: pans clicked node to center of canvas when mini-map node is clicked
  • node hovering callback, which can be used to set custom tooltips when hovering the mini map
  • separate color variables for the mini map bg/outline and nodes/links
  • four positioning options within the editor canvas
imnodes_minimap_wip2.mp4

Adds mini map feature to be used between `BeginNodeEditor` and `EndNodeEditor` with following features:
- provides "low detail" view of nodes/links in the graph as an overlay in the editor canvas
- provides the ability to zoom in and out of this context to view more of the graph than is visible in the normal editor canvas viewport
- scrolling, which scales with zoom (when zoomed out, scrolls the editor context at a faster rate)
- node snapping when clicked: pans clicked node to center of canvas when mini-map node is clicked
- node hovering callback, which can be used to set custom tooltips when hovering the minimap
- separate color variables for the minimap bg/outline and nodes/links
- four positioning options withing the editor canvas
Copy link
Owner

@Nelarius Nelarius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @briancairl ! Two small things I think could be addressed, but beyond that I think getting this merged is definitely the next step! Some things, such as further viewport customizability, and a viewport in the minimap I think would be better informed by getting this merged and having others use the feature 👍

imnodes.cpp Outdated
@@ -631,14 +631,35 @@ void BeginCanvasInteraction(ImNodesEditorContext& editor)

const bool started_panning = GImNodes->AltMouseClicked;

if (started_panning)
// Handle mini-map interactions
if (ImGui::IsWindowFocused() and
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the window is out of focus, it is possible to start a box selection inside the minimap, due to the start of the box selection interaction not being behind a window focus-check. So I think we either need to remove the ImGui::IsWindowFocused() check here, or early-out of the function if the window is not being hovered.

ImGui doesn't prevent UI element interaction when the window is out of focus, so I think for interaction consistency it might make sense to just not have the focus check here, letting the window come in to focus when starting the interaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me. Will remove.

Comment on lines +1022 to +1025
editor.Panning += GImNodes->MiniMapRectSnappingOffset;
GImNodes->MiniMapRectSnappingOffset = ImVec2(0.f, 0.f);

editor.ClickInteraction.Type = ImNodesClickInteractionType_None;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might feel a bit more consistent if the actual snap-to-node happens when the mouse button is released. In other click-based interactions, such as clicking checkboxes, buttons, and nodes, the action only happens on mouse release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change to snap on mouse release.

@briancairl
Copy link
Contributor Author

briancairl commented May 11, 2021

@Nelarius I've made the changes as per your suggestions, along with one additional major change f2ddfa9 to fix poor interact behavior when both the mini-map and a node/link/pin were under the mouse cursor.

@briancairl briancairl requested a review from Nelarius May 11, 2021 02:52
Mini-map interaction and node/link/pin hovering interaction would clobber state related to one another.
Since minimap is drawn on top, disable hovering behavior when the mouse is over the minimap AND an node/link/pin.
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

Successfully merging this pull request may close these issues.

2 participants