Skip to content

Commit 3a2f0bf

Browse files
committed
Tables: demo inner_size + scrollx + stretch, added TableGetRowIndex(), renamed _WidthAlwaysAutoResize to _WidthAutoResize.
1 parent 3b3503e commit 3a2f0bf

File tree

3 files changed

+83
-43
lines changed

3 files changed

+83
-43
lines changed

imgui.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ namespace ImGui
685685
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return false when column is not visible.
686686
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return false when column is not visible.
687687
IMGUI_API int TableGetColumnIndex(); // return current column index.
688+
IMGUI_API int TableGetRowIndex(); // return current row index.
688689
// Tables: Headers & Columns declaration
689690
// - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc.
690691
// Important: this will not display anything! The name passed to TableSetupColumn() is used by TableHeadersRow() and context-menus.
@@ -1037,14 +1038,14 @@ enum ImGuiTabItemFlags_
10371038
// - The default sizing policy for columns depends on whether the ScrollX flag is set on the table:
10381039
// When ScrollX is off:
10391040
// - Table defaults to ImGuiTableFlags_SizingPolicyStretchX -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch.
1040-
// - Columns sizing policy allowed: Fixed/Auto or Stretch.
1041+
// - Columns sizing policy allowed: Stretch (default) or Fixed/Auto.
10411042
// - Stretch Columns will share the width available in table.
10421043
// - Fixed Columns will generally obtain their requested width unless the Table cannot fit them all.
10431044
// When ScrollX is on:
10441045
// - Table defaults to ImGuiTableFlags_SizingPolicyFixedX -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed.
1045-
// - Columns sizing policy allowed: Fixed/Auto mostly! Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
1046+
// - Columns sizing policy allowed: Fixed/Auto mostly!
10461047
// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed.
1047-
// - Stretch Columns, if any, will calculate their width using inner_width, assuming no scrolling (it really doesn't make sense to do otherwise).
1048+
// - Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
10481049
// - Mixing up columns with different sizing policy is possible BUT can be tricky and has some side-effects and restrictions.
10491050
// (their visible order and the scrolling state have subtle but necessary effects on how they can be manually resized).
10501051
// The typical use of mixing sizing policies is to have ScrollX disabled, one or two Stretch Column and many Fixed Columns.
@@ -1059,7 +1060,7 @@ enum ImGuiTableFlags_
10591060
ImGuiTableFlags_MultiSortable = 1 << 4, // Allow sorting on multiple columns by holding Shift (sort_specs_count may be > 1). Call TableGetSortSpecs() to obtain sort specs.
10601061
ImGuiTableFlags_NoSavedSettings = 1 << 5, // Disable persisting columns order, width and sort settings in the .ini file.
10611062
ImGuiTableFlags_ContextMenuInBody = 1 << 6, // Right-click on columns body/contents will display table context menu. By default it is available in TableHeadersRow().
1062-
// Decoration
1063+
// Decorations
10631064
ImGuiTableFlags_RowBg = 1 << 7, // Set each RowBg color with ImGuiCol_TableRowBg or ImGuiCol_TableRowBgAlt (equivalent to calling TableSetBgColor with ImGuiTableBgFlags_RowBg0 on each row manually)
10641065
ImGuiTableFlags_BordersInnerH = 1 << 8, // Draw horizontal borders between rows.
10651066
ImGuiTableFlags_BordersOuterH = 1 << 9, // Draw horizontal borders at the top and bottom.
@@ -1073,11 +1074,11 @@ enum ImGuiTableFlags_
10731074
ImGuiTableFlags_NoBordersInBody = 1 << 12, // Disable vertical borders in columns Body (borders will always appears in Headers).
10741075
ImGuiTableFlags_NoBordersInBodyUntilResize = 1 << 13, // Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers).
10751076
// Sizing
1076-
ImGuiTableFlags_SizingPolicyFixedX = 1 << 14, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAlwaysAutoResize policy. Read description above for more details.
1077+
ImGuiTableFlags_SizingPolicyFixedX = 1 << 14, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAutoResize policy. Read description above for more details.
10771078
ImGuiTableFlags_SizingPolicyStretchX = 1 << 15, // Default if ScrollX is off. Columns will default to use _WidthStretch policy. Read description above for more details.
10781079
ImGuiTableFlags_NoHeadersWidth = 1 << 16, // Disable header width contribution to automatic width calculation.
10791080
ImGuiTableFlags_NoHostExtendY = 1 << 17, // (FIXME-TABLE: Reword as SizingPolicy?) 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)
1080-
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 18, // Disable keeping column always minimally visible when table width gets too small and ScrllX is off.
1081+
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 18, // Disable keeping column always minimally visible when table width gets too small and ScrollX is off.
10811082
ImGuiTableFlags_PreciseStretchWidths = 1 << 19, // 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.
10821083
ImGuiTableFlags_NoClip = 1 << 20, // Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with TableSetupScrollFreeze().
10831084
// Padding
@@ -1099,9 +1100,9 @@ enum ImGuiTableColumnFlags_
10991100
ImGuiTableColumnFlags_None = 0,
11001101
ImGuiTableColumnFlags_DefaultHide = 1 << 0, // Default as a hidden column.
11011102
ImGuiTableColumnFlags_DefaultSort = 1 << 1, // Default as a sorting column.
1102-
ImGuiTableColumnFlags_WidthFixed = 1 << 2, // Column will keep a fixed size, preferable with horizontal scrolling enabled (default if table sizing policy is SizingPolicyFixedX and table is resizable).
1103-
ImGuiTableColumnFlags_WidthStretch = 1 << 3, // Column will stretch, preferable with horizontal scrolling disabled (default if table sizing policy is SizingPolicyStretchX).
1104-
ImGuiTableColumnFlags_WidthAlwaysAutoResize = 1 << 4, // Column will keep resizing based on submitted contents (with a one frame delay) == Fixed with auto resize (default if table sizing policy is SizingPolicyFixedX and table is not resizable).
1103+
ImGuiTableColumnFlags_WidthStretch = 1 << 2, // Column will stretch, preferable with horizontal scrolling disabled (default if table sizing policy is SizingPolicyStretchX).
1104+
ImGuiTableColumnFlags_WidthFixed = 1 << 3, // Column will not stretch, preferable with horizontal scrolling enabled (default if table sizing policy is SizingPolicyFixedX and table is resizable).
1105+
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).
11051106
ImGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing.
11061107
ImGuiTableColumnFlags_NoClipX = 1 << 6, // Disable clipping for this column (all NoClipX columns will render in a same draw command).
11071108
ImGuiTableColumnFlags_NoSort = 1 << 7, // Disable ability to sort on this field (even if ImGuiTableFlags_Sortable is set on the table).
@@ -1116,7 +1117,7 @@ enum ImGuiTableColumnFlags_
11161117
ImGuiTableColumnFlags_NoReorder = 1 << 16, // Disable reordering this column, this will also prevent other columns from crossing over this column.
11171118

11181119
// [Internal] Combinations and masks
1119-
ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthAlwaysAutoResize,
1120+
ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthAutoResize,
11201121
ImGuiTableColumnFlags_IndentMask_ = ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_IndentDisable,
11211122
ImGuiTableColumnFlags_NoDirectResize_ = 1 << 20 // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge)
11221123
};

0 commit comments

Comments
 (0)