mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Docking: Untangle a little bit of the ActiveIdClickOffset mess.
This commit is contained in:
parent
25a9209b75
commit
b36d1d465d
15
imgui.cpp
15
imgui.cpp
@ -3414,7 +3414,7 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
|
||||
SetActiveID(window->MoveId, window);
|
||||
g.NavDisableHighlight = true;
|
||||
g.ActiveIdNoClearOnFocusLoss = true;
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos;
|
||||
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos;
|
||||
|
||||
bool can_move_window = true;
|
||||
if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
@ -3447,15 +3447,9 @@ void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* nod
|
||||
const bool clicked = IsMouseClicked(0);
|
||||
const bool dragging = IsMouseDragging(0, g.IO.MouseDragThreshold * 1.70f);
|
||||
if (can_undock_node && dragging)
|
||||
{
|
||||
DockContextQueueUndockNode(&g, node);
|
||||
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - node->Pos;
|
||||
}
|
||||
DockContextQueueUndockNode(&g, node); // Will lead to DockNodeStartMouseMovingWindow() -> StartMouseMovingWindow() being called next frame
|
||||
else if (!can_undock_node && (clicked || dragging) && g.MovingWindow != window)
|
||||
{
|
||||
StartMouseMovingWindow(window);
|
||||
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle mouse moving window
|
||||
@ -12775,11 +12769,10 @@ static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWind
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(node->WantMouseMove == true);
|
||||
ImVec2 backup_active_click_offset = g.ActiveIdClickOffset;
|
||||
StartMouseMovingWindow(window);
|
||||
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - node->Pos;
|
||||
g.MovingWindow = window; // If we are docked into a non moveable root window, StartMouseMovingWindow() won't set g.MovingWindow. Override that decision.
|
||||
node->WantMouseMove = false;
|
||||
g.ActiveIdClickOffset = backup_active_click_offset;
|
||||
}
|
||||
|
||||
// Update CentralNode, OnlyNodeWithWindows, LastFocusedNodeID. Copy window class.
|
||||
@ -13296,7 +13289,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
||||
window->DockTabItemRect = host_window->DC.LastItemRect;
|
||||
|
||||
// Update navigation ID on menu layer
|
||||
if (g.NavWindow && g.NavWindow->RootWindowDockStop == window && (window->DC.NavLayerActiveMask & (1 << 1)) == 0)
|
||||
if (g.NavWindow && g.NavWindow->RootWindowDockStop == window && (window->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) == 0)
|
||||
host_window->NavLastIds[1] = window->ID;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user