Skip to content

Commit 8f126d5

Browse files
committed
Tables: rename ImGuiTableFlags_SizingPolicyStretchX to ImGuiTableFlags_ColumnsWidthStretch, ImGuiTableFlags_SizingPolicyFixedX to ImGuiTableFlags_ColumnsWidthFixed.
1 parent 41f89e0 commit 8f126d5

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
lines changed

imgui.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,12 +1037,12 @@ enum ImGuiTabItemFlags_
10371037
// Read comments/demos carefully + experiment with live demos to get acquainted with them.
10381038
// - The default sizing policy for columns depends on whether the ScrollX flag is set on the table:
10391039
// When ScrollX is off:
1040-
// - Table defaults to ImGuiTableFlags_SizingPolicyStretchX -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch.
1040+
// - Table defaults to ImGuiTableFlags_ColumnsWidthStretch -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch.
10411041
// - Columns sizing policy allowed: Stretch (default) or Fixed/Auto.
10421042
// - Stretch Columns will share the width available in table.
10431043
// - Fixed Columns will generally obtain their requested width unless the Table cannot fit them all.
10441044
// When ScrollX is on:
1045-
// - Table defaults to ImGuiTableFlags_SizingPolicyFixedX -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed.
1045+
// - Table defaults to ImGuiTableFlags_ColumnsWidthFixed -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed.
10461046
// - Columns sizing policy allowed: Fixed/Auto mostly!
10471047
// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed.
10481048
// - Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
@@ -1074,8 +1074,8 @@ enum ImGuiTableFlags_
10741074
ImGuiTableFlags_NoBordersInBody = 1 << 12, // Disable vertical borders in columns Body (borders will always appears in Headers).
10751075
ImGuiTableFlags_NoBordersInBodyUntilResize = 1 << 13, // Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers).
10761076
// Sizing
1077-
ImGuiTableFlags_SizingPolicyStretchX = 1 << 14, // Default if ScrollX is off. Columns will default to use _WidthStretch policy. Read description above for more details.
1078-
ImGuiTableFlags_SizingPolicyFixedX = 1 << 15, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAutoResize policy (if Resizable is off). Read description above for more details.
1077+
ImGuiTableFlags_ColumnsWidthStretch = 1 << 14, // Default if ScrollX is off. Columns will default to use _WidthStretch. Read description above for more details.
1078+
ImGuiTableFlags_ColumnsWidthFixed = 1 << 15, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAutoResize policy (if Resizable is off). Read description above for more details.
10791079
ImGuiTableFlags_SameWidths = 1 << 16, // Make all columns the same widths which is useful with Fixed columns policy (but granted by default with Stretch policy + no resize). Implicitly enable ImGuiTableFlags_NoKeepColumnsVisible and disable ImGuiTableFlags_Resizable.
10801080
ImGuiTableFlags_NoHeadersWidth = 1 << 17, // Disable headers' contribution to automatic width calculation.
10811081
ImGuiTableFlags_NoHostExtendY = 1 << 18, // Disable extending past the limit set by outer_size.y, only meaningful when neither of ScrollX|ScrollY are set (data below the limit will be clipped and not visible)
@@ -1098,9 +1098,9 @@ enum ImGuiTableColumnFlags_
10981098
ImGuiTableColumnFlags_None = 0,
10991099
ImGuiTableColumnFlags_DefaultHide = 1 << 0, // Default as a hidden column.
11001100
ImGuiTableColumnFlags_DefaultSort = 1 << 1, // Default as a sorting column.
1101-
ImGuiTableColumnFlags_WidthStretch = 1 << 2, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is SizingPolicyStretchX).
1102-
ImGuiTableColumnFlags_WidthFixed = 1 << 3, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is SizingPolicyFixedX and table is resizable).
1103-
ImGuiTableColumnFlags_WidthAutoResize = 1 << 4, // Column will not stretch and keep resizing based on submitted contents (default if table sizing policy is SizingPolicyFixedX and table is not resizable).
1101+
ImGuiTableColumnFlags_WidthStretch = 1 << 2, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _ColumnsWidthStretch).
1102+
ImGuiTableColumnFlags_WidthFixed = 1 << 3, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _ColumnsWidthFixed and table is resizable).
1103+
ImGuiTableColumnFlags_WidthAutoResize = 1 << 4, // Column will not stretch and keep resizing based on submitted contents (default if table sizing policy is _ColumnsWidthFixed and table is not resizable).
11041104
ImGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing.
11051105
ImGuiTableColumnFlags_NoReorder = 1 << 6, // Disable manual reordering this column, this will also prevent other columns from crossing over this column.
11061106
ImGuiTableColumnFlags_NoHide = 1 << 7, // Disable ability to hide this column.

