Tables: Clarified that TableSetColumnEnabled() requires the table to use the ImGuiTableFlags_Hideable flag. (#3935)

This commit is contained in:
ocornut 2021-06-07 13:20:25 +02:00
parent 689e387180
commit b918751ff4
2 changed files with 8 additions and 4 deletions

View File

@ -37,6 +37,8 @@ HOW TO UPDATE?
Other Changes: Other Changes:
- TabBar: Fixed using more than 32 KB-worth of tab names. (#4176) - TabBar: Fixed using more than 32 KB-worth of tab names. (#4176)
- Tables: Clarified that TableSetColumnEnabled() requires the table to use the ImGuiTableFlags_Hideable flag,
because it manipulates the user-accessible show/hide state. (#3935)
- Tables: Added ImGuiTableColumnFlags_NoHeaderLabel to request TableHeadersRow() to not submit label for a column. - 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). Convenient for some small columns. Name will still appear in context menu. (#4206).
- Tables: Fix columns order on TableSetupScrollFreeze() if previous data got frozen columns out of their section. - Tables: Fix columns order on TableSetupScrollFreeze() if previous data got frozen columns out of their section.

View File

@ -1499,7 +1499,7 @@ void ImGui::TableSetupScrollFreeze(int columns, int rows)
// - TableGetColumnCount() // - TableGetColumnCount()
// - TableGetColumnName() // - TableGetColumnName()
// - TableGetColumnName() [Internal] // - TableGetColumnName() [Internal]
// - TableSetColumnEnabled() [Internal] // - TableSetColumnEnabled()
// - TableGetColumnFlags() // - TableGetColumnFlags()
// - TableGetCellBgRect() [Internal] // - TableGetCellBgRect() [Internal]
// - TableGetColumnResizeID() [Internal] // - TableGetColumnResizeID() [Internal]
@ -1535,10 +1535,11 @@ const char* ImGui::TableGetColumnName(const ImGuiTable* table, int column_n)
return &table->ColumnsNames.Buf[column->NameOffset]; return &table->ColumnsNames.Buf[column->NameOffset];
} }
// Request enabling/disabling a column (often perceived as "showing/hiding" from users point of view) // Change user accessible enabled/disabled state of a column (often perceived as "showing/hiding" from users point of view)
// Note that end-user can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody) // Note that end-user can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
// Request will be applied during next layout, which happens on the first call to TableNextRow() after BeginTable() // - Require table to have the ImGuiTableFlags_Hideable flag because we are manipulating user accessible state.
// For the getter you can use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsEnabled) // - Request will be applied during next layout, which happens on the first call to TableNextRow() after BeginTable().
// - For the getter you can test (TableGetColumnFlags() & ImGuiTableColumnFlags_IsEnabled) != 0.
void ImGui::TableSetColumnEnabled(int column_n, bool enabled) void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
@ -1546,6 +1547,7 @@ void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
IM_ASSERT(table != NULL); IM_ASSERT(table != NULL);
if (!table) if (!table)
return; return;
IM_ASSERT(table->Flags & ImGuiTableFlags_Hideable); // See comments above
if (column_n < 0) if (column_n < 0)
column_n = table->CurrentColumn; column_n = table->CurrentColumn;
IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount); IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount);