Skip to content

Commit 5ef7b83

Browse files
committed
Tables: removed ImGuiTableSortSpecs::ColumnsMask because it needlessly exposes our 64-columns limitation which we'd eventually would like to lift
+ shuffle declarations in internals
1 parent e09454a commit 5ef7b83

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

imgui.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ enum ImGuiTableColumnFlags_
11151115
// [Internal] Combinations and masks
11161116
ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_WidthAutoResize,
11171117
ImGuiTableColumnFlags_IndentMask_ = ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_IndentDisable,
1118-
ImGuiTableColumnFlags_NoDirectResize_ = 1 << 20 // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge)
1118+
ImGuiTableColumnFlags_NoDirectResize_ = 1 << 30 // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge)
11191119
};
11201120

11211121
// Flags for ImGui::TableNextRow()
@@ -1912,9 +1912,8 @@ struct ImGuiTableSortSpecs
19121912
const ImGuiTableSortSpecsColumn* Specs; // Pointer to sort spec array.
19131913
int SpecsCount; // Sort spec count. Most often 1 unless e.g. ImGuiTableFlags_MultiSortable is enabled.
19141914
bool SpecsDirty; // Set to true when specs have changed since last time! Use this to sort again, then clear the flag.
1915-
ImU64 ColumnsMask; // Set to the mask of column indexes included in the Specs array. e.g. (1 << N) when column N is sorted.
19161915

1917-
ImGuiTableSortSpecs() { Specs = NULL; SpecsCount = 0; SpecsDirty = false; ColumnsMask = 0x00; }
1916+
ImGuiTableSortSpecs() { Specs = NULL; SpecsCount = 0; SpecsDirty = false; }
19181917
};
19191918

19201919
//-----------------------------------------------------------------------------

imgui_internal.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,21 +2270,25 @@ namespace ImGui
22702270
IMGUI_API float GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm);
22712271
IMGUI_API float GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset);
22722272

2273-
// Tables
2273+
// Tables: Candidates for public api
2274+
IMGUI_API void TableOpenContextMenu(int column_n = -1);
2275+
IMGUI_API void TableSetColumnWidth(int column_n, float width);
2276+
IMGUI_API bool TableGetColumnIsHidden(int column_n);
2277+
IMGUI_API void TableSetColumnIsHidden(int column_n, bool hidden);
2278+
IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs);
2279+
IMGUI_API void TablePushBackgroundChannel();
2280+
IMGUI_API void TablePopBackgroundChannel();
2281+
2282+
// Tables: Internals
22742283
IMGUI_API ImGuiTable* TableFindByID(ImGuiID id);
22752284
IMGUI_API bool BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
22762285
IMGUI_API void TableBeginUpdateColumns(ImGuiTable* table);
22772286
IMGUI_API void TableUpdateDrawChannels(ImGuiTable* table);
22782287
IMGUI_API void TableUpdateLayout(ImGuiTable* table);
22792288
IMGUI_API void TableUpdateBorders(ImGuiTable* table);
2280-
IMGUI_API void TableSetColumnWidth(int column_n, float width);
2281-
IMGUI_API bool TableGetColumnIsHidden(int column_n);
2282-
IMGUI_API void TableSetColumnIsHidden(int column_n, bool hidden);
22832289
IMGUI_API void TableDrawBorders(ImGuiTable* table);
22842290
IMGUI_API void TableDrawContextMenu(ImGuiTable* table);
2285-
IMGUI_API void TableOpenContextMenu(int column_n = -1);
22862291
IMGUI_API void TableReorderDrawChannelsForMerge(ImGuiTable* table);
2287-
IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs);
22882292
IMGUI_API void TableSortSpecsSanitize(ImGuiTable* table);
22892293
IMGUI_API void TableSortSpecsBuild(ImGuiTable* table);
22902294
IMGUI_API void TableBeginRow(ImGuiTable* table);
@@ -2296,8 +2300,6 @@ namespace ImGui
22962300
IMGUI_API ImGuiID TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no = 0);
22972301
IMGUI_API void TableSetColumnWidthAutoSingle(ImGuiTable* table, int column_n);
22982302
IMGUI_API void TableSetColumnWidthAutoAll(ImGuiTable* table);
2299-
IMGUI_API void PushTableBackground();
2300-
IMGUI_API void PopTableBackground();
23012303
IMGUI_API void TableRemove(ImGuiTable* table);
23022304
IMGUI_API void TableGcCompactTransientBuffers(ImGuiTable* table);
23032305
IMGUI_API void TableGcCompactSettings();

imgui_tables.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ void ImGui::TableSetColumnWidthAutoAll(ImGuiTable* table)
21292129
}
21302130
}
21312131

2132-
void ImGui::PushTableBackground()
2132+
void ImGui::TablePushBackgroundChannel()
21332133
{
21342134
ImGuiContext& g = *GImGui;
21352135
ImGuiWindow* window = g.CurrentWindow;
@@ -2141,7 +2141,7 @@ void ImGui::PushTableBackground()
21412141
table->DrawSplitter.SetCurrentChannel(window->DrawList, table->Bg1DrawChannelCurrent);
21422142
}
21432143

2144-
void ImGui::PopTableBackground()
2144+
void ImGui::TablePopBackgroundChannel()
21452145
{
21462146
ImGuiContext& g = *GImGui;
21472147
ImGuiWindow* window = g.CurrentWindow;
@@ -2653,7 +2653,6 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
26532653

26542654
// Write output
26552655
table->SortSpecsData.resize(table->SortSpecsCount);
2656-
table->SortSpecs.ColumnsMask = 0x00;
26572656
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
26582657
{
26592658
ImGuiTableColumn* column = &table->Columns[column_n];
@@ -2664,7 +2663,6 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
26642663
sort_spec->ColumnIndex = (ImU8)column_n;
26652664
sort_spec->SortOrder = (ImU8)column->SortOrder;
26662665
sort_spec->SortDirection = column->SortDirection;
2667-
table->SortSpecs.ColumnsMask |= (ImU64)1 << column_n;
26682666
}
26692667
table->SortSpecs.Specs = table->SortSpecsData.Data;
26702668
table->SortSpecs.SpecsCount = table->SortSpecsData.Size;

imgui_widgets.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6000,7 +6000,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
60006000
if (span_all_columns && window->DC.CurrentColumns)
60016001
PushColumnsBackground();
60026002
else if (span_all_columns && g.CurrentTable)
6003-
PushTableBackground();
6003+
TablePushBackgroundChannel();
60046004

60056005
// We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries
60066006
ImGuiButtonFlags button_flags = 0;
@@ -6050,7 +6050,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
60506050
if (span_all_columns && window->DC.CurrentColumns)
60516051
PopColumnsBackground();
60526052
else if (span_all_columns && g.CurrentTable)
6053-
PopTableBackground();
6053+
TablePopBackgroundChannel();
60546054

60556055
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
60566056
RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb);

0 commit comments

Comments
 (0)