Tables: Added ImGuiTableFlags_NoHostExtendX (#3605) marked as WIP, will probably rename.

Moved some code from BeginTable() to TableUpdateLayout() to late latch some of the required data.
This commit is contained in:
ocornut
2020-12-17 22:29:11 +01:00
parent c4dbab8f5e
commit ad83976b35
4 changed files with 69 additions and 29 deletions

View File

@ -4221,6 +4221,7 @@ static void ShowDemoWindowTables()
ImGui::SetNextItemOpen(open_action != 0);
if (ImGui::TreeNode("Outer size"))
{
ImGui::Text("Using manual/explicit size:");
if (ImGui::BeginTable("##table1", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{
for (int row = 0; row < 5; row++)
@ -4248,6 +4249,30 @@ static void ShowDemoWindowTables()
}
ImGui::EndTable();
}
ImGui::Spacing();
// Showcasing use of ImGuiTableFlags_NoHostExtendX and ImGuiTableFlags_NoHostExtendY
// FIXME-TABLE: WIP API: Don't use yet, will probably rework/rename those flags.
ImGui::Text("Using NoHostExtend flags:");
static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_ColumnsWidthFixed;
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
if (ImGui::BeginTable("##table3", 3, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 5.5f)))
{
for (int row = 0; row < 10; row++)
{
ImGui::TableNextRow();
for (int column = 0; column < 3; column++)
{
ImGui::TableNextColumn();
ImGui::Text("Cell %d,%d", column, row);
}
}
ImGui::EndTable();
}
ImGui::SameLine();
ImGui::Text("Hello!");
ImGui::TreePop();
}
@ -4715,6 +4740,7 @@ static void ShowDemoWindowTables()
flags &= ~ImGuiTableFlags_ColumnsWidthStretch; // Can't specify both sizing polices so we clear the other
ImGui::SameLine(); HelpMarker("[Default if ScrollX is on]\nEnlarge as needed: enable scrollbar if ScrollX is enabled, otherwise extend parent window's contents rectangle. Only Fixed columns allowed. Stretched columns will calculate their width assuming no scrolling.");
ImGui::CheckboxFlags("ImGuiTableFlags_NoHeadersWidth", &flags, ImGuiTableFlags_NoHeadersWidth);
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible);
ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled.");