108 static ImGuiSelectionBasicStorage selection;
110 ImGui::Text(
"Selection: %d/%d", selection.Size,
ITEMS_COUNT);
111 if (ImGui::BeginChild(
112 "##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20),
113 ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY)) {
114 ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape |
115 ImGuiMultiSelectFlags_BoxSelect1d;
116 ImGuiMultiSelectIO* ms_io =
117 ImGui::BeginMultiSelect(flags, selection.Size,
ITEMS_COUNT);
118 selection.ApplyRequests(ms_io);
120 ImGuiListClipper clipper;
122 if (ms_io->RangeSrcItem != -1)
123 clipper.IncludeItemByIndex(
124 (
int)ms_io->RangeSrcItem);
125 while (clipper.Step()) {
126 for (
int n = clipper.DisplayStart; n < clipper.DisplayEnd; n++) {
130 bool item_is_selected = selection.Contains((ImGuiID)n);
131 ImGui::SetNextItemSelectionUserData(n);
132 ImGui::Selectable(label, item_is_selected);
136 ms_io = ImGui::EndMultiSelect();
137 selection.ApplyRequests(ms_io);