From b614a7beafc9bf5669ccbf86f525b1d5bbd91e7f Mon Sep 17 00:00:00 2001 From: tznind Date: Sun, 29 Jan 2023 10:13:33 +0000 Subject: [PATCH] TileView now respects Tile.View.Visible --- Terminal.Gui/Views/TileView.cs | 72 ++++- UnitTests/TileViewTests.cs | 511 ++++++++++++++++++++++----------- 2 files changed, 405 insertions(+), 178 deletions(-) diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index bda0ef2f4..0268a0288 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -352,7 +352,7 @@ namespace Terminal.Gui { lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, IntegratedBorder); } - foreach (var line in allLines.Where (l => l.Visible)) { + foreach (var line in allLines) { bool isRoot = splitterLines.Contains (line); line.ViewToScreen (0, 0, out var x1, out var y1); @@ -467,11 +467,13 @@ namespace Terminal.Gui { foreach (var sub in v.Subviews) { if (sub is TileViewLineView s) { - if (s.Parent.GetRootTileView () == this) { + if (s.Visible && s.Parent.GetRootTileView () == this) { lines.Add (s); } } else { - lines.AddRange (GetAllLineViewsRecursively (sub)); + if(sub.Visible) { + lines.AddRange (GetAllLineViewsRecursively (sub)); + } } } @@ -557,6 +559,7 @@ namespace Terminal.Gui { RespectMinimumTileSizes (); + for (int i = 0; i < splitterLines.Count; i++) { var line = splitterLines[i]; @@ -579,36 +582,77 @@ namespace Terminal.Gui { } - for (int i = 0; i < tiles.Count; i++) { - var tile = tiles [i]; + HideSplittersBasedOnTileVisibility (); + + var visibleTiles = tiles.Where (t => t.View.Visible).ToArray (); + var visibleSplitterLines = splitterLines.Where (l => l.Visible).ToArray (); + + for (int i = 0; i < visibleTiles.Length; i++) { + var tile = visibleTiles [i]; // TODO: Deal with lines being Visibility false if (Orientation == Orientation.Vertical) { - tile.View.X = i == 0 ? bounds.X : Pos.Right (splitterLines [i - 1]); + tile.View.X = i == 0 ? bounds.X : Pos.Right (visibleSplitterLines [i - 1]); tile.View.Y = bounds.Y; tile.View.Height = bounds.Height; - tile.View.Width = GetTileWidthOrHeight(i, Bounds.Width); + tile.View.Width = GetTileWidthOrHeight(i, Bounds.Width, visibleTiles,visibleSplitterLines); } else { tile.View.X = bounds.X; - tile.View.Y = i == 0 ? 0 : Pos.Bottom (splitterLines [i - 1]); + tile.View.Y = i == 0 ? 0 : Pos.Bottom (visibleSplitterLines [i - 1]); tile.View.Width = bounds.Width; - tile.View.Height = GetTileWidthOrHeight(i, Bounds.Height); + tile.View.Height = GetTileWidthOrHeight(i, Bounds.Height, visibleTiles, visibleSplitterLines); } } } - private Dim GetTileWidthOrHeight (int i, int space) + private void HideSplittersBasedOnTileVisibility () + { + foreach(var line in splitterLines) { + line.Visible = true; + } + + for(int i=0;i