ソースを参照

Fixes #386. Window can now be dragged inside another Window.

BDisp 5 年 前
コミット
c90d1bd91e
2 ファイル変更19 行追加8 行削除
  1. 17 6
      Terminal.Gui/Core/Toplevel.cs
  2. 2 2
      Terminal.Gui/Core/Window.cs

+ 17 - 6
Terminal.Gui/Core/Toplevel.cs

@@ -258,17 +258,28 @@ namespace Terminal.Gui {
 			nx = Math.Max (x, 0);
 			nx = nx + top.Frame.Width > Driver.Cols ? Math.Max (Driver.Cols - top.Frame.Width, 0) : nx;
 			bool m, s;
-			if (SuperView == null || SuperView.GetType () != typeof (Toplevel))
+			if (SuperView == null || SuperView.GetType () != typeof (Toplevel)) {
 				m = Application.Top.MenuBar != null;
-			else
+			} else {
 				m = ((Toplevel)SuperView).MenuBar != null;
-			int l = m ? 1 : 0;
+			}
+			int l;
+			if (SuperView == null || SuperView is Toplevel) {
+				l = m ? 1 : 0;
+			} else {
+				l = 0;
+			}
 			ny = Math.Max (y, l);
-			if (SuperView == null || SuperView.GetType () != typeof (Toplevel))
+			if (SuperView == null || SuperView.GetType () != typeof (Toplevel)) {
 				s = Application.Top.StatusBar != null;
-			else
+			} else {
 				s = ((Toplevel)SuperView).StatusBar != null;
-			l = s ? Driver.Rows - 1 : Driver.Rows;
+			}
+			if (SuperView == null || SuperView is Toplevel) {
+				l = s ? Driver.Rows - 1 : Driver.Rows;
+			} else {
+				l = s ? SuperView.Frame.Height - 1 : SuperView.Frame.Height;
+			}
 			ny = Math.Min (ny, l);
 			ny = ny + top.Frame.Height > l ? Math.Max (l - top.Frame.Height, m ? 1 : 0) : ny;
 		}

+ 2 - 2
Terminal.Gui/Core/Window.cs

@@ -217,8 +217,8 @@ namespace Terminal.Gui {
 					} else {
 						SuperView.SetNeedsDisplay (Frame);
 					}
-					EnsureVisibleBounds (this, mouseEvent.X + mouseEvent.OfX - start.X,
-						mouseEvent.Y + mouseEvent.OfY, out nx, out ny);
+					EnsureVisibleBounds (this, mouseEvent.X + (SuperView == null ? mouseEvent.OfX - start.X : Frame.X - start.X),
+						mouseEvent.Y + (SuperView == null ? mouseEvent.OfY : Frame.Y), out nx, out ny);
 
 					dragPosition = new Point (nx, ny);
 					Frame = new Rect (nx, ny, Frame.Width, Frame.Height);