Docking: Fix bug added in 71a58261 + Misc docking omments
diff --git a/imgui.cpp b/imgui.cpp
index ab1c4ab..92af81d 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -3398,7 +3398,7 @@
// (after we're done with all our widgets, so e.g. clicking on docking tab-bar which have set HoveredId already and not get us here!)
if (g.IO.MouseClicked[0])
{
- ImGuiWindow* root_window = g.HoveredWindow->RootWindowDockStop;
+ ImGuiWindow* root_window = g.HoveredWindow ? g.HoveredWindow->RootWindowDockStop : NULL;
if (root_window != NULL)
{
StartMouseMovingWindow(g.HoveredWindow);
@@ -13006,6 +13006,7 @@
}
// host_node may be NULL if the window doesn't have a DockNode already.
+// FIXME-DOCK: This is misnamed since it's also doing the filtering.
static void ImGui::DockNodePreviewDockCalc(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, ImGuiDockPreviewData* data, bool is_explicit_target, bool is_outer_docking)
{
ImGuiContext& g = *GImGui;
@@ -14253,7 +14254,7 @@
return;
}
- // Position window
+ // Position/Size window
SetNextWindowPos(node->Pos);
SetNextWindowSize(node->Size);
g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos()
@@ -14346,7 +14347,8 @@
const bool do_preview = payload->IsPreview() || payload->IsDelivery();
if (do_preview && (node != NULL || allow_null_target_node))
{
- ImGuiDockPreviewData split_inner, split_outer;
+ ImGuiDockPreviewData split_inner;
+ ImGuiDockPreviewData split_outer;
ImGuiDockPreviewData* split_data = &split_inner;
if (node && (node->ParentNode || node->IsCentralNode()))
if (ImGuiDockNode* root_node = DockNodeGetRootNode(node))
diff --git a/imgui.h b/imgui.h
index a1f50e0..3766ce5 100644
--- a/imgui.h
+++ b/imgui.h
@@ -1609,8 +1609,13 @@
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
};
-// [BETA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
-// Provide hints to the platform back-end via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.) and OS level parent/child relationships.
+// [ALPHA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
+// Important: the content of this class is still highly WIP and likely to change and be refactored
+// before we stabilize Docking features. Please be mindful if using this.
+// Provide hints:
+// - To the platform back-end via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.)
+// - To the platform back-end for OS level parent/child relationships of viewport.
+// - To the docking system for various options and filtering.
struct ImGuiWindowClass
{
ImGuiID ClassId; // User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
diff --git a/imgui_internal.h b/imgui_internal.h
index 4080019..eeaefb7 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1912,6 +1912,7 @@
IMGUI_API void DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
IMGUI_API bool DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos);
inline ImGuiDockNode* DockNodeGetRootNode(ImGuiDockNode* node) { while (node->ParentNode) node = node->ParentNode; return node; }
+ inline ImGuiDockNode* GetWindowDockNode() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DockNode; }
IMGUI_API bool GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window);
IMGUI_API void BeginDocked(ImGuiWindow* window, bool* p_open);
IMGUI_API void BeginDockableDragDropSource(ImGuiWindow* window);