From 928511e44a4ac5b587d38e6be8a39ed6c53c6204 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 5 Jan 2016 11:19:17 +0000 Subject: [PATCH] Fixed checks for dropping before/after groups. --- DarkUI/Win32/DockContentDragFilter.cs | 16 ++++++++-------- todo.txt | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/DarkUI/Win32/DockContentDragFilter.cs b/DarkUI/Win32/DockContentDragFilter.cs index daf3a7d..c600c06 100644 --- a/DarkUI/Win32/DockContentDragFilter.cs +++ b/DarkUI/Win32/DockContentDragFilter.cs @@ -116,7 +116,7 @@ namespace DarkUI.Win32 _groupDropAreas.Add(group, collection); } } - // If the region is NOT visible then build drop areas for the region itself. + // If the region is NOT visible then build the drop area for the region itself. else { var area = new DockDropArea(_dockPanel, region); @@ -184,23 +184,22 @@ namespace DarkUI.Win32 var groupHasOtherContent = false; if (collection.DropArea.DockGroup == _dragContent.DockGroup) - { sameGroup = true; - if (collection.DropArea.DockGroup.ContentCount > 1) - groupHasOtherContent = true; - } - if (collection.DropArea.DockGroup.DockRegion == _dragContent.DockRegion) - { sameRegion = true; - } + if (_dragContent.DockGroup.ContentCount > 1) + groupHasOtherContent = true; + + // If we're hovering over the group itself, only allow inserting before/after if multiple content is tabbed. if (!sameGroup || groupHasOtherContent) { var skipBefore = false; var skipAfter = false; + // Inserting before/after other content might cause the content to be dropped on to its own location. + // Check if the group above/below the hovered group contains our drag content. if (sameRegion && !groupHasOtherContent) { if (collection.InsertBeforeArea.DockGroup.Order == _dragContent.DockGroup.Order + 1) @@ -233,6 +232,7 @@ namespace DarkUI.Win32 } } + // Don't allow content to be dragged on to itself if (!sameGroup) { if (collection.DropArea.DropArea.Contains(location)) diff --git a/todo.txt b/todo.txt index a0df657..92b7c40 100644 --- a/todo.txt +++ b/todo.txt @@ -27,4 +27,5 @@ Dock panel -- stop dragging tabs instantly going to the end of the row -- stop differently sized toolwindow tabs from vibrating when dragging -- remove 1 pixel left padding from bottom region --- add 1 pixel border between groups in bottom region \ No newline at end of file +-- add 1 pixel border between groups in bottom region +-- allow dragging above/below adjacent groups if multiple content exists within group \ No newline at end of file