mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 09:30:56 +01:00
MovingWindow: Proper fix for 651538e
attempt, without altering MovingWindow which has side-effects. Clicking on a window with the ImGuiWIndowFlags_NoMove flags takes an ActiveId so we can't hover something else. (ref #1381, #1337)
This commit is contained in:
parent
b74f24c3e5
commit
6a1011cf53
16
imgui.cpp
16
imgui.cpp
@ -2378,10 +2378,10 @@ void ImGui::NewFrame()
|
||||
g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
|
||||
g.IO.Framerate = 1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame));
|
||||
|
||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
|
||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering).
|
||||
if (g.MovingWindowMoveId && g.MovingWindowMoveId == g.ActiveId)
|
||||
{
|
||||
KeepAliveID(g.MovingWindowMoveId);
|
||||
KeepAliveID(g.ActiveId);
|
||||
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
|
||||
IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId);
|
||||
if (g.IO.MouseDown[0])
|
||||
@ -2401,6 +2401,13 @@ void ImGui::NewFrame()
|
||||
}
|
||||
else
|
||||
{
|
||||
// When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others.
|
||||
if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId)
|
||||
{
|
||||
KeepAliveID(g.ActiveId);
|
||||
if (!g.IO.MouseDown[0])
|
||||
ClearActiveID();
|
||||
}
|
||||
g.MovingWindow = NULL;
|
||||
g.MovingWindowMoveId = 0;
|
||||
}
|
||||
@ -2934,13 +2941,14 @@ void ImGui::EndFrame()
|
||||
{
|
||||
if (g.HoveredRootWindow != NULL)
|
||||
{
|
||||
// Set ActiveId even if the _NoMove flag is set, without it dragging away from a window with _NoMove would activate hover on other windows.
|
||||
FocusWindow(g.HoveredWindow);
|
||||
SetActiveID(g.HoveredWindow->MoveId, g.HoveredWindow);
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredRootWindow->Pos;
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovingWindow = g.HoveredWindow;
|
||||
g.MovingWindowMoveId = g.MovingWindow->MoveId;
|
||||
SetActiveID(g.MovingWindowMoveId, g.HoveredRootWindow);
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - g.MovingWindow->RootWindow->Pos;
|
||||
}
|
||||
}
|
||||
else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user