mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-21 23:26:36 +00:00
Docking: Renamed target_node > node in some functions to facilitate debugger watch use across functions.
This commit is contained in:
parent
224f087a5f
commit
800fb26606
91
imgui.cpp
91
imgui.cpp
@ -11272,7 +11272,7 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
|
|||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
ImGuiWindow* payload_window = req->DockPayload; // Optional
|
ImGuiWindow* payload_window = req->DockPayload; // Optional
|
||||||
ImGuiWindow* target_window = req->DockTargetWindow;
|
ImGuiWindow* target_window = req->DockTargetWindow;
|
||||||
ImGuiDockNode* target_node = req->DockTargetNode;
|
ImGuiDockNode* node = req->DockTargetNode;
|
||||||
|
|
||||||
// Decide which Tab will be selected at the end of the operation
|
// Decide which Tab will be selected at the end of the operation
|
||||||
ImGuiID next_selected_id = 0;
|
ImGuiID next_selected_id = 0;
|
||||||
@ -11289,21 +11289,21 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
|
|||||||
|
|
||||||
// FIXME-DOCK: When we are trying to dock an existing single-window node into a loose window, transfer Node ID as well
|
// FIXME-DOCK: When we are trying to dock an existing single-window node into a loose window, transfer Node ID as well
|
||||||
// When processing an interactive split, usually LastFrameAlive will be < g.FrameCount. But DockBuilder operations can make it ==.
|
// When processing an interactive split, usually LastFrameAlive will be < g.FrameCount. But DockBuilder operations can make it ==.
|
||||||
if (target_node)
|
if (node)
|
||||||
IM_ASSERT(target_node->LastFrameAlive <= g.FrameCount);
|
IM_ASSERT(node->LastFrameAlive <= g.FrameCount);
|
||||||
if (target_node && target_window && target_node == target_window->DockNodeAsHost)
|
if (node && target_window && node == target_window->DockNodeAsHost)
|
||||||
IM_ASSERT(target_node->Windows.Size > 0 || target_node->IsSplitNode() || target_node->IsCentralNode());
|
IM_ASSERT(node->Windows.Size > 0 || node->IsSplitNode() || node->IsCentralNode());
|
||||||
|
|
||||||
// Create new node and add existing window to it
|
// Create new node and add existing window to it
|
||||||
if (target_node == NULL)
|
if (node == NULL)
|
||||||
{
|
{
|
||||||
target_node = DockContextAddNode(ctx, 0);
|
node = DockContextAddNode(ctx, 0);
|
||||||
target_node->Pos = target_window->Pos;
|
node->Pos = target_window->Pos;
|
||||||
target_node->Size = target_window->Size;
|
node->Size = target_window->Size;
|
||||||
if (target_window->DockNodeAsHost == NULL)
|
if (target_window->DockNodeAsHost == NULL)
|
||||||
{
|
{
|
||||||
DockNodeAddWindow(target_node, target_window, true);
|
DockNodeAddWindow(node, target_window, true);
|
||||||
target_node->TabBar->Tabs[0].Flags &= ~ImGuiTabItemFlags_Unsorted;
|
node->TabBar->Tabs[0].Flags &= ~ImGuiTabItemFlags_Unsorted;
|
||||||
target_window->DockIsActive = true;
|
target_window->DockIsActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11315,21 +11315,21 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
|
|||||||
const ImGuiAxis split_axis = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
|
const ImGuiAxis split_axis = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
|
||||||
const int split_inheritor_child_idx = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0; // Current contents will be moved to the opposite side
|
const int split_inheritor_child_idx = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0; // Current contents will be moved to the opposite side
|
||||||
const float split_ratio = req->DockSplitRatio;
|
const float split_ratio = req->DockSplitRatio;
|
||||||
DockNodeTreeSplit(ctx, target_node, split_axis, split_inheritor_child_idx, split_ratio, payload_node); // payload_node may be NULL here!
|
DockNodeTreeSplit(ctx, node, split_axis, split_inheritor_child_idx, split_ratio, payload_node); // payload_node may be NULL here!
|
||||||
ImGuiDockNode* new_node = target_node->ChildNodes[split_inheritor_child_idx ^ 1];
|
ImGuiDockNode* new_node = node->ChildNodes[split_inheritor_child_idx ^ 1];
|
||||||
new_node->HostWindow = target_node->HostWindow;
|
new_node->HostWindow = node->HostWindow;
|
||||||
target_node = new_node;
|
node = new_node;
|
||||||
}
|
}
|
||||||
target_node->LocalFlags &= ~ImGuiDockNodeFlags_HiddenTabBar;
|
node->LocalFlags &= ~ImGuiDockNodeFlags_HiddenTabBar;
|
||||||
|
|
||||||
if (target_node != payload_node)
|
if (node != payload_node)
|
||||||
{
|
{
|
||||||
// Create tab bar before we call DockNodeMoveWindows (which would attempt to move the old tab-bar, which would lead us to payload tabs wrongly appearing before target tabs!)
|
// Create tab bar before we call DockNodeMoveWindows (which would attempt to move the old tab-bar, which would lead us to payload tabs wrongly appearing before target tabs!)
|
||||||
if (target_node->Windows.Size > 0 && target_node->TabBar == NULL)
|
if (node->Windows.Size > 0 && node->TabBar == NULL)
|
||||||
{
|
{
|
||||||
DockNodeAddTabBar(target_node);
|
DockNodeAddTabBar(node);
|
||||||
for (int n = 0; n < target_node->Windows.Size; n++)
|
for (int n = 0; n < node->Windows.Size; n++)
|
||||||
TabBarAddTab(target_node->TabBar, ImGuiTabItemFlags_None, target_node->Windows[n]);
|
TabBarAddTab(node->TabBar, ImGuiTabItemFlags_None, node->Windows[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload_node != NULL)
|
if (payload_node != NULL)
|
||||||
@ -11337,7 +11337,7 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
|
|||||||
// Transfer full payload node (with 1+ child windows or child nodes)
|
// Transfer full payload node (with 1+ child windows or child nodes)
|
||||||
if (payload_node->IsSplitNode())
|
if (payload_node->IsSplitNode())
|
||||||
{
|
{
|
||||||
if (target_node->Windows.Size > 0)
|
if (node->Windows.Size > 0)
|
||||||
{
|
{
|
||||||
// We can dock a split payload into a node that already has windows _only_ if our payload is a node tree with a single visible node.
|
// We can dock a split payload into a node that already has windows _only_ if our payload is a node tree with a single visible node.
|
||||||
// In this situation, we move the windows of the target node into the currently visible node of the payload.
|
// In this situation, we move the windows of the target node into the currently visible node of the payload.
|
||||||
@ -11346,28 +11346,28 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
|
|||||||
ImGuiDockNode* visible_node = payload_node->OnlyNodeWithWindows;
|
ImGuiDockNode* visible_node = payload_node->OnlyNodeWithWindows;
|
||||||
if (visible_node->TabBar)
|
if (visible_node->TabBar)
|
||||||
IM_ASSERT(visible_node->TabBar->Tabs.Size > 0);
|
IM_ASSERT(visible_node->TabBar->Tabs.Size > 0);
|
||||||
DockNodeMoveWindows(target_node, visible_node);
|
DockNodeMoveWindows(node, visible_node);
|
||||||
DockNodeMoveWindows(visible_node, target_node);
|
DockNodeMoveWindows(visible_node, node);
|
||||||
DockSettingsRenameNodeReferences(target_node->ID, visible_node->ID);
|
DockSettingsRenameNodeReferences(node->ID, visible_node->ID);
|
||||||
}
|
}
|
||||||
if (target_node->IsCentralNode())
|
if (node->IsCentralNode())
|
||||||
{
|
{
|
||||||
// Central node property needs to be moved to a leaf node, pick the last focused one.
|
// Central node property needs to be moved to a leaf node, pick the last focused one.
|
||||||
// FIXME-DOCKING: If we had to transfer other flags here, what would the policy be?
|
// FIXME-DOCKING: If we had to transfer other flags here, what would the policy be?
|
||||||
ImGuiDockNode* last_focused_node = DockContextFindNodeByID(ctx, payload_node->LastFocusedNodeID);
|
ImGuiDockNode* last_focused_node = DockContextFindNodeByID(ctx, payload_node->LastFocusedNodeID);
|
||||||
IM_ASSERT(last_focused_node != NULL && DockNodeGetRootNode(last_focused_node) == DockNodeGetRootNode(payload_node));
|
IM_ASSERT(last_focused_node != NULL && DockNodeGetRootNode(last_focused_node) == DockNodeGetRootNode(payload_node));
|
||||||
last_focused_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
|
last_focused_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
|
||||||
target_node->LocalFlags &= ~ImGuiDockNodeFlags_CentralNode;
|
node->LocalFlags &= ~ImGuiDockNodeFlags_CentralNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
IM_ASSERT(target_node->Windows.Size == 0);
|
IM_ASSERT(node->Windows.Size == 0);
|
||||||
DockNodeMoveChildNodes(target_node, payload_node);
|
DockNodeMoveChildNodes(node, payload_node);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ImGuiID payload_dock_id = payload_node->ID;
|
const ImGuiID payload_dock_id = payload_node->ID;
|
||||||
DockNodeMoveWindows(target_node, payload_node);
|
DockNodeMoveWindows(node, payload_node);
|
||||||
DockSettingsRenameNodeReferences(payload_dock_id, target_node->ID);
|
DockSettingsRenameNodeReferences(payload_dock_id, node->ID);
|
||||||
}
|
}
|
||||||
DockContextRemoveNode(ctx, payload_node, true);
|
DockContextRemoveNode(ctx, payload_node, true);
|
||||||
}
|
}
|
||||||
@ -11375,15 +11375,15 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
|
|||||||
{
|
{
|
||||||
// Transfer single window
|
// Transfer single window
|
||||||
const ImGuiID payload_dock_id = payload_window->DockId;
|
const ImGuiID payload_dock_id = payload_window->DockId;
|
||||||
target_node->VisibleWindow = payload_window;
|
node->VisibleWindow = payload_window;
|
||||||
DockNodeAddWindow(target_node, payload_window, true);
|
DockNodeAddWindow(node, payload_window, true);
|
||||||
if (payload_dock_id != 0)
|
if (payload_dock_id != 0)
|
||||||
DockSettingsRenameNodeReferences(payload_dock_id, target_node->ID);
|
DockSettingsRenameNodeReferences(payload_dock_id, node->ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update selection immediately
|
// Update selection immediately
|
||||||
if (ImGuiTabBar* tab_bar = target_node->TabBar)
|
if (ImGuiTabBar* tab_bar = node->TabBar)
|
||||||
tab_bar->NextSelectedTabId = next_selected_id;
|
tab_bar->NextSelectedTabId = next_selected_id;
|
||||||
MarkIniSettingsDirty();
|
MarkIniSettingsDirty();
|
||||||
}
|
}
|
||||||
@ -13653,36 +13653,37 @@ void ImGui::BeginAsDockableDragDropTarget(ImGuiWindow* window)
|
|||||||
ImGuiWindow* payload_window = *(ImGuiWindow**)payload->Data;
|
ImGuiWindow* payload_window = *(ImGuiWindow**)payload->Data;
|
||||||
if (AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect))
|
if (AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect))
|
||||||
{
|
{
|
||||||
|
// Select target node
|
||||||
|
ImGuiDockNode* node = NULL;
|
||||||
bool allow_null_target_node = false;
|
bool allow_null_target_node = false;
|
||||||
ImGuiDockNode* target_node = NULL;
|
|
||||||
if (window->DockNodeAsHost)
|
if (window->DockNodeAsHost)
|
||||||
target_node = DockNodeTreeFindNodeByPos(window->DockNodeAsHost, g.IO.MousePos);
|
node = DockNodeTreeFindNodeByPos(window->DockNodeAsHost, g.IO.MousePos);
|
||||||
else if (window->DockNode) // && window->DockIsActive)
|
else if (window->DockNode) // && window->DockIsActive)
|
||||||
target_node = window->DockNode;
|
node = window->DockNode;
|
||||||
else
|
else
|
||||||
allow_null_target_node = true; // Dock into a regular window
|
allow_null_target_node = true; // Dock into a regular window
|
||||||
|
|
||||||
const ImRect explicit_target_rect = (target_node && target_node->TabBar && !target_node->IsHiddenTabBar() && !target_node->IsNoTabBar()) ? target_node->TabBar->BarRect : ImRect(window->Pos, window->Pos + ImVec2(window->Size.x, GetFrameHeight()));
|
const ImRect explicit_target_rect = (node && node->TabBar && !node->IsHiddenTabBar() && !node->IsNoTabBar()) ? node->TabBar->BarRect : ImRect(window->Pos, window->Pos + ImVec2(window->Size.x, GetFrameHeight()));
|
||||||
const bool is_explicit_target = g.IO.ConfigDockingWithShift || IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max);
|
const bool is_explicit_target = g.IO.ConfigDockingWithShift || IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max);
|
||||||
|
|
||||||
// Preview docking request and find out split direction/ratio
|
// Preview docking request and find out split direction/ratio
|
||||||
//const bool do_preview = true; // Ignore testing for payload->IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window.
|
//const bool do_preview = true; // Ignore testing for payload->IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window.
|
||||||
const bool do_preview = payload->IsPreview() || payload->IsDelivery();
|
const bool do_preview = payload->IsPreview() || payload->IsDelivery();
|
||||||
if (do_preview && (target_node != NULL || allow_null_target_node))
|
if (do_preview && (node != NULL || allow_null_target_node))
|
||||||
{
|
{
|
||||||
ImGuiDockPreviewData split_inner, split_outer;
|
ImGuiDockPreviewData split_inner, split_outer;
|
||||||
ImGuiDockPreviewData* split_data = &split_inner;
|
ImGuiDockPreviewData* split_data = &split_inner;
|
||||||
if (target_node && (target_node->ParentNode || target_node->IsCentralNode()))
|
if (node && (node->ParentNode || node->IsCentralNode()))
|
||||||
if (ImGuiDockNode* root_node = DockNodeGetRootNode(target_node))
|
if (ImGuiDockNode* root_node = DockNodeGetRootNode(node))
|
||||||
if (DockNodePreviewDockCalc(window, root_node, payload_window, &split_outer, is_explicit_target, true))
|
if (DockNodePreviewDockCalc(window, root_node, payload_window, &split_outer, is_explicit_target, true))
|
||||||
split_data = &split_outer;
|
split_data = &split_outer;
|
||||||
DockNodePreviewDockCalc(window, target_node, payload_window, &split_inner, is_explicit_target, false);
|
DockNodePreviewDockCalc(window, node, payload_window, &split_inner, is_explicit_target, false);
|
||||||
if (split_data == &split_outer)
|
if (split_data == &split_outer)
|
||||||
split_inner.IsDropAllowed = false;
|
split_inner.IsDropAllowed = false;
|
||||||
|
|
||||||
// Draw inner then outer, so that previewed tab (in inner data) will be behind the outer drop boxes
|
// Draw inner then outer, so that previewed tab (in inner data) will be behind the outer drop boxes
|
||||||
DockNodePreviewDockRender(window, target_node, payload_window, &split_inner);
|
DockNodePreviewDockRender(window, node, payload_window, &split_inner);
|
||||||
DockNodePreviewDockRender(window, target_node, payload_window, &split_outer);
|
DockNodePreviewDockRender(window, node, payload_window, &split_outer);
|
||||||
|
|
||||||
// Queue docking request
|
// Queue docking request
|
||||||
if (split_data->IsDropAllowed && payload->IsDelivery())
|
if (split_data->IsDropAllowed && payload->IsDelivery())
|
||||||
|
Loading…
Reference in New Issue
Block a user