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

Function NavBiasScoringRect

KBotExt/imgui/imgui.cpp:11546–11568  ·  view source on GitHub ↗

Bias scoring rect ahead of scoring + update preferred pos (if missing) using source position

Source from the content-addressed store, hash-verified

11544
11545// Bias scoring rect ahead of scoring + update preferred pos (if missing) using source position
11546static void NavBiasScoringRect(ImRect& r, ImVec2& preferred_pos_rel, ImGuiDir move_dir, ImGuiNavMoveFlags move_flags)
11547{
11548 // Bias initial rect
11549 ImGuiContext& g = *GImGui;
11550 const ImVec2 rel_to_abs_offset = g.NavWindow->DC.CursorStartPos;
11551
11552 // Initialize bias on departure if we don't have any. So mouse-click + arrow will record bias.
11553 // - We default to L/U bias, so moving down from a large source item into several columns will land on left-most column.
11554 // - But each successful move sets new bias on one axis, only cleared when using mouse.
11555 if ((move_flags & ImGuiNavMoveFlags_Forwarded) == 0)
11556 {
11557 if (preferred_pos_rel.x == FLT_MAX)
11558 preferred_pos_rel.x = ImMin(r.Min.x + 1.0f, r.Max.x) - rel_to_abs_offset.x;
11559 if (preferred_pos_rel.y == FLT_MAX)
11560 preferred_pos_rel.y = r.GetCenter().y - rel_to_abs_offset.y;
11561 }
11562
11563 // Apply general bias on the other axis
11564 if ((move_dir == ImGuiDir_Up || move_dir == ImGuiDir_Down) && preferred_pos_rel.x != FLT_MAX)
11565 r.Min.x = r.Max.x = preferred_pos_rel.x + rel_to_abs_offset.x;
11566 else if ((move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) && preferred_pos_rel.y != FLT_MAX)
11567 r.Min.y = r.Max.y = preferred_pos_rel.y + rel_to_abs_offset.y;
11568}
11569
11570void ImGui::NavUpdateCreateMoveRequest()
11571{

Callers 1

Calls 2

ImMinFunction · 0.85
GetCenterMethod · 0.80

Tested by

no test coverage detected