-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Tables output borders and background beyond right-most column #3605
Comments
I personally would not expect space beyond last one to be same as the background, because conceptually that space is part of the table. It would be confusing to have two sets of backgrounds in a single table i would think. However, a quick search shows that UI toolkits do both variants. In that case, i suppose both are valid styles to have. |
But BeginGroup/EndGroup (surrounded by white border rectangle) is telling that this space is not part of the table. It is just surrounding the three rows and four columns of the table. |
It's an artifact of the fact that tables declare a certain contents size for windows auto-resize to function, and that's the size visible in EndGroup(). Same thing if you were to enclose a simple TreeNode or Selectable in a group (the visible highlight is larger than the minimum size which is the one declared for layout purpose). As per your question, it's a valid concern but presently tables weren't designed for that. (1) You can set a specific outer-width for the Table: if (ImGui::BeginTable("##table1", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{
for (int row = 0; row < 5; row++)
{
ImGui::TableNextRow();
for (int column = 0; column < 3; column++)
{
ImGui::TableNextColumn();
ImGui::Text("Cell %d,%d", column, row);
}
}
ImGui::EndTable();
}
ImGui::SameLine();
if (ImGui::BeginTable("##table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{
for (int row = 0; row < 3; row++)
{
ImGui::TableNextRow(0, TEXT_BASE_HEIGHT * 1.5f);
for (int column = 0; column < 3; column++)
{
ImGui::TableNextColumn();
ImGui::Text("Cell %d,%d", column, row);
}
}
ImGui::EndTable();
} I just fixed a bug to make this work btw, so you'll need to update to latest. (2) To do exactly what you suggest we'd need to add an additional feature. |
FYI I have a working version of this: It's not committed yet as
PS: The "hello" string visible on the right is a |
…ll probably rename. Moved some code from BeginTable() to TableUpdateLayout() to late latch some of the required data.
This is now supported but not via the flag suggested in the previous post. " BREAKING CHANGES (DEC 2020)To support #3605 I made a little change to the default value and handling of the ImVec2 outer_size parameter.
The new meaning of Effectively this is unlikely to break much code as outer_size is only required for scrolling tables. |
…ze.x == 0.0f. Changed default outer_size to (0.0f, 0.0f). (#3605)
I made a change to the feature discussed here. I disliked the -FLT_MIN/0.0f distinction because it made the required default value for outer_size = Instead I have made it a flag Will release 1.80 shortly. |
I would like to know why tables with fixed sizing policy are printing background and borders outside of item rect size
I would expect the area contained inside red rectangle to be as the background.
The text was updated successfully, but these errors were encountered: