From ab6c5f3094c78e884a52d26840671f1140a24ab4 Mon Sep 17 00:00:00 2001 From: BDisp Date: Tue, 14 Nov 2023 20:31:19 +0000 Subject: [PATCH] Change _lines field to Lines property. --- Terminal.Gui/Drawing/LineCanvas.cs | 29 +++++++++++++++------------ Terminal.Gui/Views/TabView.cs | 3 +++ UICatalog/Scenarios/TabViewExample.cs | 1 + 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Terminal.Gui/Drawing/LineCanvas.cs b/Terminal.Gui/Drawing/LineCanvas.cs index 3400f07ac..1668c8b85 100644 --- a/Terminal.Gui/Drawing/LineCanvas.cs +++ b/Terminal.Gui/Drawing/LineCanvas.cs @@ -84,7 +84,10 @@ namespace Terminal.Gui { } } - private List _lines = new List (); + /// + /// Get or sets a list of lines. + /// + public List Lines { get; internal set; } = new List (); Dictionary runeResolvers = new Dictionary { {IntersectionRuneType.ULCorner,new ULIntersectionRuneResolver()}, @@ -122,7 +125,7 @@ namespace Terminal.Gui { public void AddLine (Point start, int length, Orientation orientation, LineStyle style, Attribute? attribute = default) { _cachedBounds = Rect.Empty; - _lines.Add (new StraightLine (start, length, orientation, style, attribute)); + Lines.Add (new StraightLine (start, length, orientation, style, attribute)); } /// @@ -132,7 +135,7 @@ namespace Terminal.Gui { public void AddLine (StraightLine line) { _cachedBounds = Rect.Empty; - _lines.Add (line); + Lines.Add (line); } /// @@ -141,9 +144,9 @@ namespace Terminal.Gui { /// public StraightLine RemoveLastLine() { - var l = _lines.LastOrDefault (); + var l = Lines.LastOrDefault (); if(l != null) { - _lines.Remove(l); + Lines.Remove(l); } return l!; @@ -155,7 +158,7 @@ namespace Terminal.Gui { public void Clear () { _cachedBounds = Rect.Empty; - _lines.Clear (); + Lines.Clear (); } /// @@ -177,14 +180,14 @@ namespace Terminal.Gui { public Rect Bounds { get { if (_cachedBounds.IsEmpty) { - if (_lines.Count == 0) { + if (Lines.Count == 0) { return _cachedBounds; } - Rect bounds = _lines [0].Bounds; + Rect bounds = Lines [0].Bounds; - for (var i = 1; i < _lines.Count; i++) { - var line = _lines [i]; + for (var i = 1; i < Lines.Count; i++) { + var line = Lines [i]; var lineBounds = line.Bounds; bounds = Rect.Union (bounds, lineBounds); } @@ -220,7 +223,7 @@ namespace Terminal.Gui { for (int y = inArea.Y; y < inArea.Y + inArea.Height; y++) { for (int x = inArea.X; x < inArea.X + inArea.Width; x++) { - var intersects = _lines + var intersects = Lines .Select (l => l.Intersects (x, y)) .Where (i => i != null) .ToArray (); @@ -250,7 +253,7 @@ namespace Terminal.Gui { for (int y = Bounds.Y; y < Bounds.Y + Bounds.Height; y++) { for (int x = Bounds.X; x < Bounds.X + Bounds.Width; x++) { - var intersects = _lines + var intersects = Lines .Select (l => l.Intersects (x, y)) .Where (i => i != null) .ToArray (); @@ -721,7 +724,7 @@ namespace Terminal.Gui { /// public void Merge (LineCanvas lineCanvas) { - foreach (var line in lineCanvas._lines) { + foreach (var line in lineCanvas.Lines) { AddLine (line); } } diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs index 9d0a6dd23..b869f926e 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -187,9 +187,12 @@ namespace Terminal.Gui { // How much space do we need to leave at the bottom to show the tabs int spaceAtBottom = Math.Max (0, GetTabHeight (false) - 1); int startAtY = Math.Max (0, GetTabHeight (true) - 1); + var lc = new LineCanvas () { Lines = new List (LineCanvas.Lines) }; DrawFrame (new Rect (0, startAtY, Bounds.Width, Math.Max (Bounds.Height - spaceAtBottom - startAtY, 0)), LineStyle.Single); + + LineCanvas.Lines = lc.Lines; } if (Tabs.Any ()) { diff --git a/UICatalog/Scenarios/TabViewExample.cs b/UICatalog/Scenarios/TabViewExample.cs index 190487751..a100a8a72 100644 --- a/UICatalog/Scenarios/TabViewExample.cs +++ b/UICatalog/Scenarios/TabViewExample.cs @@ -57,6 +57,7 @@ namespace UICatalog.Scenarios { Y = 0, Width = 60, Height = 20, + BorderStyle = LineStyle.Single }; tabView.AddTab (new Tab ("Tab1", new Label ("hodor!")), false);