imgui_demo.cpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,15 +3566,15 @@ static void ShowDemoWindowTables()
35663566
ImGui::SetNextItemOpen(open_action != 0);
35673567
if (ImGui::TreeNode("Resizable, fixed"))
35683568
{
3569-
// Here we use ImGuiTableFlags_SizingPolicyFixedX (even though _ScrollX is not set)
3569+
// Here we use ImGuiTableFlags_ColumnsWidthFixed (even though _ScrollX is not set)
35703570
// So columns will adopt the "Fixed" policy and will maintain a fixed width regardless of the whole available width (unless table is small)
35713571
// If there is not enough available width to fit all columns, they will however be resized down.
35723572
// FIXME-TABLE: Providing a stretch-on-init would make sense especially for tables which don't have saved settings
35733573
HelpMarker(
3574-
"Using _Resizable + _SizingPolicyFixedX flags.\n"
3574+
"Using _Resizable + _ColumnsWidthFixedX flags.\n"
35753575
"Fixed-width columns generally makes more sense if you want to use horizontal scrolling.\n\n"
35763576
"Double-click a column border to auto-fit the column to its contents.");
3577-
static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingPolicyFixedX | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody;
3577+
static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody;
35783578
//ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX); // FIXME-TABLE: Explain or fix the effect of enable Scroll on outer_size
35793579
if (ImGui::BeginTable("##table1", 3, flags))
35803580
{
@@ -3597,7 +3597,7 @@ static void ShowDemoWindowTables()
35973597
if (ImGui::TreeNode("Resizable, mixed"))
35983598
{
35993599
HelpMarker("Using columns flag to alter resizing policy on a per-column basis.");
3600-
static ImGuiTableFlags flags = ImGuiTableFlags_SizingPolicyFixedX | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
3600+
static ImGuiTableFlags flags = ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
36013601

36023602
if (ImGui::BeginTable("##table1", 3, flags))
36033603
{
@@ -3673,7 +3673,7 @@ static void ShowDemoWindowTables()
36733673
ImGui::EndTable();
36743674
}
36753675

3676-
if (ImGui::BeginTable("##table2", 3, flags | ImGuiTableFlags_SizingPolicyFixedX))
3676+
if (ImGui::BeginTable("##table2", 3, flags | ImGuiTableFlags_ColumnsWidthFixed))
36773677
{
36783678
ImGui::TableSetupColumn("One");
36793679
ImGui::TableSetupColumn("Two");
@@ -3768,7 +3768,7 @@ static void ShowDemoWindowTables()
37683768

37693769
if (ImGui::BeginTable("##table1", 4, flags))
37703770
{
3771-
// We could also set ImGuiTableFlags_SizingPolicyFixedX on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
3771+
// We could also set ImGuiTableFlags_ColumnsWidthFixed on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
37723772
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
37733773
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f);
37743774
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f);
@@ -3835,7 +3835,11 @@ static void ShowDemoWindowTables()
38353835
ImGui::SetNextItemOpen(open_action != 0);
38363836
if (ImGui::TreeNode("Horizontal scrolling"))
38373837
{
3838-
HelpMarker("When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_SizingPolicyFixedX, as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\nAlso note that as of the current version, you will almost always want to enable ScrollY along with ScrollX, because the container window won't automatically extend vertically to fix contents (this may be improved in future versions).");
3838+
HelpMarker(
3839+
"When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_ColumnsWidthFixed,"
3840+
"as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n"
3841+
"Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX,"
3842+
"because the container window won't automatically extend vertically to fix contents (this may be improved in future versions).");
38393843
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
38403844
static int freeze_cols = 1;
38413845
static int freeze_rows = 1;
@@ -3908,7 +3912,7 @@ static void ShowDemoWindowTables()
39083912
}
39093913

39103914
// Create the real table we care about for the example!
3911-
const ImGuiTableFlags flags = ImGuiTableFlags_SizingPolicyFixedX | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable;
3915+
const ImGuiTableFlags flags = ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable;
39123916
if (ImGui::BeginTable("##table", column_count, flags))
39133917
{
39143918
for (int column = 0; column < column_count; column++)
@@ -4002,11 +4006,11 @@ static void ShowDemoWindowTables()
40024006
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV);
40034007
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX);
40044008
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
4005-
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", &flags, ImGuiTableFlags_SizingPolicyStretchX))
4006-
flags &= ~ImGuiTableFlags_SizingPolicyFixedX; // Can't specify both sizing polices so we clear the other
4009+
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthStretch", &flags, ImGuiTableFlags_ColumnsWidthStretch))
4010+
flags &= ~ImGuiTableFlags_ColumnsWidthFixed; // Can't specify both sizing polices so we clear the other
40074011
ImGui::SameLine(); HelpMarker("Default if _ScrollX if disabled. Makes columns use _WidthStretch policy by default.");
4008-
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixedX", &flags, ImGuiTableFlags_SizingPolicyFixedX))
4009-
flags &= ~ImGuiTableFlags_SizingPolicyStretchX; // Can't specify both sizing polices so we clear the other
4012+
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthFixed", &flags, ImGuiTableFlags_ColumnsWidthFixed))
4013+
flags &= ~ImGuiTableFlags_ColumnsWidthStretch; // Can't specify both sizing polices so we clear the other
40104014
ImGui::SameLine(); HelpMarker("Default if _ScrollX if enabled. Makes columns use _WidthFixed by default, or _WidthFixedResize if _Resizable is not set.");
40114015
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
40124016
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.");
@@ -4043,21 +4047,21 @@ static void ShowDemoWindowTables()
40434047
"Showcase using Stretch columns + ScrollX together: "
40444048
"this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n"
40454049
"Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense.");
4046-
static ImGuiTableFlags flags2 = ImGuiTableFlags_SizingPolicyStretchX | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg;
4050+
static ImGuiTableFlags flags2 = ImGuiTableFlags_ColumnsWidthStretch | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg;
40474051
static float inner_width = 1000.0f;
40484052
PushStyleCompact();
40494053
ImGui::PushID("flags2");
40504054
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags2, ImGuiTableFlags_ScrollX);
4051-
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", &flags2, ImGuiTableFlags_SizingPolicyStretchX))
4052-
flags2 &= ~ImGuiTableFlags_SizingPolicyFixedX; // Can't specify both sizing polices so we clear the other
4053-
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixedX", &flags2, ImGuiTableFlags_SizingPolicyFixedX))
4054-
flags2 &= ~ImGuiTableFlags_SizingPolicyStretchX; // Can't specify both sizing polices so we clear the other
4055+
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthStretch", &flags2, ImGuiTableFlags_ColumnsWidthStretch))
4056+
flags2 &= ~ImGuiTableFlags_ColumnsWidthFixed; // Can't specify both sizing polices so we clear the other
4057+
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthFixed", &flags2, ImGuiTableFlags_ColumnsWidthFixed))
4058+
flags2 &= ~ImGuiTableFlags_ColumnsWidthStretch; // Can't specify both sizing polices so we clear the other
40554059
ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 10.0f);
40564060
ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f");
40574061
ImGui::PopID();
40584062
PopStyleCompact();
40594063

