Pārlūkot izejas kodu

LineCanvas - Exclude

Tig 8 mēneši atpakaļ
vecāks
revīzija
3d4658df6c

+ 17 - 8
Terminal.Gui/Drawing/LineCanvas.cs

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

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

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

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

@@ -133,6 +133,7 @@ public partial class View // Drawing APIs
             foreach (View subview in Border.Subviews)
             foreach (View subview in Border.Subviews)
             {
             {
                 subview.SetNeedsDraw ();
                 subview.SetNeedsDraw ();
+                LineCanvas.Exclude (new (subview.FrameToScreen()));
             }
             }
 
 
             Region? saved = Border?.ClipFrame ();
             Region? saved = Border?.ClipFrame ();

+ 4 - 4
Terminal.Gui/Views/Slider.cs

@@ -850,8 +850,8 @@ public class Slider<T> : View, IOrientation
 
 
         if (IsInitialized)
         if (IsInitialized)
         {
         {
-            normalAttr = ColorScheme?.Normal ?? Application.Top.ColorScheme.Normal;
-            setAttr = Style.SetChar.Attribute ?? ColorScheme!.HotNormal;
+            normalAttr = GetNormalColor();
+            setAttr = Style.SetChar.Attribute ?? GetHotNormalColor ();
         }
         }
 
 
         bool isVertical = _config._sliderOrientation == Orientation.Vertical;
         bool isVertical = _config._sliderOrientation == Orientation.Vertical;
@@ -1058,8 +1058,8 @@ public class Slider<T> : View, IOrientation
 
 
         if (IsInitialized)
         if (IsInitialized)
         {
         {
-            normalAttr = Style.LegendAttributes.NormalAttribute ?? ColorScheme?.Normal ?? ColorScheme.Disabled;
-            setAttr = Style.LegendAttributes.SetAttribute ?? ColorScheme?.HotNormal ?? ColorScheme.Normal;
+            normalAttr = Style.LegendAttributes.NormalAttribute ?? GetNormalColor ();
+            setAttr = Style.LegendAttributes.SetAttribute ?? GetHotNormalColor ();
             spaceAttr = Style.LegendAttributes.EmptyAttribute ?? normalAttr;
             spaceAttr = Style.LegendAttributes.EmptyAttribute ?? normalAttr;
         }
         }
 
 

+ 6 - 6
UICatalog/Scenarios/AllViewsTester.cs

@@ -60,7 +60,7 @@ public class AllViewsTester : Scenario
             SelectedItem = 0,
             SelectedItem = 0,
             Source = new ListWrapper<string> (new (_viewClasses.Keys.ToList ())),
             Source = new ListWrapper<string> (new (_viewClasses.Keys.ToList ())),
             BorderStyle = LineStyle.Rounded,
             BorderStyle = LineStyle.Rounded,
-            SuperViewRendersLineCanvas = true
+            //SuperViewRendersLineCanvas = true
         };
         };
 
 
         _classListView.SelectedItemChanged += (s, args) =>
         _classListView.SelectedItemChanged += (s, args) =>
@@ -88,7 +88,7 @@ public class AllViewsTester : Scenario
         _adornmentsEditor = new ()
         _adornmentsEditor = new ()
         {
         {
             Title = "Adornments [_2]",
             Title = "Adornments [_2]",
-            X = Pos.Right (_classListView) - 1,
+            X = Pos.Right (_classListView),
             Y = 0,
             Y = 0,
             Width = Dim.Auto (),
             Width = Dim.Auto (),
             Height = Dim.Auto (),
             Height = Dim.Auto (),
@@ -96,22 +96,22 @@ public class AllViewsTester : Scenario
             BorderStyle = LineStyle.Rounded,
             BorderStyle = LineStyle.Rounded,
             AutoSelectViewToEdit = false,
             AutoSelectViewToEdit = false,
             AutoSelectAdornments = false,
             AutoSelectAdornments = false,
-            SuperViewRendersLineCanvas = true
+            //SuperViewRendersLineCanvas = true
         };
         };
         _adornmentsEditor.ExpanderButton.Orientation = Orientation.Vertical;
         _adornmentsEditor.ExpanderButton.Orientation = Orientation.Vertical;
 
 
         _arrangementEditor = new ()
         _arrangementEditor = new ()
         {
         {
             Title = "Arrangement [_3]",
             Title = "Arrangement [_3]",
-            X = Pos.Right (_classListView) - 1,
-            Y = Pos.Bottom (_adornmentsEditor) -1,
+            X = Pos.Right (_classListView),
+            Y = Pos.Bottom (_adornmentsEditor),
             Width = Dim.Width (_adornmentsEditor),
             Width = Dim.Width (_adornmentsEditor),
             Height = Dim.Fill (),
             Height = Dim.Fill (),
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             BorderStyle = LineStyle.Rounded,
             BorderStyle = LineStyle.Rounded,
             AutoSelectViewToEdit = false,
             AutoSelectViewToEdit = false,
             AutoSelectAdornments = false,
             AutoSelectAdornments = false,
-            SuperViewRendersLineCanvas = true
+            //SuperViewRendersLineCanvas = true
         };
         };
         _arrangementEditor.ExpanderButton.Orientation = Orientation.Vertical;
         _arrangementEditor.ExpanderButton.Orientation = Orientation.Vertical;
 
 

+ 2 - 0
UICatalog/Scenarios/Editors/AdornmentsEditor.cs

@@ -27,6 +27,8 @@ public class AdornmentsEditor : EditorBase
     /// <inheritdoc/>
     /// <inheritdoc/>
     protected override void OnViewToEditChanged ()
     protected override void OnViewToEditChanged ()
     {
     {
+        Enabled = ViewToEdit is Adornment;
+
         if (MarginEditor is { })
         if (MarginEditor is { })
         {
         {
             MarginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
             MarginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;

+ 2 - 0
UICatalog/Scenarios/Editors/ArrangementEditor.cs

@@ -69,6 +69,8 @@ public sealed class ArrangementEditor : EditorBase
 
 
     protected override void OnViewToEditChanged ()
     protected override void OnViewToEditChanged ()
     {
     {
+        Enabled = ViewToEdit is not Adornment;
+
         _arrangementSlider.OptionsChanged -= ArrangementSliderOnOptionsChanged;
         _arrangementSlider.OptionsChanged -= ArrangementSliderOnOptionsChanged;
 
 
         // Set the appropriate options in the slider based on _viewToEdit.Arrangement
         // Set the appropriate options in the slider based on _viewToEdit.Arrangement

+ 1 - 0
UICatalog/Scenarios/Editors/LayoutEditor.cs

@@ -29,6 +29,7 @@ public class LayoutEditor : EditorBase
 
 
     protected override void OnViewToEditChanged ()
     protected override void OnViewToEditChanged ()
     {
     {
+        Enabled = ViewToEdit is not Adornment;
 
 
         if (_xEditor is { })
         if (_xEditor is { })
         {
         {