|
@@ -522,7 +522,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|
*column = ImGuiTableColumn();
|
|
*column = ImGuiTableColumn();
|
|
column->WidthAuto = width_auto;
|
|
column->WidthAuto = width_auto;
|
|
column->IsPreserveWidthAuto = true; // Preserve WidthAuto when reinitializing a live table: not technically necessary but remove a visible flicker
|
|
column->IsPreserveWidthAuto = true; // Preserve WidthAuto when reinitializing a live table: not technically necessary but remove a visible flicker
|
|
- column->IsEnabled = column->IsEnabledNextFrame = true;
|
|
|
|
|
|
+ column->IsEnabled = column->IsUserEnabled = column->IsUserEnabledNextFrame = true;
|
|
}
|
|
}
|
|
column->DisplayOrder = table->DisplayOrderToIndex[n] = (ImGuiTableColumnIdx)n;
|
|
column->DisplayOrder = table->DisplayOrderToIndex[n] = (ImGuiTableColumnIdx)n;
|
|
}
|
|
}
|
|
@@ -756,16 +756,18 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|
column->InitStretchWeightOrWidth = -1.0f;
|
|
column->InitStretchWeightOrWidth = -1.0f;
|
|
}
|
|
}
|
|
|
|
|
|
- // Update Enabled state, mark settings/sortspecs dirty
|
|
|
|
|
|
+ // Update Enabled state, mark settings and sort specs dirty
|
|
if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide))
|
|
if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide))
|
|
- column->IsEnabledNextFrame = true;
|
|
|
|
- if (column->IsEnabled != column->IsEnabledNextFrame)
|
|
|
|
|
|
+ column->IsUserEnabledNextFrame = true;
|
|
|
|
+ if (column->IsUserEnabled != column->IsUserEnabledNextFrame)
|
|
{
|
|
{
|
|
- column->IsEnabled = column->IsEnabledNextFrame;
|
|
|
|
|
|
+ column->IsUserEnabled = column->IsUserEnabledNextFrame;
|
|
table->IsSettingsDirty = true;
|
|
table->IsSettingsDirty = true;
|
|
- if (!column->IsEnabled && column->SortOrder != -1)
|
|
|
|
- table->IsSortSpecsDirty = true;
|
|
|
|
}
|
|
}
|
|
|
|
+ column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0;
|
|
|
|
+
|
|
|
|
+ if (column->SortOrder != -1 && !column->IsEnabled)
|
|
|
|
+ table->IsSortSpecsDirty = true;
|
|
if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
|
|
if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
|
|
table->IsSortSpecsDirty = true;
|
|
table->IsSortSpecsDirty = true;
|
|
|
|
|
|
@@ -1448,7 +1450,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
|
|
|
|
|
|
// Init default visibility/sort state
|
|
// Init default visibility/sort state
|
|
if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0)
|
|
if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0)
|
|
- column->IsEnabled = column->IsEnabledNextFrame = false;
|
|
|
|
|
|
+ column->IsUserEnabled = column->IsUserEnabledNextFrame = false;
|
|
if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0)
|
|
if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0)
|
|
{
|
|
{
|
|
column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs.
|
|
column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs.
|
|
@@ -1540,6 +1542,7 @@ const char* ImGui::TableGetColumnName(const ImGuiTable* table, int column_n)
|
|
// - Require table to have the ImGuiTableFlags_Hideable flag because we are manipulating user accessible state.
|
|
// - Require table to have the ImGuiTableFlags_Hideable flag because we are manipulating user accessible state.
|
|
// - Request will be applied during next layout, which happens on the first call to TableNextRow() after BeginTable().
|
|
// - 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.
|
|
// - For the getter you can test (TableGetColumnFlags() & ImGuiTableColumnFlags_IsEnabled) != 0.
|
|
|
|
+// - Alternative: the ImGuiTableColumnFlags_Disabled is an overriding/master disable flag which will also hide the column from context menu.
|
|
void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
|
void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
@@ -1552,7 +1555,7 @@ void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
|
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);
|
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
|
- column->IsEnabledNextFrame = enabled;
|
|
|
|
|
|
+ column->IsUserEnabledNextFrame = enabled;
|
|
}
|
|
}
|
|
|
|
|
|
// We allow querying for an extra column in order to poll the IsHovered state of the right-most section
|
|
// We allow querying for an extra column in order to poll the IsHovered state of the right-most section
|
|
@@ -3089,16 +3092,19 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
|
for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
|
|
for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
|
|
{
|
|
{
|
|
ImGuiTableColumn* other_column = &table->Columns[other_column_n];
|
|
ImGuiTableColumn* other_column = &table->Columns[other_column_n];
|
|
|
|
+ if (other_column->Flags & ImGuiTableColumnFlags_Disabled)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
const char* name = TableGetColumnName(table, other_column_n);
|
|
const char* name = TableGetColumnName(table, other_column_n);
|
|
if (name == NULL || name[0] == 0)
|
|
if (name == NULL || name[0] == 0)
|
|
name = "<Unknown>";
|
|
name = "<Unknown>";
|
|
|
|
|
|
// Make sure we can't hide the last active column
|
|
// Make sure we can't hide the last active column
|
|
bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true;
|
|
bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true;
|
|
- if (other_column->IsEnabled && table->ColumnsEnabledCount <= 1)
|
|
|
|
|
|
+ if (other_column->IsUserEnabled && table->ColumnsEnabledCount <= 1)
|
|
menu_item_active = false;
|
|
menu_item_active = false;
|
|
- if (MenuItem(name, NULL, other_column->IsEnabled, menu_item_active))
|
|
|
|
- other_column->IsEnabledNextFrame = !other_column->IsEnabled;
|
|
|
|
|
|
+ if (MenuItem(name, NULL, other_column->IsUserEnabled, menu_item_active))
|
|
|
|
+ other_column->IsUserEnabledNextFrame = !other_column->IsUserEnabled;
|
|
}
|
|
}
|
|
PopItemFlag();
|
|
PopItemFlag();
|
|
}
|
|
}
|
|
@@ -3223,7 +3229,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
|
column_settings->DisplayOrder = column->DisplayOrder;
|
|
column_settings->DisplayOrder = column->DisplayOrder;
|
|
column_settings->SortOrder = column->SortOrder;
|
|
column_settings->SortOrder = column->SortOrder;
|
|
column_settings->SortDirection = column->SortDirection;
|
|
column_settings->SortDirection = column->SortDirection;
|
|
- column_settings->IsEnabled = column->IsEnabled;
|
|
|
|
|
|
+ column_settings->IsEnabled = column->IsUserEnabled;
|
|
column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
|
|
column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
|
|
if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0)
|
|
if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0)
|
|
save_ref_scale = true;
|
|
save_ref_scale = true;
|
|
@@ -3237,7 +3243,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
|
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
|
|
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
|
|
if (column->SortOrder != -1)
|
|
if (column->SortOrder != -1)
|
|
settings->SaveFlags |= ImGuiTableFlags_Sortable;
|
|
settings->SaveFlags |= ImGuiTableFlags_Sortable;
|
|
- if (column->IsEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
|
|
|
|
|
|
+ if (column->IsUserEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
|
|
settings->SaveFlags |= ImGuiTableFlags_Hideable;
|
|
settings->SaveFlags |= ImGuiTableFlags_Hideable;
|
|
}
|
|
}
|
|
settings->SaveFlags &= table->Flags;
|
|
settings->SaveFlags &= table->Flags;
|
|
@@ -3295,7 +3301,7 @@ void ImGui::TableLoadSettings(ImGuiTable* table)
|
|
else
|
|
else
|
|
column->DisplayOrder = (ImGuiTableColumnIdx)column_n;
|
|
column->DisplayOrder = (ImGuiTableColumnIdx)column_n;
|
|
display_order_mask |= (ImU64)1 << column->DisplayOrder;
|
|
display_order_mask |= (ImU64)1 << column->DisplayOrder;
|
|
- column->IsEnabled = column->IsEnabledNextFrame = column_settings->IsEnabled;
|
|
|
|
|
|
+ column->IsUserEnabled = column->IsUserEnabledNextFrame = column_settings->IsEnabled;
|
|
column->SortOrder = column_settings->SortOrder;
|
|
column->SortOrder = column_settings->SortOrder;
|
|
column->SortDirection = column_settings->SortDirection;
|
|
column->SortDirection = column_settings->SortDirection;
|
|
}
|
|
}
|