mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
Tables: added ImGuiTableFlags_SameWidths, used in demo. Reordered columns flags and exposed them all in Columns Flags section.
This commit is contained in:
@ -467,16 +467,20 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
|
||||
if (ImGui::CollapsingHeader("Window options"))
|
||||
{
|
||||
ImGui::Checkbox("No titlebar", &no_titlebar); ImGui::SameLine(150);
|
||||
ImGui::Checkbox("No scrollbar", &no_scrollbar); ImGui::SameLine(300);
|
||||
ImGui::Checkbox("No menu", &no_menu);
|
||||
ImGui::Checkbox("No move", &no_move); ImGui::SameLine(150);
|
||||
ImGui::Checkbox("No resize", &no_resize); ImGui::SameLine(300);
|
||||
ImGui::Checkbox("No collapse", &no_collapse);
|
||||
ImGui::Checkbox("No close", &no_close); ImGui::SameLine(150);
|
||||
ImGui::Checkbox("No nav", &no_nav); ImGui::SameLine(300);
|
||||
ImGui::Checkbox("No background", &no_background);
|
||||
ImGui::Checkbox("No bring to front", &no_bring_to_front);
|
||||
if (ImGui::BeginTable("split", 3))
|
||||
{
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No titlebar", &no_titlebar);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No scrollbar", &no_scrollbar);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No menu", &no_menu);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No move", &no_move);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No resize", &no_resize);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No collapse", &no_collapse);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No close", &no_close);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background);
|
||||
ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
// All demo contents
|
||||
@ -3335,6 +3339,27 @@ static void PopStyleCompact()
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags)
|
||||
{
|
||||
ImGui::CheckboxFlags("_DefaultHide", p_flags, ImGuiTableColumnFlags_DefaultHide);
|
||||
ImGui::CheckboxFlags("_DefaultSort", p_flags, ImGuiTableColumnFlags_DefaultSort);
|
||||
ImGui::CheckboxFlags("_WidthStretch", p_flags, ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::CheckboxFlags("_WidthFixed", p_flags, ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::CheckboxFlags("_WidthAutoResize", p_flags, ImGuiTableColumnFlags_WidthAutoResize);
|
||||
ImGui::CheckboxFlags("_NoResize", p_flags, ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::CheckboxFlags("_NoReorder", p_flags, ImGuiTableColumnFlags_NoReorder);
|
||||
ImGui::CheckboxFlags("_NoHide", p_flags, ImGuiTableColumnFlags_NoHide);
|
||||
ImGui::CheckboxFlags("_NoClip", p_flags, ImGuiTableColumnFlags_NoClip);
|
||||
ImGui::CheckboxFlags("_NoSort", p_flags, ImGuiTableColumnFlags_NoSort);
|
||||
ImGui::CheckboxFlags("_NoSortAscending", p_flags, ImGuiTableColumnFlags_NoSortAscending);
|
||||
ImGui::CheckboxFlags("_NoSortDescending", p_flags, ImGuiTableColumnFlags_NoSortDescending);
|
||||
ImGui::CheckboxFlags("_NoSHeaderWidth", p_flags, ImGuiTableColumnFlags_NoHeaderWidth);
|
||||
ImGui::CheckboxFlags("_PreferSortAscending", p_flags, ImGuiTableColumnFlags_PreferSortAscending);
|
||||
ImGui::CheckboxFlags("_PreferSortDescending", p_flags, ImGuiTableColumnFlags_PreferSortDescending);
|
||||
ImGui::CheckboxFlags("_IndentEnable", p_flags, ImGuiTableColumnFlags_IndentEnable); ImGui::SameLine(); HelpMarker("Default for column 0");
|
||||
ImGui::CheckboxFlags("_IndentDisable", p_flags, ImGuiTableColumnFlags_IndentDisable); ImGui::SameLine(); HelpMarker("Default for column >0");
|
||||
}
|
||||
|
||||
static void ShowDemoWindowTables()
|
||||
{
|
||||
//ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||
@ -3576,7 +3601,7 @@ static void ShowDemoWindowTables()
|
||||
|
||||
if (ImGui::BeginTable("##table1", 3, flags))
|
||||
{
|
||||
ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed);// | ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("CCC", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableHeadersRow();
|
||||
@ -3875,19 +3900,7 @@ static void ShowDemoWindowTables()
|
||||
ImGui::PushID(column);
|
||||
ImGui::AlignTextToFramePadding(); // FIXME-TABLE: Workaround for wrong text baseline propagation
|
||||
ImGui::Text("Flags for '%s'", column_names[column]);
|
||||
ImGui::CheckboxFlags("_NoResize", &column_flags[column], ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::CheckboxFlags("_NoClipX", &column_flags[column], ImGuiTableColumnFlags_NoClipX);
|
||||
ImGui::CheckboxFlags("_NoHide", &column_flags[column], ImGuiTableColumnFlags_NoHide);
|
||||
ImGui::CheckboxFlags("_NoReorder", &column_flags[column], ImGuiTableColumnFlags_NoReorder);
|
||||
ImGui::CheckboxFlags("_DefaultSort", &column_flags[column], ImGuiTableColumnFlags_DefaultSort);
|
||||
ImGui::CheckboxFlags("_DefaultHide", &column_flags[column], ImGuiTableColumnFlags_DefaultHide);
|
||||
ImGui::CheckboxFlags("_NoSort", &column_flags[column], ImGuiTableColumnFlags_NoSort);
|
||||
ImGui::CheckboxFlags("_NoSortAscending", &column_flags[column], ImGuiTableColumnFlags_NoSortAscending);
|
||||
ImGui::CheckboxFlags("_NoSortDescending", &column_flags[column], ImGuiTableColumnFlags_NoSortDescending);
|
||||
ImGui::CheckboxFlags("_PreferSortAscending", &column_flags[column], ImGuiTableColumnFlags_PreferSortAscending);
|
||||
ImGui::CheckboxFlags("_PreferSortDescending", &column_flags[column], ImGuiTableColumnFlags_PreferSortDescending);
|
||||
ImGui::CheckboxFlags("_IndentEnable", &column_flags[column], ImGuiTableColumnFlags_IndentEnable); ImGui::SameLine(); HelpMarker("Default for column 0");
|
||||
ImGui::CheckboxFlags("_IndentDisable", &column_flags[column], ImGuiTableColumnFlags_IndentDisable); ImGui::SameLine(); HelpMarker("Default for column >0");
|
||||
EditTableColumnsFlags(&column_flags[column]);
|
||||
ImGui::PopID();
|
||||
}
|
||||
PopStyleCompact();
|
||||
@ -3990,12 +4003,12 @@ static void ShowDemoWindowTables()
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
|
||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", &flags, ImGuiTableFlags_SizingPolicyStretchX))
|
||||
flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyStretchX); // Can't specify both sizing polices so we clear the other
|
||||
flags &= ~ImGuiTableFlags_SizingPolicyFixedX; // Can't specify both sizing polices so we clear the other
|
||||
ImGui::SameLine(); HelpMarker("Default if _ScrollX if disabled. Makes columns use _WidthStretch policy by default.");
|
||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixedX", &flags, ImGuiTableFlags_SizingPolicyFixedX))
|
||||
flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyFixedX); // Can't specify both sizing polices so we clear the other
|
||||
flags &= ~ImGuiTableFlags_SizingPolicyStretchX; // Can't specify both sizing polices so we clear the other
|
||||
ImGui::SameLine(); HelpMarker("Default if _ScrollX if enabled. Makes columns use _WidthFixed by default, or _WidthFixedResize if _Resizable is not set.");
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseStretchWidths", &flags, ImGuiTableFlags_PreciseStretchWidths);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
|
||||
ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.");
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip);
|
||||
@ -4036,9 +4049,9 @@ static void ShowDemoWindowTables()
|
||||
ImGui::PushID("flags2");
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags2, ImGuiTableFlags_ScrollX);
|
||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", &flags2, ImGuiTableFlags_SizingPolicyStretchX))
|
||||
flags2 &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyStretchX);
|
||||
flags2 &= ~ImGuiTableFlags_SizingPolicyFixedX; // Can't specify both sizing polices so we clear the other
|
||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixedX", &flags2, ImGuiTableFlags_SizingPolicyFixedX))
|
||||
flags2 &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyFixedX);
|
||||
flags2 &= ~ImGuiTableFlags_SizingPolicyStretchX; // Can't specify both sizing polices so we clear the other
|
||||
ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 10.0f);
|
||||
ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f");
|
||||
ImGui::PopID();
|
||||
@ -4545,17 +4558,18 @@ static void ShowDemoWindowTables()
|
||||
if (ImGui::TreeNodeEx("Sizing:", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", &flags, ImGuiTableFlags_SizingPolicyStretchX))
|
||||
flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyStretchX); // Can't specify both sizing polices so we clear the other
|
||||
flags &= ~ImGuiTableFlags_SizingPolicyFixedX; // Can't specify both sizing polices so we clear the other
|
||||
ImGui::SameLine(); HelpMarker("[Default if ScrollX is off]\nFit all columns within available width (or specified inner_width). Fixed and Stretch columns allowed.");
|
||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixedX", &flags, ImGuiTableFlags_SizingPolicyFixedX))
|
||||
flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyFixedX); // Can't specify both sizing polices so we clear the other
|
||||
flags &= ~ImGuiTableFlags_SizingPolicyStretchX; // 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_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible);
|
||||
ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled.");
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseStretchWidths", &flags, ImGuiTableFlags_PreciseStretchWidths);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
|
||||
ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.");
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_SameWidths", &flags, ImGuiTableFlags_SameWidths);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip);
|
||||
ImGui::SameLine(); HelpMarker("Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options.");
|
||||
ImGui::TreePop();
|
||||
|
Reference in New Issue
Block a user