浏览代码

Removed findAdornments param and made FindDeepestView internal

Tig Kindel 1 年之前
父节点
当前提交
bcccce4394
共有 3 个文件被更改,包括 29 次插入31 次删除
  1. 1 1
      Terminal.Gui/Application.cs
  2. 26 28
      Terminal.Gui/View/Layout/ViewLayout.cs
  3. 2 2
      UnitTests/View/FindDeepestViewTests.cs

+ 1 - 1
Terminal.Gui/Application.cs

@@ -1377,7 +1377,7 @@ public static partial class Application
         }
         }
 
 
         // TODO: In PR #3273, FindDeepestView will return adornments. Update logic below to fix adornment mouse handling
         // TODO: In PR #3273, FindDeepestView will return adornments. Update logic below to fix adornment mouse handling
-        var view = View.FindDeepestView (Current, a.MouseEvent.X, a.MouseEvent.Y, true);
+        var view = View.FindDeepestView (Current, a.MouseEvent.X, a.MouseEvent.Y);
 
 
         if (view is { WantContinuousButtonPressed: true })
         if (view is { WantContinuousButtonPressed: true })
         {
         {

+ 26 - 28
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -553,7 +553,6 @@ public partial class View
     /// <param name="start">The superview where to look for.</param>
     /// <param name="start">The superview where to look for.</param>
     /// <param name="x">The column location in the superview.</param>
     /// <param name="x">The column location in the superview.</param>
     /// <param name="y">The row location in the superview.</param>
     /// <param name="y">The row location in the superview.</param>
-    /// <param name="findAdornments">TODO: Remove this in PR #3273</param>
     /// <returns>
     /// <returns>
     ///     The view that was found at the <paramref name="x"/> and <paramref name="y"/> coordinates.
     ///     The view that was found at the <paramref name="x"/> and <paramref name="y"/> coordinates.
     ///     <see langword="null"/> if no view was found.
     ///     <see langword="null"/> if no view was found.
@@ -561,7 +560,7 @@ public partial class View
 
 
     // CONCURRENCY: This method is not thread-safe.
     // CONCURRENCY: This method is not thread-safe.
     // Undefined behavior and likely program crashes are exposed by unsynchronized access to InternalSubviews.
     // Undefined behavior and likely program crashes are exposed by unsynchronized access to InternalSubviews.
-    public static View? FindDeepestView (View? start, int x, int y, bool findAdornments = true)
+    public static View? FindDeepestView (View? start, int x, int y)
     {
     {
         if (start is null || !start.Visible)
         if (start is null || !start.Visible)
         {
         {
@@ -573,34 +572,33 @@ public partial class View
             return null;
             return null;
         }
         }
 
 
-        if (findAdornments)
+        if (start.Margin.Thickness.Contains (start.Frame, x, y))
         {
         {
-            if (start.Margin.Thickness.Contains (start.Frame, x, y))
-            {
-                return start.Margin;
-            }
+            return start.Margin;
+        }
 
 
-            if (start.Border.Thickness.Contains (
-                                                 start.Border.Frame with { 
-                                                     X = start.Frame.X + start.Border.Frame.X,
-                                                     Y = start.Frame.Y + start.Border.Frame.Y },
-                                                 x,
-                                                 y))
-            {
-                return start.Border;
-            }
+        if (start.Border.Thickness.Contains (
+                                             start.Border.Frame with
+                                             {
+                                                 X = start.Frame.X + start.Border.Frame.X,
+                                                 Y = start.Frame.Y + start.Border.Frame.Y
+                                             },
+                                             x,
+                                             y))
+        {
+            return start.Border;
+        }
 
 
-            if (start.Padding.Thickness.Contains (
-                                                  start.Padding.Frame with
-                                                  {
-                                                      X = start.Frame.X + start.Padding.Frame.X,
-                                                      Y = start.Frame.Y + start.Padding.Frame.Y
-                                                  },
-                                                  x,
-                                                  y))
-            {
-                return start.Padding;
-            }
+        if (start.Padding.Thickness.Contains (
+                                              start.Padding.Frame with
+                                              {
+                                                  X = start.Frame.X + start.Padding.Frame.X,
+                                                  Y = start.Frame.Y + start.Padding.Frame.Y
+                                              },
+                                              x,
+                                              y))
+        {
+            return start.Padding;
         }
         }
 
 
         if (start.InternalSubviews is { Count: > 0 })
         if (start.InternalSubviews is { Count: > 0 })
@@ -615,7 +613,7 @@ public partial class View
 
 
                 if (v.Visible && v.Frame.Contains (rx, ry))
                 if (v.Visible && v.Frame.Contains (rx, ry))
                 {
                 {
-                    View? deep = FindDeepestView (v, rx, ry, findAdornments);
+                    View? deep = FindDeepestView (v, rx, ry);
 
 
                     return deep ?? v;
                     return deep ?? v;
                 }
                 }

+ 2 - 2
UnitTests/View/FindDeepestViewTests.cs

@@ -172,7 +172,7 @@ public class FindDeepestViewTests (ITestOutputHelper output)
         };
         };
         start.Add (subview);
         start.Add (subview);
 
 
-        var found = View.FindDeepestView (start, testX, testY, true);
+        var found = View.FindDeepestView (start, testX, testY);
 
 
         Assert.Equal (expectedSubViewFound, found == subview);
         Assert.Equal (expectedSubViewFound, found == subview);
     }
     }
@@ -205,7 +205,7 @@ public class FindDeepestViewTests (ITestOutputHelper output)
         };
         };
         start.Add (subview);
         start.Add (subview);
 
 
-        var found = View.FindDeepestView (start, testX, testY, true);
+        var found = View.FindDeepestView (start, testX, testY);
         Assert.Equal(expectedAdornmentType, found.GetType());
         Assert.Equal(expectedAdornmentType, found.GetType());
     }
     }