Tables: (Breaking change) Sorting: Made it users responsability to clear SpecsDirty back to false, so TableGetSortSpecs() doesn't have side-effect any more. + comments

This commit is contained in:
omar
2020-09-23 12:53:10 +02:00
committed by ocornut
parent f6800e9d3b
commit 931829f701
4 changed files with 29 additions and 24 deletions

View File

@ -2298,7 +2298,7 @@ void ImGui::TableSortSpecsClickColumn(ImGuiTable* table, ImGuiTableColumn* click
// You can sort your data again when 'SpecsChanged == true'. It will be true with sorting specs have changed since
// last call, or the first time.
// Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable()!
const ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
{
ImGuiContext& g = *GImGui;
ImGuiTable* table = g.CurrentTable;
@ -2310,8 +2310,6 @@ const ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
if (table->IsSortSpecsDirty)
TableSortSpecsBuild(table);
table->SortSpecs.SpecsChanged = table->IsSortSpecsChangedForUser;
table->IsSortSpecsChangedForUser = false;
return table->SortSpecs.SpecsCount ? &table->SortSpecs : NULL;
}
@ -2466,9 +2464,8 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
}
table->SortSpecs.Specs = table->SortSpecsData.Data;
table->SortSpecs.SpecsCount = table->SortSpecsData.Size;
table->IsSortSpecsDirty = false;
table->IsSortSpecsChangedForUser = true;
table->SortSpecs.SpecsDirty = true; // Mark as dirty for user
table->IsSortSpecsDirty = false; // Mark as not dirty for us
}
//-------------------------------------------------------------------------