thedmd / imgui-node-editor

Node Editor built using Dear ImGui
MIT License
3.73k stars 551 forks source link

Support for smooth zoom with mouse wheel #266

Closed kmatzen closed 11 months ago

kmatzen commented 1 year ago

https://github.com/thedmd/imgui-node-editor/blob/master/imgui_node_editor.cpp#L3452

Seems like the mouse wheel gets quantized and then is used to look up into a discrete set of zoom levels. This design seems to leave a lot of room for scrolling deadzones where the user doesn't know if the scroll wheel is doing anything, especially on a MacBook trackpad where the mouse wheel values (from two finger scroll) are often pretty small. What's the recommended alternative? Define a large number of zoom levels and then scale the MouseWheel value in the code drawing the editor?

w0utert commented 1 year ago

It would indeed be nice to have a little more guidance on this, because right now like @kmatzen described, zooming using e.g. a MacBook touchpad doesn't really work. Small swipes are truncated/quantized so they will never change the zoom level, while large swipes will change the zoom level in very large increments.

I also tried to play with the CustomZoomLevels configuration setting, e.g. increasing the number of zoom levels to a very high number (as far as 10K) hoping this would fix the quantisation, and while it does seem to help a little bit the experience is still very bad. Using a regular mouse it works fine.

Maybe the zoom handling should accumulate scroll wheel values over multiple frames or something like that?

thedmd commented 11 months ago

@kmatzen @w0utert I pushed support for smooth zoom to develop and master. Please note that on master it is disabled by default.