mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Docking: reinstate io.ConfigDockingWithShift option. (#4643)
This more or less reverts commit 3ed07a8f0b.
			
			
This commit is contained in:
		
							
								
								
									
										11
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -1124,6 +1124,7 @@ ImGuiIO::ImGuiIO()
 | 
			
		||||
 | 
			
		||||
    // Docking options (when ImGuiConfigFlags_DockingEnable is set)
 | 
			
		||||
    ConfigDockingNoSplit = false;
 | 
			
		||||
    ConfigDockingWithShift = false;
 | 
			
		||||
    ConfigDockingAlwaysTabBar = false;
 | 
			
		||||
    ConfigDockingTransparentPayload = false;
 | 
			
		||||
 | 
			
		||||
@@ -6836,7 +6837,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
 | 
			
		||||
        {
 | 
			
		||||
            // Docking: Dragging a dockable window (or any of its child) turns it into a drag and drop source.
 | 
			
		||||
            // We need to do this _before_ we overwrite window->DC.LastItemId below because BeginDockableDragDropSource() also overwrites it.
 | 
			
		||||
            if (g.MovingWindow == window && g.IO.KeyShift == false)
 | 
			
		||||
            if ((g.MovingWindow == window) && (g.IO.ConfigDockingWithShift == g.IO.KeyShift))
 | 
			
		||||
                if ((window->RootWindowDockTree->Flags & ImGuiWindowFlags_NoDocking) == 0)
 | 
			
		||||
                    BeginDockableDragDropSource(window);
 | 
			
		||||
 | 
			
		||||
@@ -14781,9 +14782,9 @@ static void ImGui::DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockN
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    // We only allow and preview docking when hovering over a drop rect or over the title bar
 | 
			
		||||
    // When docking without holding Shift, we only allow and preview docking when hovering over a drop rect or over the title bar
 | 
			
		||||
    data->IsDropAllowed = (data->SplitDir != ImGuiDir_None) || (data->IsCenterAvailable);
 | 
			
		||||
    if (!is_explicit_target && !data->IsSplitDirExplicit)
 | 
			
		||||
    if (!is_explicit_target && !data->IsSplitDirExplicit && !g.IO.ConfigDockingWithShift)
 | 
			
		||||
        data->IsDropAllowed = false;
 | 
			
		||||
 | 
			
		||||
    // Calculate split area
 | 
			
		||||
@@ -16078,7 +16079,7 @@ void ImGui::BeginDockableDragDropSource(ImGuiWindow* window)
 | 
			
		||||
    g.LastItemData.ID = window->MoveId;
 | 
			
		||||
    window = window->RootWindowDockTree;
 | 
			
		||||
    IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);
 | 
			
		||||
    bool is_drag_docking = ImRect(0, 0, window->SizeFull.x, GetFrameHeight()).Contains(g.ActiveIdClickOffset); // FIXME-DOCKING: Need to make this stateful and explicit
 | 
			
		||||
    bool is_drag_docking = (g.IO.ConfigDockingWithShift) || ImRect(0, 0, window->SizeFull.x, GetFrameHeight()).Contains(g.ActiveIdClickOffset); // FIXME-DOCKING: Need to make this stateful and explicit
 | 
			
		||||
    if (is_drag_docking && BeginDragDropSource(ImGuiDragDropFlags_SourceNoPreviewTooltip | ImGuiDragDropFlags_SourceNoHoldToOpenOthers | ImGuiDragDropFlags_SourceAutoExpirePayload))
 | 
			
		||||
    {
 | 
			
		||||
        SetDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, &window, sizeof(window));
 | 
			
		||||
@@ -16139,7 +16140,7 @@ void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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 = 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
 | 
			
		||||
        //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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user