Skip to content

Commit b17bfdd

Browse files
rokupsocornut
authored andcommitted
Docking: Add support for split_outer in DockContextCalcDropPosForDocking().
Misc: Add FIXME regarding behavior of some window fields.
1 parent 81e0b18 commit b17bfdd

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

imgui.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -6207,6 +6207,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
62076207

62086208
// Update contents size from last frame for auto-fitting (or use explicit size)
62096209
CalcWindowContentSizes(window, &window->ContentSize, &window->ContentSizeIdeal);
6210+
6211+
// FIXME: These flags are decremented before they are used. This means that in order to have these fields produce their intended behaviors
6212+
// for one frame we must set them to at least 2, which is counter-intuitive. HiddenFramesCannotSkipItems is a more complicated case because
6213+
// it has a single usage before this code block and may be set below before it is finally checked.
62106214
if (window->HiddenFramesCanSkipItems > 0)
62116215
window->HiddenFramesCanSkipItems--;
62126216
if (window->HiddenFramesCannotSkipItems > 0)
@@ -12892,20 +12896,16 @@ void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node)
1289212896
// This is mostly used for automation.
1289312897
bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos)
1289412898
{
12895-
if (split_outer)
12896-
{
12897-
IM_ASSERT(0);
12898-
}
12899-
else
12900-
{
12901-
ImGuiDockPreviewData split_data;
12902-
DockNodePreviewDockSetup(target, target_node, payload, &split_data, false, split_outer);
12903-
if (split_data.DropRectsDraw[split_dir+1].IsInverted())
12904-
return false;
12905-
*out_pos = split_data.DropRectsDraw[split_dir+1].GetCenter();
12906-
return true;
12907-
}
12908-
return false;
12899+
// In DockNodePreviewDockSetup() for a root central node instead of showing both "inner" and "outer" drop rects
12900+
// (which would be functionally identical) we only show the outer one. Reflect this here.
12901+
if (target_node && target_node->ParentNode == NULL && target_node->IsCentralNode() && split_dir != ImGuiDir_None)
12902+
split_outer = true;
12903+
ImGuiDockPreviewData split_data;
12904+
DockNodePreviewDockSetup(target, target_node, payload, &split_data, false, split_outer);
12905+
if (split_data.DropRectsDraw[split_dir+1].IsInverted())
12906+
return false;
12907+
*out_pos = split_data.DropRectsDraw[split_dir+1].GetCenter();
12908+
return true;
1290912909
}
1291012910

1291112911
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)