mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Docking: Moved code unjustly in DockNodeTreeFindNodeByPos() out of it and into caller (should have no side-effect ideally). Removed dupe in Begin() from earlier merge.
This commit is contained in:
parent
2c13a74a9d
commit
acf043a675
39
imgui.cpp
39
imgui.cpp
@ -6056,10 +6056,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
||||||
window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
||||||
|
|
||||||
// Lock menu offset so size calculation can use it as menu-bar windows need a minimum size.
|
|
||||||
window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
|
||||||
window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
|
||||||
|
|
||||||
// Collapse window by double-clicking on title bar
|
// Collapse window by double-clicking on title bar
|
||||||
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
|
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
|
||||||
if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse) && !window->DockIsActive)
|
if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse) && !window->DockIsActive)
|
||||||
@ -11757,7 +11753,7 @@ namespace ImGui
|
|||||||
static void DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child);
|
static void DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child);
|
||||||
static void DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes = false);
|
static void DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes = false);
|
||||||
static void DockNodeTreeUpdateSplitter(ImGuiDockNode* node);
|
static void DockNodeTreeUpdateSplitter(ImGuiDockNode* node);
|
||||||
static ImGuiDockNode* DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos);
|
static ImGuiDockNode* DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode* node, ImVec2 pos);
|
||||||
static ImGuiDockNode* DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node);
|
static ImGuiDockNode* DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
@ -14026,13 +14022,13 @@ ImGuiDockNode* ImGui::DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiDockNode* ImGui::DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos)
|
ImGuiDockNode* ImGui::DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode* node, ImVec2 pos)
|
||||||
{
|
{
|
||||||
if (!node->IsVisible)
|
if (!node->IsVisible)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const float dock_spacing = g.Style.ItemInnerSpacing.x;
|
const float dock_spacing = g.Style.ItemInnerSpacing.x; // FIXME: Relation to DOCKING_SPLITTER_SIZE?
|
||||||
ImRect r(node->Pos, node->Pos + node->Size);
|
ImRect r(node->Pos, node->Pos + node->Size);
|
||||||
r.Expand(dock_spacing * 0.5f);
|
r.Expand(dock_spacing * 0.5f);
|
||||||
bool inside = r.Contains(pos);
|
bool inside = r.Contains(pos);
|
||||||
@ -14041,20 +14037,11 @@ ImGuiDockNode* ImGui::DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos)
|
|||||||
|
|
||||||
if (node->IsLeafNode())
|
if (node->IsLeafNode())
|
||||||
return node;
|
return node;
|
||||||
if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(node->ChildNodes[0], pos))
|
if (ImGuiDockNode* hovered_node = DockNodeTreeFindVisibleNodeByPos(node->ChildNodes[0], pos))
|
||||||
return hovered_node;
|
return hovered_node;
|
||||||
if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(node->ChildNodes[1], pos))
|
if (ImGuiDockNode* hovered_node = DockNodeTreeFindVisibleNodeByPos(node->ChildNodes[1], pos))
|
||||||
return hovered_node;
|
return hovered_node;
|
||||||
|
|
||||||
// There is an edge case when docking into a dockspace which only has inactive nodes (because none of the windows are active)
|
|
||||||
// In this case we need to fallback into any leaf mode, possibly the central node.
|
|
||||||
if (node->IsDockSpace() && node->IsRootNode())
|
|
||||||
{
|
|
||||||
if (node->CentralNode && node->IsLeafNode()) // FIXME-20181220: We should not have to test for IsLeafNode() here but we have another bug to fix first.
|
|
||||||
return node->CentralNode;
|
|
||||||
return DockNodeTreeFindFallbackLeafNode(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14876,7 +14863,19 @@ void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window)
|
|||||||
ImGuiDockNode* node = NULL;
|
ImGuiDockNode* node = NULL;
|
||||||
bool allow_null_target_node = false;
|
bool allow_null_target_node = false;
|
||||||
if (window->DockNodeAsHost)
|
if (window->DockNodeAsHost)
|
||||||
node = DockNodeTreeFindNodeByPos(window->DockNodeAsHost, g.IO.MousePos);
|
{
|
||||||
|
node = DockNodeTreeFindVisibleNodeByPos(window->DockNodeAsHost, g.IO.MousePos);
|
||||||
|
|
||||||
|
// There is an edge case when docking into a dockspace which only has inactive nodes (because none of the windows are active)
|
||||||
|
// In this case we need to fallback into any leaf mode, possibly the central node.
|
||||||
|
if (node && node->IsDockSpace() && node->IsRootNode())
|
||||||
|
{
|
||||||
|
if (node->CentralNode && node->IsLeafNode()) // FIXME-20181220: We should not have to test for IsLeafNode() here but we have another bug to fix first.
|
||||||
|
node = node->CentralNode;
|
||||||
|
else
|
||||||
|
node = DockNodeTreeFindFallbackLeafNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (window->DockNode) // && window->DockIsActive)
|
else if (window->DockNode) // && window->DockIsActive)
|
||||||
node = window->DockNode;
|
node = window->DockNode;
|
||||||
else
|
else
|
||||||
@ -15975,7 +15974,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
|
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
|
||||||
{
|
{
|
||||||
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
|
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
|
||||||
if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(root_node, g.IO.MousePos))
|
if (ImGuiDockNode* hovered_node = DockNodeTreeFindVisibleNodeByPos(root_node, g.IO.MousePos))
|
||||||
if (hovered_node != node)
|
if (hovered_node != node)
|
||||||
continue;
|
continue;
|
||||||
char buf[64] = "";
|
char buf[64] = "";
|
||||||
|
@ -1085,8 +1085,8 @@ enum ImGuiDockNodeFlagsPrivate_
|
|||||||
ImGuiDockNodeFlags_NoDockingSplitOther = 1 << 18, // [EXPERIMENTAL] Prevent this node from splitting another window/node.
|
ImGuiDockNodeFlags_NoDockingSplitOther = 1 << 18, // [EXPERIMENTAL] Prevent this node from splitting another window/node.
|
||||||
ImGuiDockNodeFlags_NoDockingOverMe = 1 << 19, // [EXPERIMENTAL] Prevent another window/node to be docked over this node.
|
ImGuiDockNodeFlags_NoDockingOverMe = 1 << 19, // [EXPERIMENTAL] Prevent another window/node to be docked over this node.
|
||||||
ImGuiDockNodeFlags_NoDockingOverOther = 1 << 20, // [EXPERIMENTAL] Prevent this node to be docked over another window/node.
|
ImGuiDockNodeFlags_NoDockingOverOther = 1 << 20, // [EXPERIMENTAL] Prevent this node to be docked over another window/node.
|
||||||
ImGuiDockNodeFlags_NoResizeX = 1 << 21, // [EXPERIMENTAL]
|
ImGuiDockNodeFlags_NoResizeX = 1 << 21, // [EXPERIMENTAL]
|
||||||
ImGuiDockNodeFlags_NoResizeY = 1 << 22, // [EXPERIMENTAL]
|
ImGuiDockNodeFlags_NoResizeY = 1 << 22, // [EXPERIMENTAL]
|
||||||
ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0,
|
ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0,
|
||||||
ImGuiDockNodeFlags_NoResizeFlagsMask_ = ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_NoResizeX | ImGuiDockNodeFlags_NoResizeY,
|
ImGuiDockNodeFlags_NoResizeFlagsMask_ = ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_NoResizeX | ImGuiDockNodeFlags_NoResizeY,
|
||||||
ImGuiDockNodeFlags_LocalFlagsMask_ = ImGuiDockNodeFlags_NoSplit | ImGuiDockNodeFlags_NoResizeFlagsMask_ | ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoDocking,
|
ImGuiDockNodeFlags_LocalFlagsMask_ = ImGuiDockNodeFlags_NoSplit | ImGuiDockNodeFlags_NoResizeFlagsMask_ | ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoDocking,
|
||||||
|
Loading…
Reference in New Issue
Block a user