mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-05 06:57:13 +08: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);
|
SetActiveID(window->MoveId, window);
|
||||||
g.NavDisableHighlight = true;
|
g.NavDisableHighlight = true;
|
||||||
g.ActiveIdNoClearOnFocusLoss = 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;
|
bool can_move_window = true;
|
||||||
if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
|
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 clicked = IsMouseClicked(0);
|
||||||
const bool dragging = IsMouseDragging(0, g.IO.MouseDragThreshold * 1.70f);
|
const bool dragging = IsMouseDragging(0, g.IO.MouseDragThreshold * 1.70f);
|
||||||
if (can_undock_node && dragging)
|
if (can_undock_node && dragging)
|
||||||
{
|
DockContextQueueUndockNode(&g, node); // Will lead to DockNodeStartMouseMovingWindow() -> StartMouseMovingWindow() being called next frame
|
||||||
DockContextQueueUndockNode(&g, node);
|
|
||||||
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - node->Pos;
|
|
||||||
}
|
|
||||||
else if (!can_undock_node && (clicked || dragging) && g.MovingWindow != window)
|
else if (!can_undock_node && (clicked || dragging) && g.MovingWindow != window)
|
||||||
{
|
|
||||||
StartMouseMovingWindow(window);
|
StartMouseMovingWindow(window);
|
||||||
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle mouse moving window
|
// Handle mouse moving window
|
||||||
@ -12775,11 +12769,10 @@ static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWind
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(node->WantMouseMove == true);
|
IM_ASSERT(node->WantMouseMove == true);
|
||||||
ImVec2 backup_active_click_offset = g.ActiveIdClickOffset;
|
|
||||||
StartMouseMovingWindow(window);
|
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.
|
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;
|
node->WantMouseMove = false;
|
||||||
g.ActiveIdClickOffset = backup_active_click_offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update CentralNode, OnlyNodeWithWindows, LastFocusedNodeID. Copy window class.
|
// 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;
|
window->DockTabItemRect = host_window->DC.LastItemRect;
|
||||||
|
|
||||||
// Update navigation ID on menu layer
|
// 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;
|
host_window->NavLastIds[1] = window->ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user