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
2480 2481 2482 |
# File 'lib/imgui.rb', line 2480 def self.create() return ImGuiSelectionBasicStorage.new(ImGui::ImGuiSelectionBasicStorage_ImGuiSelectionBasicStorage()) end |
Instance Method Details
#ApplyRequests(ms_io) ⇒ Object
2460 2461 2462 |
# File 'lib/imgui.rb', line 2460 def ApplyRequests(ms_io) ImGui::ImGuiSelectionBasicStorage_ApplyRequests(self, ms_io) end |
#Clear ⇒ Object
2464 2465 2466 |
# File 'lib/imgui.rb', line 2464 def Clear() ImGui::ImGuiSelectionBasicStorage_Clear(self) end |
#Contains(id) ⇒ Object
2468 2469 2470 |
# File 'lib/imgui.rb', line 2468 def Contains(id) ImGui::ImGuiSelectionBasicStorage_Contains(self, id) end |
#destroy ⇒ Object
2492 2493 2494 |
# File 'lib/imgui.rb', line 2492 def destroy() ImGui::ImGuiSelectionBasicStorage_destroy(self) end |
#GetNextSelectedItem(opaque_it, out_id) ⇒ Object
2472 2473 2474 |
# File 'lib/imgui.rb', line 2472 def GetNextSelectedItem(opaque_it, out_id) ImGui::ImGuiSelectionBasicStorage_GetNextSelectedItem(self, opaque_it, out_id) end |
#GetStorageIdFromIndex(idx) ⇒ Object
2476 2477 2478 |
# File 'lib/imgui.rb', line 2476 def GetStorageIdFromIndex(idx) ImGui::ImGuiSelectionBasicStorage_GetStorageIdFromIndex(self, idx) end |
#SetItemSelected(id, selected) ⇒ Object
2484 2485 2486 |
# File 'lib/imgui.rb', line 2484 def SetItemSelected(id, selected) ImGui::ImGuiSelectionBasicStorage_SetItemSelected(self, id, selected) end |
#Swap(r) ⇒ Object
2488 2489 2490 |
# File 'lib/imgui.rb', line 2488 def Swap(r) ImGui::ImGuiSelectionBasicStorage_Swap(self, r) end |