ocornut / imgui

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

Scrollbar increment values #7753

Open Antidote opened 1 week ago

Antidote commented 1 week ago

Version/Branch of Dear ImGui:

docking

Back-ends:

imgui_impl_sdlrenderer2.cpp + imgui_impl_sdl2.cpp

Compiler, OS:

Linux+GCC/Clang

Full config/build information:

No response

Details:

In some cases it's useful to have discrete scrollbar increments, such as for a tile map editor where you want to increment the scrollbars by either the tile size, or a region of tiles (i.e for a rectangle brush)

If there is an existing solution to this my google-fu has failed me, I currently snap the scrollbar values manually, but due to the nature in which they get updated there is a lot of rubber-banding.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

ocornut commented 1 week ago

Hello,

I don't have a great solution yet, however, you can use:

ImGui::GetActiveID() == ImGui::GetWindowScrollbarID(ImGui::GetCurrentWindow(), ImGuiAxis_Y);

from imgui_internal.h to tell that a scrollbar is activated, which may be useful to reduce glitches.

Note that keyboard navigation and other features may also lead to scroll.

Linking to #5628.