ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.56k stars 10.36k forks source link

Scroll parent window once child window is fully scrolled #8202

Open lawrence-laz opened 15 hours ago

lawrence-laz commented 15 hours ago

Version/Branch of Dear ImGui:

1.90.8

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_opengl.cpp

Compiler, OS:

Windows

Full config/build information:

ImGui.NET

Details:

Can I scroll a parent window while hovering the child window?

I have a vertically scrollable window with a child window, which is also vertically scrollable.

Currently imgui chooses which window to scroll with the mouse wheel/touchpad based on which window the pointer is hovering.

However, there's a situation where this behavior alone creates a bit of an uncomfortable experience. If the child window is not fully visible in the viewport and you are trying to scroll to the bottom of the child window the scrolling stops once the child window is at the bottom. The bottom items are still not visible though, because the parent needs to be scrolled down a bit too. But to get the parent to scroll you have to move the pointer away from the child window and then scroll again.

I would like to achieve a behavior, where hovering over a child window and moving mouse wheel/touchpad scrolls the child window, but once you are fully scrolled to that direction it would start scrolling the parent window. This would eliminate the need move the pointer mid-scrolling.

The same situation can be shown in the demo window (attached a gif).

Can this be achieved with the current public API?

Screenshots/Video:

image

ocornut commented 14 hours ago

I guess this was mentioned in passing while we worked on #3795 but never implemented. We can probably investigate it, and add ImGuiChildFlags values for request preventing the bubbling up to parent window if desired.