-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Last Table column cuts off a wide item in the first row when ScrollX, MultiSelect, and ImGuiListClipper are used together #8250
Comments
Thanks for your careful report. The first bug appears to be that ms->ScopeRectMin = window->DC.CursorMaxPos = window->DC.CursorPos; Which is used by TableEndRow()->TableEndCell() to measure the width of the last open cell, so that measurement is lost. Which is why this issue is fixed when you move the As for the second one, box-select is very sensitive to the fact that is uses a clipping rect and parent region and they must strictly match the one used by actual items. I'll investigate this as well. |
FYI The hacky workaround for the first bug is using the following: if (wide_items_instead_of_table_headers)
{
for (int i = 0; i < num_item_rows; ++i)
{
ImGui::TableNextRow();
if (ImGui::TableSetColumnIndex(0))
ImGui::TextUnformatted("A wide item in column 1");
if (ImGui::TableSetColumnIndex(1))
ImGui::TextUnformatted("A wide item in column 2");
ImGui::TableSetColumnIndex(0);
}
}
... Aka changing column after the last submission, in order for measurement to not be lost by the |
To clarify, ScrollX has no direct effect on those issues. But it looks different because without ScrollX the default Sizing Policy for columns is to Stretch Proportionally (ignoring measured contents width), and with ScrollX the default Sizing Policy is to Fit to Contents. Either way, the measured contents width for the last submitted column is overridden by |
…ured when calling BeginMultiSelect() while inside a table. (#8250)
I am still working on exploring this further and writing tests (with led me to yakshave on yet another tangent) but I think this pushed workaround fd93229 is actually reasonable for various reasons (I checked all other rewrite of CursorMaxPos and this was the only one which had a reasonable chance to overlap cells, and it mimick similar calls in e.g. clipper). |
Thanks for taking a look at this so quickly! I just cherry-picked fd93229 to the docking branch for testing and it fixed the problem for me. |
…ured when calling BeginMultiSelect() while inside a table. (ocornut#8250)
Version/Branch of Dear ImGui:
Version 1.91.7, Branch: master
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Linux + GCC 12.2.0
Full config/build information:
Details:
Hello again!
I found a corner case in the interaction of MultiSelect, Tables, and ImGuiListClipper.
When ScrollX is enabled in the Table and I do not call TableHeadersRow, then the last column will cut off a wide item in the first row early. Furthermore, the first row will have a few pixels of extra vertical spacing at the bottom. If there are multiple rows of wide items at the beginning of the Table, then the last column no longer cuts off early, but the last of these multiple rows still has the extra vertical spacing at the bottom.
If I comment out the usage of ImGuiListClipper, then the last column no longer cuts off early.
If I comment out the usage of MultiSelect, then the last column no longer cuts off early and the extra vertical spacing at the bottom disappears.
Commenting out the call to TableSetupScrollFreeze has no effect either way.
I've modified the "Multi-Select (in a table)" example from the demo to demonstrate (see code and video 1).
Another interesting thing I've noticed during troubleshooting is that the problems I've described here disappear if I move the call of BeginMultiSelect above the submission of the first row (either via TableHeadersRow or via submitting other items). But this then causes another issue when the first row is frozen, namely that items get skipped while scrolling back up the table via BoxSelect (see video 2).
Kind regards.
Screenshots/Video:
table-wide-item-multiselect.mp4
This is what happens after moving the call of BeginMultiSelect above the submission of the first (frozen) row:
table-wide-item-multiselect-2.mp4
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: