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
2364 2365 2366 |
# File 'lib/imgui.rb', line 2364 def self.create() return ImGuiSelectionBasicStorage.new(ImGui::ImGuiSelectionBasicStorage_ImGuiSelectionBasicStorage()) end |
Instance Method Details
#ApplyRequests(ms_io) ⇒ Object
2344 2345 2346 |
# File 'lib/imgui.rb', line 2344 def ApplyRequests(ms_io) ImGui::ImGuiSelectionBasicStorage_ApplyRequests(self, ms_io) end |
#Clear ⇒ Object
2348 2349 2350 |
# File 'lib/imgui.rb', line 2348 def Clear() ImGui::ImGuiSelectionBasicStorage_Clear(self) end |
#Contains(id) ⇒ Object
2352 2353 2354 |
# File 'lib/imgui.rb', line 2352 def Contains(id) ImGui::ImGuiSelectionBasicStorage_Contains(self, id) end |
#destroy ⇒ Object
2376 2377 2378 |
# File 'lib/imgui.rb', line 2376 def destroy() ImGui::ImGuiSelectionBasicStorage_destroy(self) end |
#GetNextSelectedItem(opaque_it, out_id) ⇒ Object
2356 2357 2358 |
# File 'lib/imgui.rb', line 2356 def GetNextSelectedItem(opaque_it, out_id) ImGui::ImGuiSelectionBasicStorage_GetNextSelectedItem(self, opaque_it, out_id) end |
#GetStorageIdFromIndex(idx) ⇒ Object
2360 2361 2362 |
# File 'lib/imgui.rb', line 2360 def GetStorageIdFromIndex(idx) ImGui::ImGuiSelectionBasicStorage_GetStorageIdFromIndex(self, idx) end |
#SetItemSelected(id, selected) ⇒ Object
2368 2369 2370 |
# File 'lib/imgui.rb', line 2368 def SetItemSelected(id, selected) ImGui::ImGuiSelectionBasicStorage_SetItemSelected(self, id, selected) end |
#Swap(r) ⇒ Object
2372 2373 2374 |
# File 'lib/imgui.rb', line 2372 def Swap(r) ImGui::ImGuiSelectionBasicStorage_Swap(self, r) end |