Docking: Add support for split_outer in DockContextCalcDropPosForDocking().

Misc: Add FIXME regarding behavior of some window fields.
This commit is contained in:
Rokas Kupstys 2021-02-02 17:20:30 +02:00 committed by ocornut
parent 81e0b18e38
commit b17bfdd6f4

View File

@ -6207,6 +6207,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Update contents size from last frame for auto-fitting (or use explicit size) // Update contents size from last frame for auto-fitting (or use explicit size)
CalcWindowContentSizes(window, &window->ContentSize, &window->ContentSizeIdeal); CalcWindowContentSizes(window, &window->ContentSize, &window->ContentSizeIdeal);
// FIXME: These flags are decremented before they are used. This means that in order to have these fields produce their intended behaviors
// for one frame we must set them to at least 2, which is counter-intuitive. HiddenFramesCannotSkipItems is a more complicated case because
// it has a single usage before this code block and may be set below before it is finally checked.
if (window->HiddenFramesCanSkipItems > 0) if (window->HiddenFramesCanSkipItems > 0)
window->HiddenFramesCanSkipItems--; window->HiddenFramesCanSkipItems--;
if (window->HiddenFramesCannotSkipItems > 0) if (window->HiddenFramesCannotSkipItems > 0)
@ -12892,12 +12896,10 @@ void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node)
// This is mostly used for automation. // This is mostly used for automation.
bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos) bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos)
{ {
if (split_outer) // In DockNodePreviewDockSetup() for a root central node instead of showing both "inner" and "outer" drop rects
{ // (which would be functionally identical) we only show the outer one. Reflect this here.
IM_ASSERT(0); if (target_node && target_node->ParentNode == NULL && target_node->IsCentralNode() && split_dir != ImGuiDir_None)
} split_outer = true;
else
{
ImGuiDockPreviewData split_data; ImGuiDockPreviewData split_data;
DockNodePreviewDockSetup(target, target_node, payload, &split_data, false, split_outer); DockNodePreviewDockSetup(target, target_node, payload, &split_data, false, split_outer);
if (split_data.DropRectsDraw[split_dir+1].IsInverted()) if (split_data.DropRectsDraw[split_dir+1].IsInverted())
@ -12905,8 +12907,6 @@ bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode*
*out_pos = split_data.DropRectsDraw[split_dir+1].GetCenter(); *out_pos = split_data.DropRectsDraw[split_dir+1].GetCenter();
return true; return true;
} }
return false;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Docking: ImGuiDockNode // Docking: ImGuiDockNode