diff --git a/Terminal.Gui/Views/SplitView.cs b/Terminal.Gui/Views/SplitView.cs index 95e9190d0..b46c2d41f 100644 --- a/Terminal.Gui/Views/SplitView.cs +++ b/Terminal.Gui/Views/SplitView.cs @@ -24,7 +24,7 @@ namespace Terminal.Gui { public BorderStyle IntegratedBorder { get; set; } public class Tile { - public View View { get; } + public View View { get; internal set; } public int MinSize { get; set; } public string Title { get; set; } @@ -259,7 +259,7 @@ namespace Terminal.Gui { } } } - /* + /// /// Converts from a regular /// container to a new nested . If @@ -274,67 +274,14 @@ namespace Terminal.Gui { /// if a was converted to a new nested /// . if it was already a nested /// - public bool TrySplitView1(out SplitView result) + public bool TrySplitView(int idx, out SplitView result) { // when splitting a view into 2 sub views we will need to migrate // the title too - var title = View1Title; + var tile = tiles [idx]; + var title = tile.Title; + View toMove = tile.View; - bool returnValue = TrySplit ( - this.View1, - (newSplitContainer) => { - this.View1 = newSplitContainer; - - // Move title to new container - View1Title = string.Empty; - newSplitContainer.View1Title = title; - }, - out result); - - return returnValue; - } - - /// - /// Converts from a regular - /// container to a new nested . If - /// is already a then returns false. - /// - /// After successful splitting, the returned container's - /// will contain the original content and (if any) while - /// will be empty and available for adding to. - /// for adding to. - /// The new now showing in - /// or the existing one if it was already been converted before. - /// if a was converted to a new nested - /// . if it was already a nested - /// - public bool TrySplitView2 (out SplitView result) - { - // when splitting a view into 2 sub views we will need to migrate - // the title too - var title = View2Title; - - bool returnValue = TrySplit ( - this.View2, - (newSplitContainer) => { - this.View2 = newSplitContainer; - - // Move title to new container - View2Title = string.Empty; - - // Content always goes into View1 of the new container - // so that is where the title goes too - newSplitContainer.View1Title = title; - }, - out result); - - return returnValue; - } - private bool TrySplit( - View toMove, - Action newSplitContainerSetter, - out SplitView result) - { if (toMove is SplitView existing) { result = existing; return false; @@ -353,16 +300,18 @@ namespace Terminal.Gui { // Remove the view itself and replace it with the new SplitContainer Remove (toMove); Add (newContainer); - newSplitContainerSetter(newContainer); + tile.View = newContainer; + + var newTileView1 = newContainer.tiles [0].View; // Add the original content into the first view of the new container - foreach(var childView in childViews) { - newContainer.View1.Add (childView); + foreach (var childView in childViews) { + newTileView1.Add (childView); } result = newContainer; return true; - }*/ + } private List GetAllChildSplitContainerLineViewRecursively (View v) diff --git a/UnitTests/SplitViewTests.cs b/UnitTests/SplitViewTests.cs index 466cb32ec..e93d7e504 100644 --- a/UnitTests/SplitViewTests.cs +++ b/UnitTests/SplitViewTests.cs @@ -541,7 +541,7 @@ namespace UnitTests { private SplitView GetNestedContainer2Left1Right(bool withBorder) { var container = GetSplitView (20, 10,withBorder); - Assert.True (container.TrySplitView1 (out var newContainer)); + Assert.True (container.TrySplitView (0, out var newContainer)); newContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal; newContainer.ColorScheme = new ColorScheme ();