4060-
if (ImGui::BeginTable("##table2", 7, flags2 | ImGuiTableFlags_SizingPolicyStretchX | ImGuiTableFlags_ContextMenuInBody, outer_size, inner_width))
4064+
if (ImGui::BeginTable("##table2", 7, flags2 | ImGuiTableFlags_ColumnsWidthStretch | ImGuiTableFlags_ContextMenuInBody, outer_size, inner_width))
40614065
{
40624066
for (int cell = 0; cell < 20 * 7; cell++)
40634067
{
@@ -4351,7 +4355,7 @@ static void ShowDemoWindowTables()
43514355
// [2.2] Right-click on the ".." to open a custom popup
43524356
// [2.3] Right-click in columns to open another custom popup
43534357
HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body).");
4354-
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingPolicyFixedX | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
4358+
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
43554359
if (ImGui::BeginTable("##table2", COLUMNS_COUNT, flags2))
43564360
{
43574361
ImGui::TableSetupColumn("One");
@@ -4506,7 +4510,7 @@ static void ShowDemoWindowTables()
45064510
ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_MultiSortable
45074511
| ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBody
45084512
| ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
4509-
| ImGuiTableFlags_SizingPolicyFixedX
4513+
| ImGuiTableFlags_ColumnsWidthFixed
45104514
;
45114515

45124516
enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow };
@@ -4557,11 +4561,11 @@ static void ShowDemoWindowTables()
45574561

45584562
if (ImGui::TreeNodeEx("Sizing:", ImGuiTreeNodeFlags_DefaultOpen))
45594563
{
4560-
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", &flags, ImGuiTableFlags_SizingPolicyStretchX))
4561-
flags &= ~ImGuiTableFlags_SizingPolicyFixedX; // Can't specify both sizing polices so we clear the other
4564+
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthStretch", &flags, ImGuiTableFlags_ColumnsWidthStretch))
4565+
flags &= ~ImGuiTableFlags_ColumnsWidthFixed; // Can't specify both sizing polices so we clear the other
45624566
ImGui::SameLine(); HelpMarker("[Default if ScrollX is off]\nFit all columns within available width (or specified inner_width). Fixed and Stretch columns allowed.");
4563-
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixedX", &flags, ImGuiTableFlags_SizingPolicyFixedX))
4564-
flags &= ~ImGuiTableFlags_SizingPolicyStretchX; // Can't specify both sizing polices so we clear the other
4567+
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthFixed", &flags, ImGuiTableFlags_ColumnsWidthFixed))
4568+
flags &= ~ImGuiTableFlags_ColumnsWidthStretch; // Can't specify both sizing polices so we clear the other
45654569
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.");
45664570
ImGui::CheckboxFlags("ImGuiTableFlags_NoHeadersWidth", &flags, ImGuiTableFlags_NoHeadersWidth);
45674571
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);

0 commit comments

Comments
 (0)