-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
ImGuiListClipper doesn't obey scroll position in certain conditions, seemingly unrelated #3073
Comments
Wow yeah that's weird. I feel this may be an issue related to incorrect floating point rounding somewhere, will look at it ! (Not your bug but as for the clipper API: it's obviously lacking. We should rewrite it to at least 1) have a flag to disable clipping while preserving same looping API, 2) allow to manually insert items to not clip, both will allow you to avoid duplicating your code.) |
Hello, Fixed with 4986dba. Haven't merged in Docking yet but you may cherry-pick it without conflict. The issue that was Y position are meant to be aligned to integer, but that centering code would lead to misaligned scrolling leading to misaligned starting cursor position. This would generally be fixed after any item submission, but using the clipper right after Begin() the clipper would grab an unrounded position, then miscalculate item height (e.g. it would calculate line height as 13.5 instead of 13). Passing our tests. Thanks a lot! |
Thanks :) |
…ling values and initial cursor position. (ocornut#3073) This would often get fixed after the fix item submission, but using the ImGuiListClipper as the first thing after Begin() could largely break size calculations. (ocornut#3073)
@wolfpld I comes to the same issue and resolved it this way. Just put it as reference for anyone who comes to the same problem This solution can scroll to target row in one frame. with ImGui::SetScrollY().
|
Version/Branch of Dear ImGui:
Version: 1.75
Branch: master
Issue
Consider the following code:
This creates a list of 2000 items, which is clipped by ImGuiListClipper during normal usage, unless target position is selected using one of the buttons, in which case whole list is rendered for a single frame, so that
ImGui::SetScrollHereY()
can be called to center the view on the selected entry.What should happen
When the '1000' button is pressed, the list of items should be centered on the '1000' item.
What happens instead
When the aforementioned button is pressed, the list of items is centered on the '1000' item for a single frame, then, when the clipper is used to skip rendering of unseen elements, the '1000' item is placed outside the view. Notice that the same thing happens when the '100' button is pressed, but this time scroll mis-movement is smaller.
The WTF moment
Remove the
ImGui::TextUnformatted( "bleble" );
line to reduce number of printed lines in header to 1, or add another line (doesn't matter what's in it) to increase number of printed lines in header to 3. This will fix the issue. It appears that when number of header lines is even, this issue manifests itself, and when number of header lines is odd, everything works as intended.The text was updated successfully, but these errors were encountered: