|
@@ -2542,20 +2542,18 @@ ImGuiStoragePair* ImLowerBound(ImGuiStoragePair* in_begin, ImGuiStoragePair* in_
|
|
|
return in_p;
|
|
|
}
|
|
|
|
|
|
+static int IMGUI_CDECL PairComparerByID(const void* lhs, const void* rhs)
|
|
|
+{
|
|
|
+ // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that.
|
|
|
+ ImGuiID lhs_v = ((const ImGuiStoragePair*)lhs)->key;
|
|
|
+ ImGuiID rhs_v = ((const ImGuiStoragePair*)rhs)->key;
|
|
|
+ return (lhs_v > rhs_v ? +1 : lhs_v < rhs_v ? -1 : 0);
|
|
|
+}
|
|
|
+
|
|
|
// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
|
|
|
void ImGuiStorage::BuildSortByKey()
|
|
|
{
|
|
|
- struct StaticFunc
|
|
|
- {
|
|
|
- static int IMGUI_CDECL PairComparerByID(const void* lhs, const void* rhs)
|
|
|
- {
|
|
|
- // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that.
|
|
|
- if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1;
|
|
|
- if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1;
|
|
|
- return 0;
|
|
|
- }
|
|
|
- };
|
|
|
- ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairComparerByID);
|
|
|
+ ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), PairComparerByID);
|
|
|
}
|
|
|
|
|
|
int ImGuiStorage::GetInt(ImGuiID key, int default_val) const
|