mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-21 17:31:45 +00:00
MultiSelect: ImGuiSelectionBasicStorage: move function bodies to cpp file.
+ make ImGuiStorage::BuildSortByKey() less affected by msvc debug mode.
This commit is contained in:
@@ -7821,6 +7821,30 @@ void ImGui::DebugNodeMultiSelectState(ImGuiMultiSelectState* storage)
|
||||
// - ImGuiSelectionExternalStorage
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
ImGuiSelectionBasicStorage::ImGuiSelectionBasicStorage()
|
||||
{
|
||||
Size = 0;
|
||||
UserData = NULL;
|
||||
AdapterIndexToStorageId = [](ImGuiSelectionBasicStorage*, int idx) { return (ImGuiID)idx; };
|
||||
}
|
||||
|
||||
void ImGuiSelectionBasicStorage::Clear()
|
||||
{
|
||||
Size = 0;
|
||||
_Storage.Data.resize(0);
|
||||
}
|
||||
|
||||
void ImGuiSelectionBasicStorage::Swap(ImGuiSelectionBasicStorage& r)
|
||||
{
|
||||
ImSwap(Size, r.Size);
|
||||
_Storage.Data.swap(r._Storage.Data);
|
||||
}
|
||||
|
||||
bool ImGuiSelectionBasicStorage::Contains(ImGuiID id) const
|
||||
{
|
||||
return _Storage.GetInt(id, 0) != 0;
|
||||
}
|
||||
|
||||
// GetNextSelectedItem() is an abstraction allowing us to change our underlying actual storage system without impacting user.
|
||||
// (e.g. store unselected vs compact down, compact down on demand, use raw ImVector<ImGuiID> instead of ImGuiStorage...)
|
||||
ImGuiID ImGuiSelectionBasicStorage::GetNextSelectedItem(void** opaque_it)
|
||||
@@ -7838,6 +7862,13 @@ ImGuiID ImGuiSelectionBasicStorage::GetNextSelectedItem(void** opaque_it)
|
||||
return has_more ? it->key : 0;
|
||||
}
|
||||
|
||||
void ImGuiSelectionBasicStorage::SetItemSelected(ImGuiID id, bool selected)
|
||||
{
|
||||
int* p_int = _Storage.GetIntRef(id, 0);
|
||||
if (selected && *p_int == 0) { *p_int = 1; Size++; }
|
||||
else if (!selected && *p_int != 0) { *p_int = 0; Size--; }
|
||||
}
|
||||
|
||||
// Optimized for batch edits (with same value of 'selected')
|
||||
static void ImGuiSelectionBasicStorage_BatchSetItemSelected(ImGuiSelectionBasicStorage* selection, ImGuiID id, bool selected, int size_before_amends)
|
||||
{
|
||||
@@ -7914,6 +7945,12 @@ void ImGuiSelectionBasicStorage::ApplyRequests(ImGuiMultiSelectIO* ms_io)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
ImGuiSelectionExternalStorage::ImGuiSelectionExternalStorage()
|
||||
{
|
||||
UserData = NULL;
|
||||
AdapterSetItemSelected = NULL;
|
||||
}
|
||||
|
||||
// Apply requests coming from BeginMultiSelect() and EndMultiSelect().
|
||||
// We also pull 'ms_io->ItemsCount' as passed for BeginMultiSelect() for consistency with ImGuiSelectionBasicStorage
|
||||
// This makes no assumption about underlying storage.
|
||||
|
Reference in New Issue
Block a user