Tables: Fixed ignoring DefaultHide or DefaultSort data from flags when loading settings that don't have them.
This commit is contained in:
parent
9f43aae226
commit
9b6d0fdb7a
@ -1952,7 +1952,7 @@ struct ImGuiTable
|
||||
ImU64 ActiveMaskByIndex; // Column Index -> IsActive map (Active == not hidden by user/api) in a format adequate for iterating column without touching cold data
|
||||
ImU64 ActiveMaskByDisplayOrder; // Column DisplayOrder -> IsActive map
|
||||
ImU64 VisibleMaskByIndex; // Visible (== Active and not Clipped)
|
||||
ImGuiTableFlags SettingsSaveFlags; // Pre-compute which data we are going to save into the .ini file (e.g. when order is not altered we won't save order)
|
||||
ImGuiTableFlags SettingsLoadedFlags; // Which data were loaded from the .ini file (e.g. when order is not altered we won't save order)
|
||||
int SettingsOffset; // Offset in g.SettingsTables
|
||||
int LastFrameActive;
|
||||
int ColumnsCount; // Number of columns declared in BeginTable()
|
||||
@ -2022,7 +2022,6 @@ struct ImGuiTable
|
||||
bool IsUsingHeaders; // Set when the first row had the ImGuiTableRowFlags_Headers flag.
|
||||
bool IsContextPopupOpen; // Set when default context menu is open (also see: ContextPopupColumn, InstanceInteracted).
|
||||
bool IsSettingsRequestLoad;
|
||||
bool IsSettingsLoaded;
|
||||
bool IsSettingsDirty; // Set when table settings have changed and needs to be reported into ImGuiTableSetttings data.
|
||||
bool IsDefaultDisplayOrder; // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1)
|
||||
bool IsResetDisplayOrderRequest;
|
||||
@ -2050,7 +2049,7 @@ struct ImGuiTableColumnSettings
|
||||
ImS8 DisplayOrder;
|
||||
ImS8 SortOrder;
|
||||
ImS8 SortDirection : 7;
|
||||
ImU8 Visible : 1; // This is called Active in ImGuiTableColumn, in .ini file we call it Visible.
|
||||
ImU8 Visible : 1; // This is called Active in ImGuiTableColumn, but in user-facing code we call this Visible (thus in .ini file)
|
||||
|
||||
ImGuiTableColumnSettings()
|
||||
{
|
||||
|
@ -1466,12 +1466,12 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags,
|
||||
column->ResizeWeight = 1.0f;
|
||||
}
|
||||
}
|
||||
if (table->IsInitializing && !table->IsSettingsLoaded)
|
||||
if (table->IsInitializing)
|
||||
{
|
||||
// Init default visibility/sort state
|
||||
if (flags & ImGuiTableColumnFlags_DefaultHide)
|
||||
if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0)
|
||||
column->IsActive = column->IsActiveNextFrame = false;
|
||||
if (flags & ImGuiTableColumnFlags_DefaultSort)
|
||||
if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0)
|
||||
{
|
||||
column->SortOrder = 0; // Multiple columns using _DefaultSort will be reordered when building the sort specs.
|
||||
column->SortDirection = (column->Flags & ImGuiTableColumnFlags_PreferSortDescending) ? (ImS8)ImGuiSortDirection_Descending : (ImU8)(ImGuiSortDirection_Ascending);
|
||||
@ -2360,7 +2360,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
||||
}
|
||||
settings->ColumnsCount = (ImS8)table->ColumnsCount;
|
||||
|
||||
// Serialize ImGuiTableSettings/ImGuiTableColumnSettings --> ImGuiTable/ImGuiTableColumn
|
||||
// Serialize ImGuiTable/ImGuiTableColumn into ImGuiTableSettings/ImGuiTableColumnSettings
|
||||
IM_ASSERT(settings->ID == table->ID);
|
||||
IM_ASSERT(settings->ColumnsCount == table->ColumnsCount && settings->ColumnsCountMax >= settings->ColumnsCount);
|
||||
ImGuiTableColumn* column = table->Columns.Data;
|
||||
@ -2378,7 +2378,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
||||
column_settings->Visible = column->IsActive;
|
||||
|
||||
// We skip saving some data in the .ini file when they are unnecessary to restore our state
|
||||
// FIXME-TABLE: We don't have logic to easily compare SortOrder to DefaultSortOrder yet.
|
||||
// FIXME-TABLE: We don't have logic to easily compare SortOrder to DefaultSortOrder yet so it's always saved.
|
||||
if (column->DisplayOrder != n)
|
||||
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
|
||||
if (column_settings->SortOrder != -1)
|
||||
@ -2411,10 +2411,9 @@ void ImGui::TableLoadSettings(ImGuiTable* table)
|
||||
{
|
||||
settings = g.SettingsTables.ptr_from_offset(table->SettingsOffset);
|
||||
}
|
||||
table->IsSettingsLoaded = true;
|
||||
settings->SaveFlags = table->Flags;
|
||||
table->SettingsLoadedFlags = settings->SaveFlags;
|
||||
|
||||
// Serialize ImGuiTable/ImGuiTableColumn --> ImGuiTableSettings/ImGuiTableColumnSettings
|
||||
// Serialize ImGuiTableSettings/ImGuiTableColumnSettings into ImGuiTable/ImGuiTableColumn
|
||||
ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings();
|
||||
for (int data_n = 0; data_n < settings->ColumnsCount; data_n++, column_settings++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user