Return updated ImGuiMultiSelectIO structure. Lifetime: don't hold on ImGuiMultiSelectIO* pointers over multiple frames or past any subsequent call to BeginMultiSelect() or EndMultiSelect().
| 7948 | // Return updated ImGuiMultiSelectIO structure. |
| 7949 | // Lifetime: don't hold on ImGuiMultiSelectIO* pointers over multiple frames or past any subsequent call to BeginMultiSelect() or EndMultiSelect(). |
| 7950 | ImGuiMultiSelectIO* ImGui::EndMultiSelect() |
| 7951 | { |
| 7952 | ImGuiContext& g = *GImGui; |
| 7953 | ImGuiMultiSelectTempData* ms = g.CurrentMultiSelect; |
| 7954 | ImGuiMultiSelectState* storage = ms->Storage; |
| 7955 | ImGuiWindow* window = g.CurrentWindow; |
| 7956 | IM_ASSERT_USER_ERROR(ms->FocusScopeId == g.CurrentFocusScopeId, "EndMultiSelect() FocusScope mismatch!"); |
| 7957 | IM_ASSERT(g.CurrentMultiSelect != NULL && storage->Window == g.CurrentWindow); |
| 7958 | IM_ASSERT(g.MultiSelectTempDataStacked > 0 && &g.MultiSelectTempData[g.MultiSelectTempDataStacked - 1] == g.CurrentMultiSelect); |
| 7959 | |
| 7960 | ImRect scope_rect = CalcScopeRect(ms, window); |
| 7961 | if (ms->IsFocused) |
| 7962 | { |
| 7963 | // We currently don't allow user code to modify RangeSrcItem by writing to BeginIO's version, but that would be an easy change here. |
| 7964 | 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) |
| 7965 | { |
| 7966 | IMGUI_DEBUG_LOG_SELECTION("[selection] EndMultiSelect: Reset RangeSrcItem.\n"); // Will set be to NavId. |
| 7967 | storage->RangeSrcItem = ImGuiSelectionUserData_Invalid; |
| 7968 | } |
| 7969 | if (ms->NavIdPassedBy == false && storage->NavIdItem != ImGuiSelectionUserData_Invalid) |
| 7970 | { |
| 7971 | IMGUI_DEBUG_LOG_SELECTION("[selection] EndMultiSelect: Reset NavIdItem.\n"); |
| 7972 | storage->NavIdItem = ImGuiSelectionUserData_Invalid; |
| 7973 | storage->NavIdSelected = -1; |
| 7974 | } |
| 7975 | |
| 7976 | if ((ms->Flags & (ImGuiMultiSelectFlags_BoxSelect1d | ImGuiMultiSelectFlags_BoxSelect2d)) && GetBoxSelectState(ms->BoxSelectId)) |
| 7977 | EndBoxSelect(scope_rect, ms->Flags); |
| 7978 | } |
| 7979 | |
| 7980 | if (ms->IsEndIO == false) |
| 7981 | ms->IO.Requests.resize(0); |
| 7982 | |
| 7983 | // Clear selection when clicking void? |
| 7984 | // We specifically test for IsMouseDragPastThreshold(0) == false to allow box-selection! |
| 7985 | // The InnerRect test is necessary for non-child/decorated windows. |
| 7986 | bool scope_hovered = IsWindowHovered() && window->InnerRect.Contains(g.IO.MousePos); |
| 7987 | if (scope_hovered && (ms->Flags & ImGuiMultiSelectFlags_ScopeRect)) |
| 7988 | scope_hovered &= scope_rect.Contains(g.IO.MousePos); |
| 7989 | if (scope_hovered && g.HoveredId == 0 && g.ActiveId == 0) |
| 7990 | { |
| 7991 | if (ms->Flags & (ImGuiMultiSelectFlags_BoxSelect1d | ImGuiMultiSelectFlags_BoxSelect2d)) |
| 7992 | { |
| 7993 | if (!g.BoxSelectState.IsActive && !g.BoxSelectState.IsStarting && g.IO.MouseClickedCount[0] == 1) |
| 7994 | { |
| 7995 | BoxSelectPreStartDrag(ms->BoxSelectId, ImGuiSelectionUserData_Invalid); |
| 7996 | FocusWindow(window, ImGuiFocusRequestFlags_UnlessBelowModal); |
| 7997 | SetHoveredID(ms->BoxSelectId); |
| 7998 | if (ms->Flags & ImGuiMultiSelectFlags_ScopeRect) |
| 7999 | SetNavID(0, ImGuiNavLayer_Main, ms->FocusScopeId, ImRect(g.IO.MousePos, g.IO.MousePos)); // Automatically switch FocusScope for initial click from void to box-select. |
| 8000 | } |
| 8001 | } |
| 8002 | |
| 8003 | if (ms->Flags & ImGuiMultiSelectFlags_ClearOnClickVoid) |
| 8004 | if (IsMouseReleased(0) && IsMouseDragPastThreshold(0) == false && g.IO.KeyMods == ImGuiMod_None) |
| 8005 | MultiSelectAddSetAll(ms, false); |
| 8006 | } |
| 8007 |
nothing calls this directly
no test coverage detected