Nelarius / imnodes

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

Any chance to zoom in/zoom out node graph? #118

Open vtushevskiy opened 2 years ago

vtushevskiy commented 2 years ago

Would it be possible to implement zoom in/out for whole node graph in the editor?

smilediver commented 2 years ago

I have hacked up a quick proof of concept using a suggestion noted here: https://github.com/ocornut/imgui/issues/772#issuecomment-244628219 . It seems to work for both visual and input parts. I can work on it after I land mini-map changes.

Screenshot 2021-09-14 at 14 06 35
Nelarius commented 2 years ago

Very cool @smilediver !

I don't want to have ImNodes depend on a modified ImGui version. But if there is some community-supported way of doing this, then that would be great to have documented in the repository.

smilediver commented 2 years ago

It doesn't require modifications to ImGui. Basically it does two things: goes through ImNodes' draw lists and transforms the vertices; and modifies ImGui's mouse states (like ImGuiIO::MousePos) to be in the zoomed coordinate space. I just hope that ImGui doesn't have some hidden mouse states that we can't control.

jonnygarrett commented 2 years ago

hi @smilediver, is a (possibly beta) version of your change available anywhere ? - thanks

smilediver commented 2 years ago

I think it's mostly done. I'll try to find some free time to work on it on Friday to clean it up and review, and maybe will do a PR.

navyenzo commented 2 years ago

did this ever get implemented?

dyze commented 1 year ago

Hello, Is this zoom in/out implemented? If yes, how to use it? Thanks

navyenzo commented 1 year ago

Yes, any news on whether this was implemented?

the mini-map is ok, but wheel-zooming and mouse panning would be awesome

theVerySharpFlat commented 1 year ago

mouse panning would be awesome

Although this feature isn't implemented in the library, I was able to get this to work using EditorContextGetPanning and EditorContextResetPanning

championAI commented 9 months ago

Yes, any news on whether this was implemented?

the mini-map is ok, but wheel-zooming and mouse panning would be awesome