Fixes #2493. Move all layout code out of View (and Toplevel) into a layout helper class (#2544)

* Comment/warning clean up

* Moved Text and Drawing out

* Moved Layout out

* Removed extra lines

* Removed Mouse out

* Reorgainzed View

* API docs

* removed border.cs

* TopLevel.Resized -> TerminalResized

* Mdi -> Overlapped

* Removed confusing and un-needed WillPresent

* privates -> _

* Tweaked RunLoop API
This commit is contained in:
Tig
2023-04-14 10:26:10 -06:00
committed by GitHub
parent 8c59e8255f
commit b4552ee14b
154 changed files with 5261 additions and 5725 deletions

View File

@@ -37,7 +37,6 @@ namespace Terminal.Gui.ViewsTests {
}
[Fact]
public void EnsureValidScrollOffsets_LoadSmallerTable ()
{
@@ -67,7 +66,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (0, tableView.RowOffset);
Assert.Equal (0, tableView.ColumnOffset);
// Trying to set invalid indexes should not be possible
tableView.RowOffset = 20;
tableView.ColumnOffset = 10;
@@ -92,7 +90,6 @@ namespace Terminal.Gui.ViewsTests {
tableView.Redraw (tableView.Bounds);
}
[Fact]
public void SelectedCellChanged_NotFiredForSameValue ()
{
@@ -116,7 +113,6 @@ namespace Terminal.Gui.ViewsTests {
}
[Fact]
public void SelectedCellChanged_SelectedColumnIndexesCorrect ()
{
@@ -199,7 +195,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.False (tableView.IsSelected (2, 4));
}
[Fact]
public void IsSelected_MultiSelectionOn_Horizontal ()
{
@@ -224,7 +219,6 @@ namespace Terminal.Gui.ViewsTests {
}
[Fact]
public void IsSelected_MultiSelectionOn_BoxSelection ()
{
@@ -269,7 +263,6 @@ namespace Terminal.Gui.ViewsTests {
Application.Top.Add (tableView);
Application.Begin (Application.Top);
Application.Top.FocusFirst ();
Assert.True (tableView.HasFocus);
@@ -315,7 +308,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (9, tableView.GetAllSelectedCells ().Count ());
}
[Fact]
public void DeleteRow_SelectLastRow_AdjustsSelectionToPreventOverrun ()
{
@@ -362,7 +354,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (new Point (1, 1), tableView.GetAllSelectedCells ().Single ());
}
[Fact]
public void GetAllSelectedCells_SquareSelection_ReturnsFour ()
{
@@ -387,7 +378,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (new Point (2, 2), selected [3]);
}
[Fact]
public void GetAllSelectedCells_SquareSelection_FullRowSelect ()
{
@@ -415,7 +405,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (new Point (2, 2), selected [5]);
}
[Fact]
public void GetAllSelectedCells_TwoIsolatedSelections_ReturnsSix ()
{
@@ -477,7 +466,6 @@ namespace Terminal.Gui.ViewsTests {
Application.Shutdown ();
}
[Fact, AutoInitShutdown]
public void TableView_ExpandLastColumn_False ()
{
@@ -757,7 +745,6 @@ namespace Terminal.Gui.ViewsTests {
";
TestHelpers.AssertDriverContentsAre (expected, output);
string expectedColors = @"
00000
00000
@@ -802,7 +789,6 @@ namespace Terminal.Gui.ViewsTests {
";
TestHelpers.AssertDriverContentsAre (expected, output);
string expectedColors = @"
00000
00000
@@ -822,7 +808,6 @@ namespace Terminal.Gui.ViewsTests {
Application.Shutdown ();
}
[Theory, AutoInitShutdown]
[InlineData (false)]
[InlineData (true)]
@@ -860,7 +845,6 @@ namespace Terminal.Gui.ViewsTests {
";
TestHelpers.AssertDriverContentsAre (expected, output);
string expectedColors = @"
00000
00000
@@ -876,7 +860,6 @@ namespace Terminal.Gui.ViewsTests {
// 2
rowHighlight.Normal});
// change the value in the table so that
// it no longer matches the RowColorGetter
// delegate conditional ( which checks for
@@ -892,7 +875,6 @@ namespace Terminal.Gui.ViewsTests {
";
TestHelpers.AssertDriverContentsAre (expected, output);
expectedColors = @"
00000
00000
@@ -909,7 +891,6 @@ namespace Terminal.Gui.ViewsTests {
// 1
focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal });
// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
}
@@ -954,7 +935,6 @@ namespace Terminal.Gui.ViewsTests {
";
TestHelpers.AssertDriverContentsAre (expected, output);
string expectedColors = @"
00000
00000
@@ -970,7 +950,6 @@ namespace Terminal.Gui.ViewsTests {
// 2
cellHighlight.Normal});
// change the value in the table so that
// it no longer matches the ColorGetter
// delegate conditional ( which checks for
@@ -986,7 +965,6 @@ namespace Terminal.Gui.ViewsTests {
";
TestHelpers.AssertDriverContentsAre (expected, output);
expectedColors = @"
00000
00000
@@ -1003,7 +981,6 @@ namespace Terminal.Gui.ViewsTests {
// 1
focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal });
// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
}
@@ -1097,11 +1074,9 @@ namespace Terminal.Gui.ViewsTests {
TestHelpers.AssertDriverContentsAre (expected, output);
// Scroll right
tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight });
tableView.Redraw (tableView.Bounds);
// Note that with SmoothHorizontalScrolling only a single new column
@@ -1118,7 +1093,6 @@ namespace Terminal.Gui.ViewsTests {
TestHelpers.AssertDriverContentsAre (expected, output);
// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
}
@@ -1161,11 +1135,9 @@ namespace Terminal.Gui.ViewsTests {
TestHelpers.AssertDriverContentsAre (expected, output);
// Scroll right
tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight });
tableView.Redraw (tableView.Bounds);
// notice that without smooth scrolling we just update the first column
@@ -1174,7 +1146,6 @@ namespace Terminal.Gui.ViewsTests {
// area as we scroll until the new column (D) is exposed. But it makes
// the view 'jump' to expose all new columns
expected =
@"
│D│E│F│
@@ -1182,7 +1153,6 @@ namespace Terminal.Gui.ViewsTests {
TestHelpers.AssertDriverContentsAre (expected, output);
// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
}
@@ -1209,7 +1179,6 @@ namespace Terminal.Gui.ViewsTests {
dt.Columns.Add ("E");
dt.Columns.Add ("F");
dt.Rows.Add (1, 2, 3, 4, 5, 6);
tableView.Table = dt;
@@ -1254,7 +1223,6 @@ namespace Terminal.Gui.ViewsTests {
TestHelpers.AssertDriverContentsAre (expected, output);
}
[Fact, AutoInitShutdown]
public void TestColumnStyle_AllColumnsVisibleFalse_BehavesAsTableNull ()
{
@@ -1268,7 +1236,6 @@ namespace Terminal.Gui.ViewsTests {
tableView.Style.GetOrCreateColumnStyle (dt.Columns ["F"]).Visible = false;
tableView.LayoutSubviews ();
// expect nothing to be rendered when all columns are invisible
string expected =
@"
@@ -1277,7 +1244,6 @@ namespace Terminal.Gui.ViewsTests {
tableView.Redraw (tableView.Bounds);
TestHelpers.AssertDriverContentsAre (expected, output);
// expect behavior to match when Table is null
tableView.Table = null;
@@ -1407,7 +1373,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (1, tableView.SelectedColumn);
}
[InlineData (true)]
[InlineData (false)]
[Theory, AutoInitShutdown]
@@ -1586,7 +1551,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (0, s2.X);
Assert.Equal (1, s2.Y);
// Go back to the toggled cell
tableView.ProcessKey (new KeyEvent { Key = Key.CursorRight });
tableView.ProcessKey (new KeyEvent { Key = Key.CursorUp });
@@ -1639,7 +1603,6 @@ namespace Terminal.Gui.ViewsTests {
}
[Fact, AutoInitShutdown]
public void TestToggleCells_MultiSelectOn_SquareSelectToggled ()
{
@@ -1709,7 +1672,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (8, tableView.GetAllSelectedCells ().Count ());
}
[Theory, AutoInitShutdown]
[InlineData (new object [] { true, true })]
[InlineData (new object [] { false, true })]
@@ -1888,7 +1850,6 @@ namespace Terminal.Gui.ViewsTests {
Application.Shutdown ();
}
[Fact, AutoInitShutdown]
public void ScrollIndicators ()
{
@@ -1931,11 +1892,9 @@ namespace Terminal.Gui.ViewsTests {
TestHelpers.AssertDriverContentsAre (expected, output);
// Scroll right
tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight });
// since A is now pushed off screen we get indicator showing
// that user can scroll left to see first column
tableView.Redraw (tableView.Bounds);
@@ -1948,7 +1907,6 @@ namespace Terminal.Gui.ViewsTests {
TestHelpers.AssertDriverContentsAre (expected, output);
// Scroll right twice more (to end of columns)
tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight });
tableView.ProcessKey (new KeyEvent () { Key = Key.CursorRight });
@@ -2021,7 +1979,6 @@ namespace Terminal.Gui.ViewsTests {
}
tv.Redraw (tv.Bounds);
expected =
@"
@@ -2032,7 +1989,6 @@ namespace Terminal.Gui.ViewsTests {
";
TestHelpers.AssertDriverColorsAre (expected, new Attribute [] { tv.ColorScheme.Normal, color });
}
/// <summary>
@@ -2102,7 +2058,6 @@ namespace Terminal.Gui.ViewsTests {
// after last row
Assert.Null (tableView.ScreenToCell (1, 4));
// ---------------- X=2 -----------------------
// ( even though there is a horizontal dividing line here we treat it as a hit on the cell before)
// click in header
@@ -2116,7 +2071,6 @@ namespace Terminal.Gui.ViewsTests {
// after last row
Assert.Null (tableView.ScreenToCell (2, 4));
// ---------------- X=3 -----------------------
// click in header
Assert.Null (tableView.ScreenToCell (3, 0));
@@ -2180,7 +2134,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Null (tableView.ScreenToCell (1, 4, out col));
Assert.Null (col);
// ---------------- X=2 -----------------------
// click in header
Assert.Null (tableView.ScreenToCell (2, 0, out col));
@@ -2198,7 +2151,6 @@ namespace Terminal.Gui.ViewsTests {
Assert.Null (tableView.ScreenToCell (2, 4, out col));
Assert.Null (col);
// ---------------- X=3 -----------------------
// click in header
Assert.Null (tableView.ScreenToCell (3, 0, out col));