62 static ImGuiSelectionBasicStorage selection;
64 ImGui::Text(
"Selection: %d/%d", selection.Size,
ITEMS_COUNT);
65 if (ImGui::BeginChild(
66 "##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20),
67 ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY)) {
68 ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape |
69 ImGuiMultiSelectFlags_BoxSelect1d;
70 ImGuiMultiSelectIO *ms_io =
71 ImGui::BeginMultiSelect(flags, selection.Size,
ITEMS_COUNT);
72 selection.ApplyRequests(ms_io);
74 ImGuiListClipper clipper;
76 if (ms_io->RangeSrcItem != -1)
77 clipper.IncludeItemByIndex(
78 (
int)ms_io->RangeSrcItem);
79 while (clipper.Step()) {
80 for (
int n = clipper.DisplayStart; n < clipper.DisplayEnd; n++) {
84 bool item_is_selected = selection.Contains((ImGuiID)n);
85 ImGui::SetNextItemSelectionUserData(n);
86 ImGui::Selectable(label, item_is_selected);
90 ms_io = ImGui::EndMultiSelect();
91 selection.ApplyRequests(ms_io);