Return updated ImGuiMultiSelectIO structure. Lifetime: don't hold on ImGuiMultiSelectIO* pointers over multiple frames or past any subsequent call to BeginMultiSelect() or EndMultiSelect().
| 8049 | // Return updated ImGuiMultiSelectIO structure. |
| 8050 | // Lifetime: don't hold on ImGuiMultiSelectIO* pointers over multiple frames or past any subsequent call to BeginMultiSelect() or EndMultiSelect(). |
| 8051 | ImGuiMultiSelectIO* ImGui::EndMultiSelect() |
| 8052 | { |
| 8053 | ImGuiContext& g = *GImGui; |
| 8054 | ImGuiMultiSelectTempData* ms = g.CurrentMultiSelect; |
| 8055 | ImGuiMultiSelectState* storage = ms->Storage; |
| 8056 | ImGuiWindow* window = g.CurrentWindow; |
| 8057 | IM_ASSERT_USER_ERROR(ms->FocusScopeId == g.CurrentFocusScopeId, "EndMultiSelect() FocusScope mismatch!"); |
| 8058 | IM_ASSERT(g.CurrentMultiSelect != NULL && storage->Window == g.CurrentWindow); |
| 8059 | IM_ASSERT(g.MultiSelectTempDataStacked > 0 && &g.MultiSelectTempData[g.MultiSelectTempDataStacked - 1] == g.CurrentMultiSelect); |
| 8060 | |
| 8061 | ImRect scope_rect = CalcScopeRect(ms, window); |
| 8062 | if (ms->IsFocused) |
| 8063 | { |
| 8064 | // We currently don't allow user code to modify RangeSrcItem by writing to BeginIO's version, but that would be an easy change here. |
| 8065 | if (ms->IO.RangeSrcReset || (ms->RangeSrcPassedBy == false && ms->IO.RangeSrcItem != ImGuiSelectionUserData_Invalid)) // Can't read storage->RangeSrcItem here -> we want the state at beginning of the scope (see tests for easy failure) |
| 8066 | { |
| 8067 | IMGUI_DEBUG_LOG_SELECTION("[selection] EndMultiSelect: Reset RangeSrcItem.\n"); // Will set be to NavId. |
| 8068 | storage->RangeSrcItem = ImGuiSelectionUserData_Invalid; |
| 8069 | } |
| 8070 | if (ms->NavIdPassedBy == false && storage->NavIdItem != ImGuiSelectionUserData_Invalid) |
| 8071 | { |
| 8072 | IMGUI_DEBUG_LOG_SELECTION("[selection] EndMultiSelect: Reset NavIdItem.\n"); |
| 8073 | storage->NavIdItem = ImGuiSelectionUserData_Invalid; |
| 8074 | storage->NavIdSelected = -1; |
| 8075 | } |
| 8076 | |
| 8077 | if ((ms->Flags & (ImGuiMultiSelectFlags_BoxSelect1d | ImGuiMultiSelectFlags_BoxSelect2d)) && GetBoxSelectState(ms->BoxSelectId)) |
| 8078 | EndBoxSelect(scope_rect, ms->Flags); |
| 8079 | } |
| 8080 | |
| 8081 | if (ms->IsEndIO == false) |
| 8082 | ms->IO.Requests.resize(0); |
| 8083 | |
| 8084 | // Clear selection when clicking void? |
| 8085 | // We specifically test for IsMouseDragPastThreshold(0) == false to allow box-selection! |
| 8086 | // The InnerRect test is necessary for non-child/decorated windows. |
| 8087 | bool scope_hovered = IsWindowHovered() && window->InnerRect.Contains(g.IO.MousePos); |
| 8088 | if (scope_hovered && (ms->Flags & ImGuiMultiSelectFlags_ScopeRect)) |
| 8089 | scope_hovered &= scope_rect.Contains(g.IO.MousePos); |
| 8090 | if (scope_hovered && g.HoveredId == 0 && g.ActiveId == 0) |
| 8091 | { |
| 8092 | if (ms->Flags & (ImGuiMultiSelectFlags_BoxSelect1d | ImGuiMultiSelectFlags_BoxSelect2d)) |
| 8093 | { |
| 8094 | if (!g.BoxSelectState.IsActive && !g.BoxSelectState.IsStarting && g.IO.MouseClickedCount[0] == 1) |
| 8095 | { |
| 8096 | BoxSelectPreStartDrag(ms->BoxSelectId, ImGuiSelectionUserData_Invalid); |
| 8097 | FocusWindow(window, ImGuiFocusRequestFlags_UnlessBelowModal); |
| 8098 | SetHoveredID(ms->BoxSelectId); |
| 8099 | if (ms->Flags & ImGuiMultiSelectFlags_ScopeRect) |
| 8100 | SetNavID(0, ImGuiNavLayer_Main, ms->FocusScopeId, ImRect(g.IO.MousePos, g.IO.MousePos)); // Automatically switch FocusScope for initial click from void to box-select. |
| 8101 | } |
| 8102 | } |
| 8103 | |
| 8104 | if (ms->Flags & ImGuiMultiSelectFlags_ClearOnClickVoid) |
| 8105 | if (IsMouseReleased(0) && IsMouseDragPastThreshold(0) == false && g.IO.KeyMods == ImGuiMod_None) |
| 8106 | MultiSelectAddSetAll(ms, false); |
| 8107 | } |
| 8108 |
nothing calls this directly
no test coverage detected