From: Jean-Philippe Bruyère Date: Mon, 19 Apr 2021 15:25:14 +0000 (+0200) Subject: dock windows parent.parent test X-Git-Tag: v0.9.5-beta~21 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=d7bd85c20b11c4a3eb53b708524457a18e7ac025;p=jp%2Fcrow.git dock windows parent.parent test --- diff --git a/Crow/src/Widgets/DockStack.cs b/Crow/src/Widgets/DockStack.cs index df1cc6f1..d72270c7 100644 --- a/Crow/src/Widgets/DockStack.cs +++ b/Crow/src/Widgets/DockStack.cs @@ -146,6 +146,7 @@ namespace Crow } } } + } if (curDockPos != dw.DockingPosition) diff --git a/Crow/src/Widgets/DockWindow.cs b/Crow/src/Widgets/DockWindow.cs index 096ef0e1..af47ce3a 100644 --- a/Crow/src/Widgets/DockWindow.cs +++ b/Crow/src/Widgets/DockWindow.cs @@ -70,7 +70,17 @@ namespace Crow } return Slot.ContainsOrIsEqual(m); }*/ - + + bool tryGetTargetDockStack (DockWindow dw, out DockStack ds) { + if (dw.Parent is DockStack dwp) + ds = dwp; + else if (dw.LogicalParent is TabView) + ds = dw.LogicalParent.Parent as DockStack; + else + ds = null; + return ds != null; + } + bool dockParentParent = false; public override void onDrag (object sender, MouseMoveEventArgs e) { if (isDocked) @@ -84,6 +94,8 @@ namespace Crow return; Alignment dockingPosSave = DockingPosition; + bool dockParentParentSave = dockParentParent; + dockParentParent = false; Rectangle r = default; Console.WriteLine ($"onDrag target={IFace.DragAndDropOperation.DropTarget}"); @@ -93,23 +105,45 @@ namespace Crow r = ds.ScreenCoordinates (ds.LastPaintedSlot); }else if (IFace.DragAndDropOperation.DropTarget is DockWindow dw && dw.IsDocked == true) { Point m = dw.ScreenPointToLocal (e.Position); - Rectangle dwCb = dw.ClientRectangle; - dwCb.Inflate (dwCb.Width / -3, dwCb.Height / -3); + r = dw.ClientRectangle; + Rectangle dwCb = r; + dwCb.Inflate (dwCb.Width / -5, dwCb.Height / -5); if (dwCb.ContainsOrIsEqual(m)) { DockingPosition = Alignment.Center; r = dw.ScreenCoordinates (dw.LastPaintedSlot); - Console.WriteLine ("center"); - } else if (dw.Parent is DockStack dsp) { - dsp.onDragMouseMove (this, e); - if (dsp.focusedChild == null) - r = dsp.ScreenCoordinates (dsp.LastPaintedSlot); - else - r = dsp.focusedChild.ScreenCoordinates (dsp.focusedChild.LastPaintedSlot); + } else { + dwCb = r; + dwCb.Inflate (-4,-4); + + if (tryGetTargetDockStack (dw, out DockStack targetStack)) { + Console.WriteLine ($"exterior: {!dwCb.ContainsOrIsEqual (m)} targetStack.Parent: {targetStack.Parent.GetType()}"); + if (dwCb.ContainsOrIsEqual (m)) { + r = dw.ScreenCoordinates (dw.LastPaintedSlot); + } else if (targetStack.Parent is DockStack) { + dockParentParent = true; + targetStack = targetStack.Parent as DockStack; + r = targetStack.ScreenCoordinates (targetStack.LastPaintedSlot); + } else + r = dw.ScreenCoordinates (dw.LastPaintedSlot); + + targetStack.onDragMouseMove (this, e); + } else + System.Diagnostics.Debugger.Break (); + + /*if (dw.Parent is DockStack dsp) { + if (dsp.focusedChild == null) + r = dsp.ScreenCoordinates (dsp.LastPaintedSlot); + else + r = dsp.focusedChild.ScreenCoordinates (dsp.focusedChild.LastPaintedSlot); + } else if (dw.LogicalParent is TabView tv && dw.LogicalParent.Parent is DockStack dspp) { + dspp.onDragMouseMove (this, e); + r = tv.ScreenCoordinates (tv.LastPaintedSlot); + }*/ } }else DockingPosition = Alignment.Undefined; - if (DockingPosition != dockingPosSave) { + if (DockingPosition != dockingPosSave || dockParentParent != dockParentParentSave) { if (DockingPosition == Alignment.Undefined) { IFace.ClearDragImage (); return; @@ -182,9 +216,14 @@ namespace Crow else if (e.DropTarget is DockWindow dw) { if (DockingPosition == Alignment.Center) Dock (dw); - else - Dock (dw.Parent as DockStack); - } + else if (tryGetTargetDockStack (dw, out DockStack targetStack)) { + if (dockParentParent) + targetStack = targetStack.Parent as DockStack; + Dock (targetStack); + }else + System.Diagnostics.Debugger.Break (); + }else + System.Diagnostics.Debugger.Break (); } base.onDrop (sender, e); IFace.ClearDragImage ();