Nav: Mouse pos passed to backend always rounded, so that lossy application of non-integer mouse pos doesn't lead to undesirable movement (#3

This commit is contained in:
ocornut 2016-08-21 00:10:48 +02:00
parent bf42657850
commit 30c04d0dbe

View File

@ -2377,7 +2377,7 @@ static ImVec2 NavCalcPreferredMousePos()
return g.IO.MousePos; return g.IO.MousePos;
ImVec2 p = g.NavWindow->Pos + ImVec2(g.NavRefRectRel.Min.x + ImMin(g.Style.FramePadding.x*4, g.NavRefRectRel.GetWidth()), g.NavRefRectRel.Max.y - ImMin(g.Style.FramePadding.y, g.NavRefRectRel.GetHeight())); ImVec2 p = g.NavWindow->Pos + ImVec2(g.NavRefRectRel.Min.x + ImMin(g.Style.FramePadding.x*4, g.NavRefRectRel.GetWidth()), g.NavRefRectRel.Max.y - ImMin(g.Style.FramePadding.y, g.NavRefRectRel.GetHeight()));
ImRect r = GetVisibleRect(); ImRect r = GetVisibleRect();
return ImClamp(p, r.Min, r.Max); return ImFloor(ImClamp(p, r.Min, r.Max)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
} }
static int FindWindowIndex(ImGuiWindow* window) // FIXME-OPT O(N) static int FindWindowIndex(ImGuiWindow* window) // FIXME-OPT O(N)