Class: ImGuiSelectionBasicStorage
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- ImGuiSelectionBasicStorage
- Defined in:
- lib/imgui.rb
Overview
Optional helper to store multi-selection state + apply multi-selection requests.
-
Used by our demos and provided as a convenience to easily implement basic multi-selection.
-
Iterate selection with ‘void* it = NULL; ImGuiID id; while (selection.GetNextSelectedItem(&it, &id)) { … }’ Or you can check ‘if (Contains(id)) { … }’ for each possible object if their number is not too high to iterate.
-
USING THIS IS NOT MANDATORY. This is only a helper and not a required API.
To store a multi-selection, in your application you could:
-
Use this helper as a convenience. We use our simple key->value ImGuiStorage as a std::set<ImGuiID> replacement.
-
Use your own external storage: e.g. std::set<MyObjectId>, std::vector<MyObjectId>, interval trees, intrusively stored selection etc.
In ImGuiSelectionBasicStorage we:
-
always use indices in the multi-selection API (passed to SetNextItemSelectionUserData(), retrieved in ImGuiMultiSelectIO)
-
use the AdapterIndexToStorageId() indirection layer to abstract how persistent selection data is derived from an index.
-
use decently optimized logic to allow queries and insertion of very large selection sets.
-
do not preserve selection order.
Many combinations are possible depending on how you prefer to store your items and how you prefer to store your selection. Large applications are likely to eventually want to get rid of this indirection layer and do their own thing. See github.com/ocornut/imgui/wiki/Multi-Select for details and pseudo-code using this helper.
Class Method Summary collapse
Instance Method Summary collapse
- #ApplyRequests(ms_io) ⇒ Object
- #Clear ⇒ Object
- #Contains(id) ⇒ Object
- #destroy ⇒ Object
- #GetNextSelectedItem(opaque_it, out_id) ⇒ Object
- #GetStorageIdFromIndex(idx) ⇒ Object
- #SetItemSelected(id, selected) ⇒ Object
- #Swap(r) ⇒ Object
Class Method Details
.create ⇒ Object
2486 2487 2488 |
# File 'lib/imgui.rb', line 2486 def self.create() return ImGuiSelectionBasicStorage.new(ImGui::ImGuiSelectionBasicStorage_ImGuiSelectionBasicStorage()) end |
Instance Method Details
#ApplyRequests(ms_io) ⇒ Object
2466 2467 2468 |
# File 'lib/imgui.rb', line 2466 def ApplyRequests(ms_io) ImGui::ImGuiSelectionBasicStorage_ApplyRequests(self, ms_io) end |
#Clear ⇒ Object
2470 2471 2472 |
# File 'lib/imgui.rb', line 2470 def Clear() ImGui::ImGuiSelectionBasicStorage_Clear(self) end |
#Contains(id) ⇒ Object
2474 2475 2476 |
# File 'lib/imgui.rb', line 2474 def Contains(id) ImGui::ImGuiSelectionBasicStorage_Contains(self, id) end |
#destroy ⇒ Object
2498 2499 2500 |
# File 'lib/imgui.rb', line 2498 def destroy() ImGui::ImGuiSelectionBasicStorage_destroy(self) end |
#GetNextSelectedItem(opaque_it, out_id) ⇒ Object
2478 2479 2480 |
# File 'lib/imgui.rb', line 2478 def GetNextSelectedItem(opaque_it, out_id) ImGui::ImGuiSelectionBasicStorage_GetNextSelectedItem(self, opaque_it, out_id) end |
#GetStorageIdFromIndex(idx) ⇒ Object
2482 2483 2484 |
# File 'lib/imgui.rb', line 2482 def GetStorageIdFromIndex(idx) ImGui::ImGuiSelectionBasicStorage_GetStorageIdFromIndex(self, idx) end |
#SetItemSelected(id, selected) ⇒ Object
2490 2491 2492 |
# File 'lib/imgui.rb', line 2490 def SetItemSelected(id, selected) ImGui::ImGuiSelectionBasicStorage_SetItemSelected(self, id, selected) end |
#Swap(r) ⇒ Object
2494 2495 2496 |
# File 'lib/imgui.rb', line 2494 def Swap(r) ImGui::ImGuiSelectionBasicStorage_Swap(self, r) end |