From 69a2c4de53411e0711b76b7e590dbb56a6c6f826 Mon Sep 17 00:00:00 2001 From: Tig Date: Wed, 6 Nov 2024 17:06:24 -0700 Subject: [PATCH] Messing with border --- Terminal.Gui/View/View.Drawing.cs | 2 +- UICatalog/Scenarios/AllViewsTester.cs | 21 ++++--- UICatalog/Scenarios/LineCanvasExperiment.cs | 2 +- UnitTests/View/Adornment/BorderTests.cs | 65 ++++++++++++++++++++- 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/Terminal.Gui/View/View.Drawing.cs b/Terminal.Gui/View/View.Drawing.cs index 9e431f81b..1a2f185ad 100644 --- a/Terminal.Gui/View/View.Drawing.cs +++ b/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 (); diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index c60b812f1..28fbd6eea 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -59,7 +59,8 @@ public class AllViewsTester : Scenario ColorScheme = Colors.ColorSchemes ["TopLevel"], SelectedItem = 0, Source = new ListWrapper (new (_viewClasses.Keys.ToList ())), - BorderStyle = LineStyle.Rounded + BorderStyle = LineStyle.Rounded, + SuperViewRendersLineCanvas = true }; _classListView.SelectedItemChanged += (s, args) => @@ -87,28 +88,30 @@ public class AllViewsTester : Scenario _adornmentsEditor = new () { Title = "Adornments [_2]", - X = Pos.Right (_classListView), + X = Pos.Right (_classListView) - 1, Y = 0, Width = Dim.Auto (), Height = Dim.Auto (), ColorScheme = Colors.ColorSchemes ["TopLevel"], BorderStyle = LineStyle.Rounded, AutoSelectViewToEdit = false, - AutoSelectAdornments = false + AutoSelectAdornments = false, + SuperViewRendersLineCanvas = true }; _adornmentsEditor.ExpanderButton.Orientation = Orientation.Vertical; _arrangementEditor = new () { Title = "Arrangement [_3]", - X = Pos.Right (_classListView), - Y = Pos.Bottom (_adornmentsEditor), + X = Pos.Right (_classListView) - 1, + Y = Pos.Bottom (_adornmentsEditor) -1, Width = Dim.Width (_adornmentsEditor), Height = Dim.Fill (), ColorScheme = Colors.ColorSchemes ["TopLevel"], BorderStyle = LineStyle.Rounded, AutoSelectViewToEdit = false, - AutoSelectAdornments = false + AutoSelectAdornments = false, + SuperViewRendersLineCanvas = true }; _arrangementEditor.ExpanderButton.Orientation = Orientation.Vertical; @@ -124,7 +127,8 @@ public class AllViewsTester : Scenario ColorScheme = Colors.ColorSchemes ["TopLevel"], BorderStyle = LineStyle.Rounded, AutoSelectViewToEdit = false, - AutoSelectAdornments = false + AutoSelectAdornments = false, + SuperViewRendersLineCanvas = true }; _settingsPane = new () @@ -136,7 +140,8 @@ public class AllViewsTester : Scenario Height = Dim.Auto (), CanFocus = true, ColorScheme = Colors.ColorSchemes ["TopLevel"], - BorderStyle = LineStyle.Rounded + BorderStyle = LineStyle.Rounded, + SuperViewRendersLineCanvas = true }; Label label = new () { X = 0, Y = 0, Text = "_Orientation:" }; diff --git a/UICatalog/Scenarios/LineCanvasExperiment.cs b/UICatalog/Scenarios/LineCanvasExperiment.cs index e38175296..6732736dc 100644 --- a/UICatalog/Scenarios/LineCanvasExperiment.cs +++ b/UICatalog/Scenarios/LineCanvasExperiment.cs @@ -131,7 +131,7 @@ public class LineCanvasExperiment : Scenario //ColorScheme = Colors.ColorSchemes ["Error"], SuperViewRendersLineCanvas = true }; - marginWindow.Margin.ColorScheme = Colors.ColorSchemes ["Dialog"]; + marginWindow.Margin.ColorScheme = Colors.ColorSchemes ["Error"]; marginWindow.Margin.Thickness = new (1); marginWindow.Border.Thickness = new (1, 2, 1, 1); diff --git a/UnitTests/View/Adornment/BorderTests.cs b/UnitTests/View/Adornment/BorderTests.cs index 9e74670f3..fd4c98a4c 100644 --- a/UnitTests/View/Adornment/BorderTests.cs +++ b/UnitTests/View/Adornment/BorderTests.cs @@ -836,7 +836,7 @@ public class BorderTests (ITestOutputHelper output) │ ┊ ┊ └─└┄┘")] [SetupFakeDriver] - public void SuperViewRendersLineCanvas_AutoJoinsLines (bool superViewRendersLineCanvas, string expected) + public void SuperViewRendersLineCanvas_No_Subviews_AutoJoinsLines (bool superViewRendersLineCanvas, string expected) { View superView = new View () { @@ -876,4 +876,67 @@ public class BorderTests (ITestOutputHelper output) TestHelpers.AssertDriverContentsAre (expected, output); } + + + [Theory] + [InlineData (false, @" +┌┤A├──────┐ +│ ║ │ +│ ║ │ +│════┌┤C├┄│ +│ ┊ │ +│ ┊ │ +└─────────┘")] + [InlineData (true, @" +╔╡A╞═╗────┐ +║ ║ │ +║ ║ │ +╚════╬┤C├┄┐ +│ ┊ ┊ +│ ┊ ┊ +└────└┄┄┄┄┘")] + [SetupFakeDriver] + public void SuperViewRendersLineCanvas_Title_AutoJoinsLines (bool superViewRendersLineCanvas, string expected) + { + View superView = new View () + { + Id = "superView", + Title = "A", + Width = 11, + Height = 7, + BorderStyle = LineStyle.Single + }; + + View view1 = new View () + { + Id = "view1", + Title = "B", + Width = 6, + Height = 4, + X = -1, + Y = -1, + BorderStyle = LineStyle.Double, + SuperViewRendersLineCanvas = superViewRendersLineCanvas + }; + + View view2 = new View () + { + Id = "view2", + Title = "C", + Width = 6, + Height = 4, + X = 4, + Y = 2, + BorderStyle = LineStyle.Dotted, + SuperViewRendersLineCanvas = superViewRendersLineCanvas + }; + + superView.Add (view1, view2); + + superView.BeginInit (); + superView.EndInit (); + superView.Draw (); + + TestHelpers.AssertDriverContentsAre (expected, output); + } }