1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-13 18:50:58 +01:00

Moving window doesn't use accumulating MouseDelta so straying out of boundaries keeps moved window at the same spot.

This commit is contained in:
omar 2017-12-25 16:03:58 +01:00
parent 78f48bb795
commit 3849bb4470

View File

@ -2379,9 +2379,10 @@ void ImGui::NewFrame()
IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId); IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId);
if (g.IO.MouseDown[0]) if (g.IO.MouseDown[0])
{ {
g.MovingWindow->RootWindow->PosFloat += g.IO.MouseDelta; ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f) if (g.MovingWindow->RootWindow->PosFloat.x != pos.x || g.MovingWindow->RootWindow->PosFloat.y != pos.y)
MarkIniSettingsDirty(g.MovingWindow->RootWindow); MarkIniSettingsDirty(g.MovingWindow->RootWindow);
g.MovingWindow->RootWindow->PosFloat = pos;
FocusWindow(g.MovingWindow); FocusWindow(g.MovingWindow);
} }
else else
@ -2930,6 +2931,7 @@ void ImGui::EndFrame()
g.MovingWindow = g.HoveredWindow; g.MovingWindow = g.HoveredWindow;
g.MovingWindowMoveId = g.MovingWindow->MoveId; g.MovingWindowMoveId = g.MovingWindow->MoveId;
SetActiveID(g.MovingWindowMoveId, g.HoveredRootWindow); SetActiveID(g.MovingWindowMoveId, g.HoveredRootWindow);
g.ActiveIdClickOffset = g.IO.MousePos - g.MovingWindow->RootWindow->Pos;
} }
} }
else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL) else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL)