MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / NavCalcPreferredRefPos

Method NavCalcPreferredRefPos

KBotExt/imgui/imgui.cpp:11308–11334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11306}
11307
11308static ImVec2 ImGui::NavCalcPreferredRefPos()
11309{
11310 ImGuiContext& g = *GImGui;
11311 ImGuiWindow* window = g.NavWindow;
11312 if (g.NavDisableHighlight || !g.NavDisableMouseHover || !window)
11313 {
11314 // Mouse (we need a fallback in case the mouse becomes invalid after being used)
11315 // 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.
11316 // In theory we could move that +1.0f offset in OpenPopupEx()
11317 ImVec2 p = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : g.MouseLastValidPos;
11318 return ImVec2(p.x + 1.0f, p.y);
11319 }
11320 else
11321 {
11322 // When navigation is active and mouse is disabled, pick a position around the bottom left of the currently navigated item
11323 // Take account of upcoming scrolling (maybe set mouse pos should be done in EndFrame?)
11324 ImRect rect_rel = WindowRectRelToAbs(window, window->NavRectRel[g.NavLayer]);
11325 if (window->LastFrameActive != g.FrameCount && (window->ScrollTarget.x != FLT_MAX || window->ScrollTarget.y != FLT_MAX))
11326 {
11327 ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window);
11328 rect_rel.Translate(window->Scroll - next_scroll);
11329 }
11330 ImVec2 pos = ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
11331 ImGuiViewport* viewport = GetMainViewport();
11332 return ImFloor(ImClamp(pos, viewport->Pos, viewport->Pos + viewport->Size)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
11333 }
11334}
11335
11336float ImGui::GetNavTweakPressedAmount(ImGuiAxis axis)
11337{

Callers

nothing calls this directly

Calls 6

ImVec2Function · 0.85
WindowRectRelToAbsFunction · 0.85
ImMinFunction · 0.85
ImFloorFunction · 0.85
ImClampFunction · 0.85

Tested by

no test coverage detected