| 13406 | } |
| 13407 | |
| 13408 | static ImVec2 ImGui::NavCalcPreferredRefPos() |
| 13409 | { |
| 13410 | ImGuiContext& g = *GImGui; |
| 13411 | ImGuiWindow* window = g.NavWindow; |
| 13412 | ImGuiInputSource source = NavCalcPreferredRefPosSource(); |
| 13413 | |
| 13414 | const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID; |
| 13415 | |
| 13416 | if (source != ImGuiInputSource_Mouse && !activated_shortcut && window == NULL) |
| 13417 | source = ImGuiInputSource_Mouse; |
| 13418 | |
| 13419 | // 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. |
| 13420 | if (source == ImGuiInputSource_Mouse) |
| 13421 | { |
| 13422 | // Mouse (we need a fallback in case the mouse becomes invalid after being used) |
| 13423 | // 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. |
| 13424 | // In theory we could move that +1.0f offset in OpenPopupEx() |
| 13425 | ImVec2 p = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : g.MouseLastValidPos; |
| 13426 | return ImVec2(p.x + 1.0f, p.y); |
| 13427 | } |
| 13428 | else |
| 13429 | { |
| 13430 | // When navigation is active and mouse is disabled, pick a position around the bottom left of the currently navigated item |
| 13431 | ImRect ref_rect; |
| 13432 | if (activated_shortcut) |
| 13433 | ref_rect = g.LastItemData.NavRect; |
| 13434 | else if (window != NULL) |
| 13435 | ref_rect = WindowRectRelToAbs(window, window->NavRectRel[g.NavLayer]); |
| 13436 | |
| 13437 | // Take account of upcoming scrolling (maybe set mouse pos should be done in EndFrame?) |
| 13438 | if (window != NULL && window->LastFrameActive != g.FrameCount && (window->ScrollTarget.x != FLT_MAX || window->ScrollTarget.y != FLT_MAX)) |
| 13439 | { |
| 13440 | ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window); |
| 13441 | ref_rect.Translate(window->Scroll - next_scroll); |
| 13442 | } |
| 13443 | 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())); |
| 13444 | ImGuiViewport* viewport = GetMainViewport(); |
| 13445 | 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. |
| 13446 | } |
| 13447 | } |
| 13448 | |
| 13449 | float ImGui::GetNavTweakPressedAmount(ImGuiAxis axis) |
| 13450 | { |
nothing calls this directly
no test coverage detected