mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-04 22:39:05 +08:00
Internals: Moving window: test mouse validity while translating window + using SetWindowPos().
This commit is contained in:
parent
b32bb4e6e3
commit
184a6f1198
@ -3234,13 +3234,13 @@ static void ImGui::UpdateMovingWindow()
|
|||||||
KeepAliveID(g.ActiveId);
|
KeepAliveID(g.ActiveId);
|
||||||
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
|
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
|
||||||
ImGuiWindow* moving_window = g.MovingWindow->RootWindow;
|
ImGuiWindow* moving_window = g.MovingWindow->RootWindow;
|
||||||
if (g.IO.MouseDown[0])
|
if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
|
||||||
{
|
{
|
||||||
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
|
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
|
||||||
if (moving_window->PosFloat.x != pos.x || moving_window->PosFloat.y != pos.y)
|
if (moving_window->PosFloat.x != pos.x || moving_window->PosFloat.y != pos.y)
|
||||||
{
|
{
|
||||||
MarkIniSettingsDirty(moving_window);
|
MarkIniSettingsDirty(moving_window);
|
||||||
moving_window->PosFloat = pos;
|
SetWindowPos(moving_window, pos, ImGuiCond_Always);
|
||||||
}
|
}
|
||||||
FocusWindow(g.MovingWindow);
|
FocusWindow(g.MovingWindow);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user