2
0
Эх сурвалжийг харах

Added Exclusions to LineCanvas

Tig 8 сар өмнө
parent
commit
45ce64ab86

+ 12 - 3
Terminal.Gui/Drawing/LineCanvas.cs

@@ -158,8 +158,14 @@ public class LineCanvas : IDisposable
     {
         _cachedViewport = Rectangle.Empty;
         _lines.Clear ();
+        Exclusions.Clear ();
     }
 
+    /// <summary>
+    ///     Gets the list of locations that will be excluded from <see cref="GetCellMap"/> and <see cref="GetMap()"/>.
+    /// </summary>
+    public List<Point> Exclusions { get; } = new List<Point> ();
+
     /// <summary>
     ///     Clears any cached states from the canvas Call this method if you make changes to lines that have already been
     ///     added.
@@ -188,9 +194,10 @@ public class LineCanvas : IDisposable
 
                 Cell? cell = GetCellForIntersects (Application.Driver, intersects);
 
-                if (cell is { })
+                Point location = new (x, y);
+                if (cell is { } && !Exclusions.Contains (location))
                 {
-                    map.Add (new (x, y), cell);
+                    map.Add (location, cell);
                 }
             }
         }
@@ -223,7 +230,8 @@ public class LineCanvas : IDisposable
 
                 Rune? rune = GetRuneForIntersects (Application.Driver, intersects);
 
-                if (rune is { })
+                Point location = new (x, y);
+                if (rune is { } && !Exclusions.Contains (location))
                 {
                     map.Add (new (x, y), rune.Value);
                 }
@@ -249,6 +257,7 @@ public class LineCanvas : IDisposable
         {
             AddLine (line);
         }
+        Exclusions.AddRange (lineCanvas.Exclusions);
     }
 
     /// <summary>Removes the last line added to the canvas</summary>

+ 1 - 0
Terminal.Gui/View/Adornment/Border.cs

@@ -106,6 +106,7 @@ public class Border : Adornment
         {
             DrawIndicator.AdvanceAnimation (false);
             DrawIndicator.Render ();
+            Parent?.LineCanvas.Exclusions.Add (DrawIndicator.ViewportToScreen (new Point (0,0)));
         }
     }
 

+ 1 - 1
Terminal.Gui/View/View.Drawing.cs

@@ -92,7 +92,7 @@ public partial class View // Drawing APIs
 
             // Re-draw the border and padding subviews
             // HACK: This is a hack to ensure that the border and padding subviews are drawn after the line canvas.
-            //DoDrawBorderAndPaddingSubViews ();
+            DoDrawBorderAndPaddingSubViews ();
 
             // Advance the diagnostics draw indicator
             Border?.AdvanceDrawIndicator ();

+ 14 - 14
Terminal.Gui/Views/ListView.cs

@@ -918,20 +918,20 @@ public class ListView : View, IDesignable
     /// <summary>This event is raised when the user Double Clicks on an item or presses ENTER to open the selected item.</summary>
     public event EventHandler<ListViewItemEventArgs> OpenSelectedItem;
 
-    /// <inheritdoc/>
-    public override Point? PositionCursor ()
-    {
-        int x = 0;
-        int y = _selected - Viewport.Y;
-        if (!_allowsMarking)
-        {
-            x = Viewport.Width - 1;
-        }
-
-        Move (x, y);
-
-        return null; // Don't show the cursor
-    }
+    ///// <inheritdoc/>
+    //public override Point? PositionCursor ()
+    //{
+    //    int x = 0;
+    //    int y = _selected - Viewport.Y;
+    //    if (!_allowsMarking)
+    //    {
+    //        x = Viewport.Width - 1;
+    //    }
+
+    //    Move (x, y);
+
+    //    return null; // Don't show the cursor
+    //}
 
     /// <summary>This event is invoked when this <see cref="ListView"/> is being drawn before rendering.</summary>
     public event EventHandler<ListViewRowEventArgs> RowRender;

+ 4 - 1
UnitTests/View/Adornment/BorderTests.cs

@@ -904,7 +904,8 @@ public class BorderTests (ITestOutputHelper output)
             Title = "A",
             Width = 11,
             Height = 7,
-            BorderStyle = LineStyle.Single
+            CanFocus = true,
+            BorderStyle = LineStyle.Single,
         };
 
         View view1 = new View ()
@@ -915,6 +916,7 @@ public class BorderTests (ITestOutputHelper output)
             Height = 4,
             X = -1,
             Y = -1,
+            CanFocus = true,
             BorderStyle = LineStyle.Double,
             SuperViewRendersLineCanvas = superViewRendersLineCanvas
         };
@@ -927,6 +929,7 @@ public class BorderTests (ITestOutputHelper output)
             Height = 4,
             X = 4,
             Y = 2,
+            CanFocus = true,
             BorderStyle = LineStyle.Dotted,
             SuperViewRendersLineCanvas = superViewRendersLineCanvas
         };