Add Style.ShowHeaders to TableView (#2514)

* Add Style.HideHeaders to TableView

* Revisions to TableView HideHeaders from review

Also add to UICatalog TableEditor Scenario

* Allow ShowHorizontalHeaderUnderline to draw top border even when HideHeaders is enabled; AlwaysShowHeader will keep it there on scroll

* Add Unit Tests for TableView.Style.HideHeaders

* Rename HideHeaders to ShowHeaders and simplify logic

---------

Co-authored-by: tznind <tznind@dundee.ac.uk>
This commit is contained in:
Nutzzz
2023-04-15 17:27:05 -07:00
committed by GitHub
parent 62746f8037
commit dcdb4f9b49
3 changed files with 105 additions and 5 deletions

View File

@@ -444,6 +444,86 @@ namespace Terminal.Gui.ViewsTests {
Assert.Equal (new Point (8, 3), selected [5]);
}
[Fact, AutoInitShutdown]
public void TableView_ShowHeadersFalse_AndNoHeaderLines ()
{
var tv = GetABCDEFTableView (out _);
tv.Bounds = new Rect (0, 0, 5, 5);
tv.Style.ShowHeaders = false;
tv.Style.ShowHorizontalHeaderOverline = false;
tv.Style.ShowHorizontalHeaderUnderline = false;
tv.Redraw (tv.Bounds);
string expected = @"
│1│2│
";
TestHelpers.AssertDriverContentsAre (expected, output);
}
[Fact, AutoInitShutdown]
public void TableView_ShowHeadersFalse_OverlineTrue ()
{
var tv = GetABCDEFTableView (out _);
tv.Bounds = new Rect (0, 0, 5, 5);
tv.Style.ShowHeaders = false;
tv.Style.ShowHorizontalHeaderOverline = true;
tv.Style.ShowHorizontalHeaderUnderline = false;
tv.Redraw (tv.Bounds);
string expected = @"
┌─┬─┐
│1│2│
";
TestHelpers.AssertDriverContentsAre (expected, output);
}
[Fact, AutoInitShutdown]
public void TableView_ShowHeadersFalse_UnderlineTrue ()
{
var tv = GetABCDEFTableView (out _);
tv.Bounds = new Rect (0, 0, 5, 5);
tv.Style.ShowHeaders = false;
tv.Style.ShowHorizontalHeaderOverline = false;
tv.Style.ShowHorizontalHeaderUnderline = true;
// Horizontal scrolling option is part of the underline
tv.Style.ShowHorizontalScrollIndicators = true;
tv.Redraw (tv.Bounds);
string expected = @"
├─┼─►
│1│2│
";
TestHelpers.AssertDriverContentsAre (expected, output);
}
[Fact, AutoInitShutdown]
public void TableView_ShowHeadersFalse_AllLines ()
{
var tv = GetABCDEFTableView (out _);
tv.Bounds = new Rect (0, 0, 5, 5);
tv.Style.ShowHeaders = false;
tv.Style.ShowHorizontalHeaderOverline = true;
tv.Style.ShowHorizontalHeaderUnderline = true;
// Horizontal scrolling option is part of the underline
tv.Style.ShowHorizontalScrollIndicators = true;
tv.Redraw (tv.Bounds);
string expected = @"
┌─┬─┐
├─┼─►
│1│2│
";
TestHelpers.AssertDriverContentsAre (expected, output);
}
[Fact, AutoInitShutdown]
public void TableView_ExpandLastColumn_True ()
{