Tables: Added ImGuiTableColumnFlags_NoHeaderLabel to request TableHeadersRow() to not submit label for a column. (#4206)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index cdead85..c2bdabc 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -37,6 +37,8 @@
Other Changes:
- TabBar: Fixed using more than 32 KB-worth of tab names. (#4176)
+- Tables: Added ImGuiTableColumnFlags_NoHeaderLabel to request TableHeadersRow() to not submit label for a column.
+ Convenient for some small columns. Name will still appear in context menu. (#4206).
- Fixed printf-style format checks on non-MinGW flavors. (#4183, #3592)
- Demo: Fixed requirement in 1.83 to link with imgui_demo.cpp if IMGUI_DISABLE_METRICS_WINDOW is not set. (#4171)
Normally the right way to disable compiling the demo is to set IMGUI_DISABLE_DEMO_WINDOWS, but we want to avoid
diff --git a/imgui.h b/imgui.h
index 275f6c8..2738757 100644
--- a/imgui.h
+++ b/imgui.h
@@ -1180,6 +1180,7 @@
ImGuiTableColumnFlags_PreferSortDescending = 1 << 13, // Make the initial sort direction Descending when first sorting on this column.
ImGuiTableColumnFlags_IndentEnable = 1 << 14, // Use current Indent value when entering cell (default for column 0).
ImGuiTableColumnFlags_IndentDisable = 1 << 15, // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes _within_ the cell will still be honored.
+ ImGuiTableColumnFlags_NoHeaderLabel = 1 << 16, // TableHeadersRow() will not submit label for this column. Convenient for some small columns. Name will still appear in context menu.
// Output status flags, read-only via TableGetColumnFlags()
ImGuiTableColumnFlags_IsEnabled = 1 << 20, // Status: is enabled == not hidden by user/api (referred to as "Hide" in _DefaultHide and _NoHide) flags.
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index b69bbed..a85cf04 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -3509,6 +3509,7 @@
ImGui::CheckboxFlags("_NoSort", p_flags, ImGuiTableColumnFlags_NoSort);
ImGui::CheckboxFlags("_NoSortAscending", p_flags, ImGuiTableColumnFlags_NoSortAscending);
ImGui::CheckboxFlags("_NoSortDescending", p_flags, ImGuiTableColumnFlags_NoSortDescending);
+ ImGui::CheckboxFlags("_NoHeaderLabel", p_flags, ImGuiTableColumnFlags_NoHeaderLabel);
ImGui::CheckboxFlags("_NoHeaderWidth", p_flags, ImGuiTableColumnFlags_NoHeaderWidth);
ImGui::CheckboxFlags("_PreferSortAscending", p_flags, ImGuiTableColumnFlags_PreferSortAscending);
ImGui::CheckboxFlags("_PreferSortDescending", p_flags, ImGuiTableColumnFlags_PreferSortDescending);
diff --git a/imgui_tables.cpp b/imgui_tables.cpp
index 971dce3..8c020b9 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -2780,8 +2780,11 @@
float row_height = GetTextLineHeight();
int columns_count = TableGetColumnCount();
for (int column_n = 0; column_n < columns_count; column_n++)
- if (TableGetColumnFlags(column_n) & ImGuiTableColumnFlags_IsEnabled)
+ {
+ ImGuiTableColumnFlags flags = TableGetColumnFlags(column_n);
+ if ((flags & ImGuiTableColumnFlags_IsEnabled) && !(flags & ImGuiTableColumnFlags_NoHeaderLabel))
row_height = ImMax(row_height, CalcTextSize(TableGetColumnName(column_n)).y);
+ }
row_height += GetStyle().CellPadding.y * 2.0f;
return row_height;
}
@@ -2818,7 +2821,7 @@
// Push an id to allow unnamed labels (generally accidental, but let's behave nicely with them)
// - in your own code you may omit the PushID/PopID all-together, provided you know they won't collide
// - table->InstanceCurrent is only >0 when we use multiple BeginTable/EndTable calls with same identifier.
- const char* name = TableGetColumnName(column_n);
+ const char* name = (TableGetColumnFlags(column_n) & ImGuiTableColumnFlags_NoHeaderLabel) ? "" : TableGetColumnName(column_n);
PushID(table->InstanceCurrent * table->ColumnsCount + column_n);
TableHeader(name);
PopID();