| 13620 | } |
| 13621 | |
| 13622 | static ImVec2 ImGui::NavCalcPreferredRefPos() |
| 13623 | { |
| 13624 | ImGuiContext& g = *GImGui; |
| 13625 | ImGuiWindow* window = g.NavWindow; |
| 13626 | ImGuiInputSource source = NavCalcPreferredRefPosSource(); |
| 13627 | |
| 13628 | const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID; |
| 13629 | |
| 13630 | // Testing for !activated_shortcut here could in theory be removed if we decided that activating a remote shortcut altered one of the g.NavDisableXXX flag. |
| 13631 | if (source == ImGuiInputSource_Mouse) |
| 13632 | { |
| 13633 | // Mouse (we need a fallback in case the mouse becomes invalid after being used) |
| 13634 | // The +1.0f offset when stored by OpenPopupEx() allows reopening this or another popup (same or another mouse button) while not moving the mouse, it is pretty standard. |
| 13635 | // In theory we could move that +1.0f offset in OpenPopupEx() |
| 13636 | ImVec2 p = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : g.MouseLastValidPos; |
| 13637 | return ImVec2(p.x + 1.0f, p.y); |
| 13638 | } |
| 13639 | else |
| 13640 | { |
| 13641 | // When navigation is active and mouse is disabled, pick a position around the bottom left of the currently navigated item |
| 13642 | ImRect ref_rect; |
| 13643 | if (activated_shortcut) |
| 13644 | ref_rect = g.LastItemData.NavRect; |
| 13645 | else |
| 13646 | ref_rect = WindowRectRelToAbs(window, window->NavRectRel[g.NavLayer]); |
| 13647 | |
| 13648 | // Take account of upcoming scrolling (maybe set mouse pos should be done in EndFrame?) |
| 13649 | if (window->LastFrameActive != g.FrameCount && (window->ScrollTarget.x != FLT_MAX || window->ScrollTarget.y != FLT_MAX)) |
| 13650 | { |
| 13651 | ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window); |
| 13652 | ref_rect.Translate(window->Scroll - next_scroll); |
| 13653 | } |
| 13654 | ImVec2 pos = ImVec2(ref_rect.Min.x + ImMin(g.Style.FramePadding.x * 4, ref_rect.GetWidth()), ref_rect.Max.y - ImMin(g.Style.FramePadding.y, ref_rect.GetHeight())); |
| 13655 | ImGuiViewport* viewport = window->Viewport; |
| 13656 | return ImTrunc(ImClamp(pos, viewport->Pos, viewport->Pos + viewport->Size)); // ImTrunc() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta. |
| 13657 | } |
| 13658 | } |
| 13659 | |
| 13660 | float ImGui::GetNavTweakPressedAmount(ImGuiAxis axis) |
| 13661 | { |
nothing calls this directly
no test coverage detected