diff --git a/Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs b/Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs index d1dec203c..2c2dc89ed 100644 --- a/Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs +++ b/Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs @@ -129,7 +129,7 @@ public class CollectionNavigatorTester : Scenario _items = new (_items.OrderBy (i => i, StringComparer.OrdinalIgnoreCase)); CreateListView (); - var vsep = new LineView (Orientation.Vertical) { X = Pos.Right (_listView), Y = 1, Height = Dim.Fill () }; + var vsep = new Line { Orientation = Orientation.Vertical, X = Pos.Right (_listView), Y = 1, Height = Dim.Fill () }; top.Add (vsep); CreateTreeView (); diff --git a/Examples/UICatalog/Scenarios/FileDialogExamples.cs b/Examples/UICatalog/Scenarios/FileDialogExamples.cs index 10dcf8c35..49df84740 100644 --- a/Examples/UICatalog/Scenarios/FileDialogExamples.cs +++ b/Examples/UICatalog/Scenarios/FileDialogExamples.cs @@ -62,7 +62,7 @@ public class FileDialogExamples : Scenario x = 24; win.Add ( - new LineView (Orientation.Vertical) { X = x++, Y = 1, Height = 4 } + new Line { Orientation = Orientation.Vertical, X = x++, Y = 1, Height = 4 } ); win.Add (new Label { X = x++, Y = y++, Text = "Caption" }); @@ -74,7 +74,7 @@ public class FileDialogExamples : Scenario x = 34; win.Add ( - new LineView (Orientation.Vertical) { X = x++, Y = 1, Height = 4 } + new Line { Orientation = Orientation.Vertical, X = x++, Y = 1, Height = 4 } ); win.Add (new Label { X = x++, Y = y++, Text = "OpenMode" }); @@ -86,7 +86,7 @@ public class FileDialogExamples : Scenario x = 48; win.Add ( - new LineView (Orientation.Vertical) { X = x++, Y = 1, Height = 4 } + new Line { Orientation = Orientation.Vertical, X = x++, Y = 1, Height = 4 } ); win.Add (new Label { X = x++, Y = y++, Text = "Icons" }); @@ -101,7 +101,7 @@ public class FileDialogExamples : Scenario x = 24; win.Add ( - new LineView (Orientation.Vertical) { X = x++, Y = y + 1, Height = 4 } + new Line { Orientation = Orientation.Vertical, X = x++, Y = y + 1, Height = 4 } ); win.Add (new Label { X = x++, Y = y++, Text = "Allowed" }); @@ -113,7 +113,7 @@ public class FileDialogExamples : Scenario x = 45; win.Add ( - new LineView (Orientation.Vertical) { X = x++, Y = y + 1, Height = 4 } + new Line { Orientation = Orientation.Vertical, X = x++, Y = y + 1, Height = 4 } ); win.Add (new Label { X = x++, Y = y++, Text = "Buttons" }); diff --git a/Examples/UICatalog/Scenarios/LineExample.cs b/Examples/UICatalog/Scenarios/LineExample.cs index e0dc8d0ad..294884d92 100644 --- a/Examples/UICatalog/Scenarios/LineExample.cs +++ b/Examples/UICatalog/Scenarios/LineExample.cs @@ -203,21 +203,6 @@ public class LineExample : Scenario app.Add (framedView); - // Section 6: Comparison with LineView - var comparisonLabel = new Label - { - X = 35, - Y = 15, - Text = "Line vs LineView Comparison:" - }; - app.Add (comparisonLabel); - - app.Add (new Label { X = 35, Y = 16, Text = "Line (uses LineCanvas):" }); - app.Add (new Line { X = 35, Y = 17, Width = 20, Style = LineStyle.Single }); - - app.Add (new Label { X = 35, Y = 18, Text = "LineView (direct render):" }); - app.Add (new LineView { X = 35, Y = 19, Width = 20 }); - // Add help text var helpLabel = new Label { diff --git a/Examples/UICatalog/Scenarios/LineViewExample.cs b/Examples/UICatalog/Scenarios/LineViewExample.cs deleted file mode 100644 index 38290bdce..000000000 --- a/Examples/UICatalog/Scenarios/LineViewExample.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Globalization; -using System.Text; - -namespace UICatalog.Scenarios; - -[ScenarioMetadata ("Line View", "Demonstrates drawing lines using the LineView control.")] -[ScenarioCategory ("Controls")] -[ScenarioCategory ("LineView")] -[ScenarioCategory ("Adornments")] -public class LineViewExample : Scenario -{ - public override void Main () - { - Application.Init (); - - var appWindow = new Window() - { - Title = GetQuitKeyAndName (), - }; - - appWindow.Add (new Label { Y = 1, Text = "Regular Line" }); - - // creates a horizontal line - var line = new LineView { Y = 2 }; - - appWindow.Add (line); - - appWindow.Add (new Label { Y = 3, Text = "Double Width Line" }); - - // creates a horizontal line - var doubleLine = new LineView { Y = 4, LineRune = (Rune)'\u2550' }; - - appWindow.Add (doubleLine); - - appWindow.Add (new Label { Y = 5, Text = "Short Line" }); - - // creates a horizontal line - var shortLine = new LineView { Y = 5, Width = 10 }; - - appWindow.Add (shortLine); - - appWindow.Add (new Label { Y = 7, Text = "Arrow Line" }); - - // creates a horizontal line - var arrowLine = new LineView - { - Y = 8, Width = 10, StartingAnchor = Glyphs.LeftTee, EndingAnchor = (Rune)'>' - }; - - appWindow.Add (arrowLine); - - appWindow.Add (new Label { Y = 10, X = 11, Text = "Vertical Line" }); - - // creates a horizontal line - var verticalLine = new LineView (Orientation.Vertical) { X = 25 }; - - appWindow.Add (verticalLine); - - appWindow.Add (new Label { Y = 12, X = 28, Text = "Vertical Arrow" }); - - // creates a horizontal line - var verticalArrow = new LineView (Orientation.Vertical) - { - X = 27, StartingAnchor = Glyphs.TopTee, EndingAnchor = (Rune)'V' - }; - - appWindow.Add (verticalArrow); - - // Run - Start the application. - Application.Run (appWindow); - appWindow.Dispose (); - - // Shutdown - Calling Application.Shutdown is required. - Application.Shutdown (); - } -} diff --git a/Examples/UICatalog/Scenarios/TileViewNesting.cs b/Examples/UICatalog/Scenarios/TileViewNesting.cs index 2d262bf49..3c4f7e710 100644 --- a/Examples/UICatalog/Scenarios/TileViewNesting.cs +++ b/Examples/UICatalog/Scenarios/TileViewNesting.cs @@ -4,7 +4,6 @@ namespace UICatalog.Scenarios; [ScenarioMetadata ("Tile View Nesting", "Demonstrates recursive nesting of TileViews")] [ScenarioCategory ("Controls")] -[ScenarioCategory ("LineView")] public class TileViewNesting : Scenario { private CheckBox _cbBorder; diff --git a/Terminal.Gui/Views/Line.cs b/Terminal.Gui/Views/Line.cs index d61851753..5b5a9c9a8 100644 --- a/Terminal.Gui/Views/Line.cs +++ b/Terminal.Gui/Views/Line.cs @@ -8,9 +8,8 @@ namespace Terminal.Gui.Views; /// /// /// is a that renders a single horizontal or vertical line -/// using the system. Unlike , which directly renders -/// runes, integrates with the LineCanvas to enable proper box-drawing character -/// selection and line intersection handling. +/// using the system. integrates with the LineCanvas +/// to enable proper box-drawing character selection and line intersection handling. /// /// /// The line's appearance is controlled by the property, which supports @@ -232,7 +231,8 @@ public class Line : View, IOrientation pos, length, Orientation, - Style + Style, + GetAttributeForRole(VisualRole.Normal) ); return true; diff --git a/Terminal.Gui/Views/LineView.cs b/Terminal.Gui/Views/LineView.cs deleted file mode 100644 index e90e99970..000000000 --- a/Terminal.Gui/Views/LineView.cs +++ /dev/null @@ -1,93 +0,0 @@ - -namespace Terminal.Gui.Views; - -/// A straight line control either horizontal or vertical -public class LineView : View -{ - /// Creates a horizontal line - public LineView () : this (Orientation.Horizontal) { } - - /// Creates a horizontal or vertical line based on - public LineView (Orientation orientation) - { - CanFocus = false; - - switch (orientation) - { - case Orientation.Horizontal: - Height = Dim.Auto (minimumContentDim: 1); - Width = Dim.Fill (); - LineRune = Glyphs.HLine; - - break; - case Orientation.Vertical: - Height = Dim.Fill (); - Width = Dim.Auto (minimumContentDim: 1); - LineRune = Glyphs.VLine; - - break; - default: - throw new ArgumentException ($"Unknown Orientation {orientation}"); - } - - Orientation = orientation; - } - - /// - /// The rune to display at the end of the line (right end of horizontal line or bottom end of vertical). If not - /// specified then is used - /// - public Rune? EndingAnchor { get; set; } - - /// The symbol to use for drawing the line - public Rune LineRune { get; set; } - - /// - /// The direction of the line. If you change this you will need to manually update the Width/Height of the - /// control to cover a relevant area based on the new direction. - /// - public Orientation Orientation { get; set; } - - /// - /// The rune to display at the start of the line (left end of horizontal line or top end of vertical) If not - /// specified then is used - /// - public Rune? StartingAnchor { get; set; } - - /// Draws the line including any starting/ending anchors - protected override bool OnDrawingContent () - { - Move (0, 0); - SetAttribute (GetAttributeForRole (VisualRole.Normal)); - - int hLineWidth = Math.Max (1, Glyphs.HLine.GetColumns ()); - - int dEnd = Orientation == Orientation.Horizontal ? Viewport.Width : Viewport.Height; - - for (var d = 0; d < dEnd; d += hLineWidth) - { - if (Orientation == Orientation.Horizontal) - { - Move (d, 0); - } - else - { - Move (0, d); - } - - Rune rune = LineRune; - - if (d == 0) - { - rune = StartingAnchor ?? LineRune; - } - else if (d == dEnd - 1) - { - rune = EndingAnchor ?? LineRune; - } - - Driver?.AddRune (rune); - } - return true; - } -} diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index 0e929ac96..13de45e17 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -780,7 +780,6 @@ public class TileView : View line.Height = _orientation == Orientation.Vertical ? Dim.Fill () : 1; - line.LineRune = _orientation == Orientation.Vertical ? Glyphs.VLine : Glyphs.HLine; if (_orientation == Orientation.Vertical) { @@ -864,7 +863,7 @@ public class TileView : View } } - private class TileViewLineView : LineView + private class TileViewLineView : Line { public Point? moveRuneRenderLocation; diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index 3e00e22bb..a9b011451 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -78,8 +78,8 @@ public class Wizard : Dialog IsDefault = true }; - //// Add a horiz separator - var separator = new LineView (Orientation.Horizontal) { Y = Pos.Top (BackButton) - 1 }; + // Add a horiz separator + var separator = new Line { Orientation = Orientation.Horizontal, X = -1, Y = Pos.Top (BackButton) - 1, Length = Dim.Fill (-1) }; base.Add (separator); AddButton (BackButton); @@ -301,7 +301,7 @@ public class Wizard : Dialog if (previous is { }) { - return GoToStep (previous); + return GoToStep (previous); } return false; diff --git a/Tests/UnitTests/View/ViewTests.cs b/Tests/UnitTests/View/ViewTests.cs index 59569d4dd..a3c1e8496 100644 --- a/Tests/UnitTests/View/ViewTests.cs +++ b/Tests/UnitTests/View/ViewTests.cs @@ -338,7 +338,7 @@ public class ViewTests top.Add (new Label { Text = "111" }); v.Add (top); - v.Add (new LineView (Orientation.Horizontal) { Y = 1 }); + v.Add (new Line { Orientation = Orientation.Horizontal, Y = 1 }); bottom.Add (new Label { Text = "222" }); v.Add (bottom); diff --git a/Tests/UnitTests/Views/LineViewTests.cs b/Tests/UnitTests/Views/LineViewTests.cs deleted file mode 100644 index c0360365c..000000000 --- a/Tests/UnitTests/Views/LineViewTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using UnitTests; - -namespace Terminal.Gui.ViewsTests; - -public class LineViewTests -{ - [Fact] - [AutoInitShutdown] - public void LineView_DefaultConstructor () - { - var horizontal = new LineView (); - - Assert.Equal (Orientation.Horizontal, horizontal.Orientation); - Assert.Equal (Dim.Fill (), horizontal.Width); - horizontal.Layout (); - Assert.Equal (1, horizontal.Frame.Height); - } - - [Fact] - [AutoInitShutdown] - public void LineView_Horizontal () - { - var horizontal = new LineView (Orientation.Horizontal); - - Assert.Equal (Orientation.Horizontal, horizontal.Orientation); - Assert.Equal (Dim.Fill (), horizontal.Width); - horizontal.Layout (); - Assert.Equal (1, horizontal.Frame.Height); - } - - [Fact] - [AutoInitShutdown] - public void LineView_Vertical () - { - var vert = new LineView (Orientation.Vertical); - - Assert.Equal (Orientation.Vertical, vert.Orientation); - Assert.Equal (Dim.Fill (), vert.Height); - vert.Layout (); - Assert.Equal (1, vert.Frame.Width); - } -} diff --git a/Tests/UnitTests/Views/TileViewTests.cs b/Tests/UnitTests/Views/TileViewTests.cs index 4cc7ee2ea..88533ac19 100644 --- a/Tests/UnitTests/Views/TileViewTests.cs +++ b/Tests/UnitTests/Views/TileViewTests.cs @@ -1630,7 +1630,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Horizontal () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.Orientation = Orientation.Horizontal; tileView.Layout (); tileView.Draw (); @@ -1654,7 +1654,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Horizontal_Focused () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.Orientation = Orientation.Horizontal; tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); @@ -1700,7 +1700,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Horizontal_View1MinSize_Absolute () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); tileView.Orientation = Orientation.Horizontal; @@ -1792,7 +1792,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_InsertPanelAtEnd () { - TileView tileView = Get11By3TileView (out LineView line, true); + TileView tileView = Get11By3TileView (out Line line, true); tileView.InsertTile (2); tileView.Layout (); @@ -1811,7 +1811,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_InsertPanelAtStart () { - TileView tileView = Get11By3TileView (out LineView line, true); + TileView tileView = Get11By3TileView (out Line line, true); tileView.InsertTile (0); tileView.Layout (); @@ -1830,7 +1830,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_InsertPanelMiddle () { - TileView tileView = Get11By3TileView (out LineView line, true); + TileView tileView = Get11By3TileView (out Line line, true); tileView.InsertTile (1); tileView.Layout (); @@ -1849,7 +1849,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.Layout (); tileView.Draw (); @@ -1872,7 +1872,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_Focused () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); AutoInitShutdownAttribute.RunIteration (); @@ -1913,7 +1913,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_Focused_50PercentSplit () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.SetSplitterPos (0, Pos.Percent (50)); Assert.IsType (tileView.SplitterDistances.ElementAt (0)); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); @@ -1961,7 +1961,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_Focused_WithBorder () { - TileView tileView = Get11By3TileView (out LineView line, true); + TileView tileView = Get11By3TileView (out Line line, true); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); AutoInitShutdownAttribute.RunIteration (); @@ -2001,7 +2001,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_View1MinSize_Absolute () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); tileView.Tiles.ElementAt (0).MinSize = 6; @@ -2044,7 +2044,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_View1MinSize_Absolute_WithBorder () { - TileView tileView = Get11By3TileView (out LineView line, true); + TileView tileView = Get11By3TileView (out Line line, true); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); tileView.Tiles.ElementAt (0).MinSize = 5; @@ -2087,7 +2087,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_View2MinSize_Absolute () { - TileView tileView = Get11By3TileView (out LineView line); + TileView tileView = Get11By3TileView (out Line line); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); tileView.Tiles.ElementAt (1).MinSize = 6; AutoInitShutdownAttribute.RunIteration (); @@ -2132,7 +2132,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_View2MinSize_Absolute_WithBorder () { - TileView tileView = Get11By3TileView (out LineView line, true); + TileView tileView = Get11By3TileView (out Line line, true); tileView.NewKeyDownEvent (new (tileView.ToggleResizable)); tileView.Tiles.ElementAt (1).MinSize = 5; @@ -2177,7 +2177,7 @@ public class TileViewTests (ITestOutputHelper output) [AutoInitShutdown] public void TestTileView_Vertical_WithBorder () { - TileView tileView = Get11By3TileView (out LineView line, true); + TileView tileView = Get11By3TileView (out Line line, true); AutoInitShutdownAttribute.RunIteration (); @@ -2210,7 +2210,7 @@ public class TileViewTests (ITestOutputHelper output) Assert.Empty (tv.Tiles.ElementAt (0).Title); } - private TileView Get11By3TileView (out LineView line, bool withBorder = false) + private TileView Get11By3TileView (out Line line, bool withBorder = false) { TileView split = Get11By3TileView (withBorder); line = GetLine (split); @@ -2267,7 +2267,7 @@ public class TileViewTests (ITestOutputHelper output) return tv; } - private LineView GetLine (TileView tileView) { return tileView.SubViews.OfType ().Single (); } + private Line GetLine (TileView tileView) { return tileView.SubViews.OfType ().Single (); } /// Creates a vertical orientation root container with left pane split into two (with horizontal splitter line). /// diff --git a/docfx/docs/views.md b/docfx/docs/views.md index 85fb126db..4b05a5df0 100644 --- a/docfx/docs/views.md +++ b/docfx/docs/views.md @@ -307,14 +307,6 @@ Draws a single line using the [LineStyle](~/api/Terminal.Gui.Drawing.LineStyle.y ────────────────────────────────────────────────── ``` -## [LineView](~/api/Terminal.Gui.Views.LineView.yml) - -A straight line control either horizontal or vertical - -```text -────────────────────────────────────────────────── -``` - ## [ListView](~/api/Terminal.Gui.Views.ListView.yml) Provides a scrollable list of data where each item can be activated to perform an action.