Docking: Fix bug added in 71a58261 + Misc docking omments

This commit is contained in:
omar 2019-11-28 17:34:26 +01:00
parent 28dd8d7efd
commit a1e4af62d3
3 changed files with 13 additions and 5 deletions

View File

@ -3398,7 +3398,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
// (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!) // (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]) if (g.IO.MouseClicked[0])
{ {
ImGuiWindow* root_window = g.HoveredWindow->RootWindowDockStop; ImGuiWindow* root_window = g.HoveredWindow ? g.HoveredWindow->RootWindowDockStop : NULL;
if (root_window != NULL) if (root_window != NULL)
{ {
StartMouseMovingWindow(g.HoveredWindow); StartMouseMovingWindow(g.HoveredWindow);
@ -13006,6 +13006,7 @@ bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir
} }
// host_node may be NULL if the window doesn't have a DockNode already. // 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) 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; ImGuiContext& g = *GImGui;
@ -14253,7 +14254,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
return; return;
} }
// Position window // Position/Size window
SetNextWindowPos(node->Pos); SetNextWindowPos(node->Pos);
SetNextWindowSize(node->Size); SetNextWindowSize(node->Size);
g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos() g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos()
@ -14346,7 +14347,8 @@ void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window)
const bool do_preview = payload->IsPreview() || payload->IsDelivery(); const bool do_preview = payload->IsPreview() || payload->IsDelivery();
if (do_preview && (node != NULL || allow_null_target_node)) 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; ImGuiDockPreviewData* split_data = &split_inner;
if (node && (node->ParentNode || node->IsCentralNode())) if (node && (node->ParentNode || node->IsCentralNode()))
if (ImGuiDockNode* root_node = DockNodeGetRootNode(node)) if (ImGuiDockNode* root_node = DockNodeGetRootNode(node))

View File

@ -1609,8 +1609,13 @@ struct ImGuiSizeCallbackData
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing. 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. // [ALPHA] 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. // 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 struct ImGuiWindowClass
{ {
ImGuiID ClassId; // User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others. ImGuiID ClassId; // User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.

View File

@ -1912,6 +1912,7 @@ namespace ImGui
IMGUI_API void DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node); 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); 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* 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 bool GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window);
IMGUI_API void BeginDocked(ImGuiWindow* window, bool* p_open); IMGUI_API void BeginDocked(ImGuiWindow* window, bool* p_open);
IMGUI_API void BeginDockableDragDropSource(ImGuiWindow* window); IMGUI_API void BeginDockableDragDropSource(ImGuiWindow* window);