aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-04-19 17:25:14 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-04-19 17:25:14 +0200
commitd7bd85c20b11c4a3eb53b708524457a18e7ac025 (patch)
tree2d5647bfdd50e2211c3e1bc9a31189853dcc3f4f
parentffb850e567132718def019b64494883dc9f30511 (diff)
dock windows parent.parent test
-rw-r--r--Crow/src/Widgets/DockStack.cs1
-rw-r--r--Crow/src/Widgets/DockWindow.cs67
2 files changed, 54 insertions, 14 deletions
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 ();