mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-03 03:37:24 +01:00
Nav: Process and apply mouse move request immediately after move request result comes (#323)
This commit is contained in:
parent
f71cdd13b7
commit
78b7e2dfb3
32
imgui.cpp
32
imgui.cpp
@ -2475,20 +2475,6 @@ static void NavUpdate()
|
||||
g.NavInitDefaultResultExplicit = false;
|
||||
g.NavInitDefaultResultId = 0;
|
||||
|
||||
// Apply application mouse position movement
|
||||
if (g.NavMousePosDirty && g.NavIdIsAlive)
|
||||
{
|
||||
// Set mouse position given our knowledge of the nav widget position from last frame
|
||||
if (g.IO.NavMovesMouse)
|
||||
{
|
||||
g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredMousePos();
|
||||
g.IO.WantMoveMouse = true;
|
||||
}
|
||||
g.NavMousePosDirty = false;
|
||||
}
|
||||
g.NavIdIsAlive = false;
|
||||
g.NavTabbedId = 0;
|
||||
|
||||
// Process navigation move request
|
||||
if (g.NavMoveRequest && g.NavMoveResultId != 0)
|
||||
{
|
||||
@ -2519,6 +2505,10 @@ static void NavUpdate()
|
||||
g.NavWindow->ScrollTarget.y = g.NavMoveResultRectRel.Max.y + g.NavWindow->Scroll.y + g.Style.ItemSpacing.y;
|
||||
g.NavWindow->ScrollTargetCenterRatio.y = 1.0f;
|
||||
}
|
||||
|
||||
// Estimate upcoming scroll so we can offset our relative mouse position so mouse position can be applied immediately (under this block)
|
||||
ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(g.NavWindow);
|
||||
g.NavMoveResultRectRel.Translate(g.NavWindow->Scroll - next_scroll);
|
||||
}
|
||||
|
||||
// Apply result from previous frame navigation directional move request
|
||||
@ -2527,6 +2517,20 @@ static void NavUpdate()
|
||||
g.NavMoveFromClampedRefRect = false;
|
||||
}
|
||||
|
||||
// Apply application mouse position movement, after we had a chance to process move request result.
|
||||
if (g.NavMousePosDirty && g.NavIdIsAlive)
|
||||
{
|
||||
// Set mouse position given our knowledge of the nav widget position from last frame
|
||||
if (g.IO.NavMovesMouse)
|
||||
{
|
||||
g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredMousePos();
|
||||
g.IO.WantMoveMouse = true;
|
||||
}
|
||||
g.NavMousePosDirty = false;
|
||||
}
|
||||
g.NavIdIsAlive = false;
|
||||
g.NavTabbedId = 0;
|
||||
|
||||
// Navigation windowing mode (change focus, move/resize window)
|
||||
if (!g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_PadMenu, ImGuiNavReadMode_Pressed))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user