فهرست منبع

Mostly got mouse working

Tigger Kindel 2 سال پیش
والد
کامیت
fdf1e0d3b7
4فایلهای تغییر یافته به همراه33 افزوده شده و 7 حذف شده
  1. 11 1
      Terminal.Gui/Core/Application.cs
  2. 2 6
      Terminal.Gui/Core/Frame.cs
  3. 1 0
      Terminal.Gui/Core/Responder.cs
  4. 19 0
      Terminal.Gui/Core/View.cs

+ 11 - 1
Terminal.Gui/Core/Application.cs

@@ -671,6 +671,15 @@ namespace Terminal.Gui {
 			return start;
 		}
 
+		/// <summary>
+		/// Finds the deepest view at the specified coordinates.
+		/// </summary>
+		/// <param name="start"></param>
+		/// <param name="x"></param>
+		/// <param name="y"></param>
+		/// <param name="resx"></param>
+		/// <param name="resy"></param>
+		/// <returns></returns>
 		static View FindDeepestView (View start, int x, int y, out int resx, out int resy)
 		{
 			var startFrame = start.Frame;
@@ -681,6 +690,7 @@ namespace Terminal.Gui {
 				return null;
 			}
 
+			startFrame = start.Padding.Thickness.GetInnerRect (start.BorderFrame.Thickness.GetInnerRect (start.Margin.Thickness.GetInnerRect (startFrame)));
 			if (start.InternalSubviews != null) {
 				int count = start.InternalSubviews.Count;
 				if (count > 0) {
@@ -810,7 +820,7 @@ namespace Terminal.Gui {
 			if (mouseGrabView != null) {
 				view ??= mouseGrabView;
 
-				var newxy = mouseGrabView.ScreenToView (me.X, me.Y);
+				var newxy = mouseGrabView.ScreenToBounds (me.X, me.Y);
 				var nme = new MouseEvent () {
 					X = newxy.X,
 					Y = newxy.Y,

+ 2 - 6
Terminal.Gui/Core/Frame.cs

@@ -21,7 +21,7 @@ namespace Terminal.Gui {
 		internal override void CreateFrames (){ /* Do nothing - Frames do not have Frames */ }
 
 		/// <summary>
-		/// The Parent of this Frame (the View that this Frame surrounds).
+		/// The Parent of this Frame (the View this Frame surrounds).
 		/// </summary>
 		public View Parent { get; set; }
 
@@ -89,10 +89,6 @@ namespace Terminal.Gui {
 		{
 			if (Thickness == Thickness.Empty) return;
 
-			//OnDrawContent (bounds);
-			//OnDrawSubViews (bounds);
-			//OnDrawContentComplete (bounds);
-
 			if (ColorScheme != null) {
 				Driver.SetAttribute (ColorScheme.Normal);
 			}
@@ -102,7 +98,7 @@ namespace Terminal.Gui {
 			var screenBounds = ViewToScreen (Frame);
 			Thickness.Draw (screenBounds, (string)(Data != null ? Data : string.Empty));
 
-			//OnDrawContent (bounds); 
+			//OnDrawSubviews (bounds); 
 
 			if (BorderStyle != BorderStyle.None) {
 				var lc = new LineCanvas ();

+ 1 - 0
Terminal.Gui/Core/Responder.cs

@@ -237,6 +237,7 @@ namespace Terminal.Gui {
 		/// </summary>
 		public virtual void OnVisibleChanged () { }
 
+		// TODO: v2 - nuke this
 		/// <summary>
 		/// Utilty function to determine <paramref name="method"/> is overridden in the <paramref name="subclass"/>.
 		/// </summary>

+ 19 - 0
Terminal.Gui/Core/View.cs

@@ -1331,6 +1331,23 @@ namespace Terminal.Gui {
 			}
 		}
 
+		/// <summary>
+		/// Converts a point from screen-relative coordinates to bounds-relative coordinates.
+		/// </summary>
+		/// <returns>The mapped point.</returns>
+		/// <param name="x">X screen-coordinate point.</param>
+		/// <param name="y">Y screen-coordinate point.</param>
+		public Point ScreenToBounds (int x, int y)
+		{
+			if (SuperView == null) {
+				var inner = Padding.Thickness.GetInnerRect (BorderFrame.Thickness.GetInnerRect (Margin.Thickness.GetInnerRect (Frame)));
+				return new Point (x - inner.X, y - inner.Y);
+			} else {
+				var parent = SuperView.ScreenToView (x, y);
+				return new Point (parent.X - frame.X, parent.Y - frame.Y);
+			}
+		}
+
 		/// <summary>
 		/// Converts a view-relative location to a screen-relative location (col,row). The output is optionally clamped to the screen dimensions.
 		/// </summary>
@@ -2904,6 +2921,7 @@ namespace Terminal.Gui {
 			}
 		}
 
+		// TODO: v2 Nuke teh Border property (rename BorderFrame to Border)
 		Border border;
 
 		/// <inheritdoc/>
@@ -2924,6 +2942,7 @@ namespace Terminal.Gui {
 			}
 		}
 
+		// TODO: v2 nuke This
 		/// <summary>
 		/// </summary>
 		public virtual bool IgnoreBorderPropertyOnRedraw { get; set; }