Skip to content

Commit f70bf69

Browse files
committed
Tables: comments and tweaks on TableUpdateLayout(). changed "apply final width" loop to use natural column order.
1 parent 155b8bb commit f70bf69

File tree

3 files changed

+75
-88
lines changed

3 files changed

+75
-88
lines changed

imgui.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -663,19 +663,20 @@ namespace ImGui
663663
// - 3. Optionally call TableSetupScrollFreeze() to request scroll freezing of columns/rows
664664
// - 4. Optionally call TableHeadersRow() to submit a header row (names will be pulled from data submitted to TableSetupColumns)
665665
// - 5. Populate contents
666-
// - In most situations you can use TableNextRow() + TableSetColumnIndex(xx) to start appending into a column.
666+
// - In most situations you can use TableNextRow() + TableSetColumnIndex(N) to start appending into a column.
667667
// - If you are using tables as a sort of grid, where every columns is holding the same type of contents,
668668
// you may prefer using TableNextColumn() instead of TableNextRow() + TableSetColumnIndex().
669669
// TableNextColumn() will automatically wrap-around into the next row if needed.
670670
// - IMPORTANT: Comparatively to the old Columns() API, we need to call TableNextColumn() for the first column!
671671
// - Both TableSetColumnIndex() and TableNextColumn() return false when the column is not visible, so you can
672-
// skip submitting the contents of a cell but only if you know the contents is not going to alter row height.
672+
// skip submitting the contents of a cell BUT ONLY if you know the contents is not going to alter row height.
673+
// In many situations, you may skip submitting contents for every columns but one (e.g. the first one).
673674
// - Summary of possible call flow:
674675
// ----------------------------------------------------------------------------------------------------------
675676
// TableNextRow() -> TableSetColumnIndex(0) -> Text("Hello 0") -> TableSetColumnIndex(1) -> Text("Hello 1") // OK
676-
// TableNextRow() -> TableNextColumn() Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK
677-
// TableNextColumn() Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK: TableNextColumn() automatically gets to next row!
678-
// TableNextRow() Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear!
677+
// TableNextRow() -> TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK
678+
// TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK: TableNextColumn() automatically gets to next row!
679+
// TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear!
679680
// ----------------------------------------------------------------------------------------------------------
680681
// - 5. Call EndTable()
681682
#define IMGUI_HAS_TABLE 1
@@ -1109,8 +1110,8 @@ enum ImGuiTableColumnFlags_
11091110
ImGuiTableColumnFlags_NoHeaderWidth = 1 << 12, // Header width don't contribute to automatic column width.
11101111
ImGuiTableColumnFlags_PreferSortAscending = 1 << 13, // Make the initial sort direction Ascending when first sorting on this column (default).
11111112
ImGuiTableColumnFlags_PreferSortDescending = 1 << 14, // Make the initial sort direction Descending when first sorting on this column.
1112-
ImGuiTableColumnFlags_IndentEnable = 1 << 15, // Use current Indent value when entering cell (default for 1st column).
1113-
ImGuiTableColumnFlags_IndentDisable = 1 << 16, // Ignore current Indent value when entering cell (default for columns after the 1st one). Indentation changes _within_ the cell will still be honored.
1113+
ImGuiTableColumnFlags_IndentEnable = 1 << 15, // Use current Indent value when entering cell (default for column 0).
1114+
ImGuiTableColumnFlags_IndentDisable = 1 << 16, // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes _within_ the cell will still be honored.
11141115

11151116
// [Internal] Combinations and masks
11161117
ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthAutoResize,

imgui_internal.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,8 @@ typedef ImS8 ImGuiTableColumnIdx;
18981898
typedef ImU8 ImGuiTableDrawChannelIdx;
18991899

19001900
// [Internal] sizeof() ~ 104
1901-
// We use the terminology "Visible" to refer to a columns that are not Hidden by user or settings. However it may still be out of view and clipped (and IsClipped would be set).
1901+
// We use the terminology "Enabled" to refer to a column that is not Hidden by user/api.
1902+
// We use the terminology "Clipped" to refer to a column that is out of sight because of scrolling/clipping.
19021903
// This is in contrast with some user-facing api such as IsItemVisible() / IsRectVisible() which use "Visible" to mean "not clipped".
19031904
struct ImGuiTableColumn
19041905
{
@@ -1932,7 +1933,7 @@ struct ImGuiTableColumn
19321933
bool IsEnabled; // Is the column not marked Hidden by the user? (even if off view, e.g. clipped by scrolling).
19331934
bool IsEnabledNextFrame;
19341935
bool IsClipped; // Is not actually in view (e.g. not overlapping the host window clipping rectangle).
1935-
bool IsSkipItems; // Do we want item submissions to this column to be ignored early on.
1936+
bool IsSkipItems; // Do we want item submissions to this column to be completely ignored (no layout will happen).
19361937
ImS8 NavLayerCurrent; // ImGuiNavLayer in 1 byte
19371938
ImS8 SortDirection; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending
19381939
ImU8 AutoFitQueue; // Queue of 8 values for the next 8 frames to request auto-fit
@@ -1969,9 +1970,9 @@ struct ImGuiTable
19691970
ImSpan<ImGuiTableColumn> Columns; // Point within RawData[]
19701971
ImSpan<ImGuiTableColumnIdx> DisplayOrderToIndex; // Point within RawData[]. Store display order of columns (when not reordered, the values are 0...Count-1)
19711972
ImSpan<ImGuiTableCellData> RowCellData; // Point within RawData[]. Store cells background requests for current row.
1972-
ImU64 EnabledMaskByIndex; // Column Index -> IsEnabled map (== not hidden by user/api) in a format adequate for iterating column without touching cold data
19731973
ImU64 EnabledMaskByDisplayOrder; // Column DisplayOrder -> IsEnabled map
19741974
ImU64 EnabledUnclippedMaskByIndex;// Enabled and not Clipped, aka "actually visible" "not hidden by some scrolling"
1975+
ImU64 EnabledMaskByIndex; // Column Index -> IsEnabled map (== not hidden by user/api) in a format adequate for iterating column without touching cold data
19751976
ImGuiTableFlags SettingsLoadedFlags; // Which data were loaded from the .ini file (e.g. when order is not altered we won't save order)
19761977
int SettingsOffset; // Offset in g.SettingsTables
19771978
int LastFrameActive;

0 commit comments

Comments
 (0)