Browse Source

WIP new multi tile system compiling

tznind 2 years ago
parent
commit
395fc3d9d1
2 changed files with 13 additions and 64 deletions
  1. 12 63
      Terminal.Gui/Views/SplitView.cs
  2. 1 1
      UnitTests/SplitViewTests.cs

+ 12 - 63
Terminal.Gui/Views/SplitView.cs

@@ -24,7 +24,7 @@ namespace Terminal.Gui {
 		public BorderStyle IntegratedBorder { get; set; }
 		public BorderStyle IntegratedBorder { get; set; }
 
 
 		public class Tile {
 		public class Tile {
-			public View View { get; }
+			public View View { get; internal set; }
 			public int MinSize { get; set; }
 			public int MinSize { get; set; }
 			public string Title { get; set; }
 			public string Title { get; set; }
 
 
@@ -259,7 +259,7 @@ namespace Terminal.Gui {
 				}
 				}
 			}
 			}
 		}
 		}
-		/*
+		
 		/// <summary>
 		/// <summary>
 		/// Converts <see cref="View1"/> from a regular <see cref="View"/>
 		/// Converts <see cref="View1"/> from a regular <see cref="View"/>
 		/// container to a new nested <see cref="SplitView"/>.  If <see cref="View1"/>
 		/// container to a new nested <see cref="SplitView"/>.  If <see cref="View1"/>
@@ -274,67 +274,14 @@ namespace Terminal.Gui {
 		/// <returns><see langword="true"/> if a <see cref="View"/> was converted to a new nested
 		/// <returns><see langword="true"/> if a <see cref="View"/> was converted to a new nested
 		/// <see cref="SplitView"/>.  <see langword="false"/> if it was already a nested
 		/// <see cref="SplitView"/>.  <see langword="false"/> if it was already a nested
 		/// <see cref="SplitView"/></returns>
 		/// <see cref="SplitView"/></returns>
-		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
 			// when splitting a view into 2 sub views we will need to migrate
 			// the title too
 			// the title too
-			var title = View1Title;
-
-			bool returnValue = TrySplit (
-				this.View1,
-				(newSplitContainer) => {
-					this.View1 = newSplitContainer;
-					
-					// Move title to new container
-					View1Title = string.Empty;
-					newSplitContainer.View1Title = title;
-				},
-				out result);
-			
-			return returnValue;
-		}
+			var tile = tiles [idx];
+			var title = tile.Title;
+			View toMove = tile.View;
 
 
-		/// <summary>
-		/// Converts <see cref="View2"/> from a regular <see cref="View"/>
-		/// container to a new nested <see cref="SplitView"/>.  If <see cref="View2"/>
-		/// is already a <see cref="SplitView"/> then returns false.
-		/// </summary>
-		/// <remarks>After successful splitting, the returned container's <see cref="View1"/> 
-		/// will contain the original content and <see cref="View2Title"/> (if any) while
-		/// <see cref="View2"/> will be empty and available for adding to.
-		/// for adding to.</remarks>
-		/// <param name="result">The new <see cref="SplitView"/> now showing in 
-		/// <see cref="View2"/> or the existing one if it was already been converted before.</param>
-		/// <returns><see langword="true"/> if a <see cref="View"/> was converted to a new nested
-		/// <see cref="SplitView"/>.  <see langword="false"/> if it was already a nested
-		/// <see cref="SplitView"/></returns>
-		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<SplitView> newSplitContainerSetter,
-			out SplitView result)
-		{
 			if (toMove is SplitView existing) {
 			if (toMove is SplitView existing) {
 				result = existing;
 				result = existing;
 				return false;
 				return false;
@@ -353,16 +300,18 @@ namespace Terminal.Gui {
 			// Remove the view itself and replace it with the new SplitContainer
 			// Remove the view itself and replace it with the new SplitContainer
 			Remove (toMove);
 			Remove (toMove);
 			Add (newContainer);
 			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
 			// 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;
 			result = newContainer;
 			return true;
 			return true;
-		}*/
+		}
 
 
 
 
 		private List<SplitContainerLineView> GetAllChildSplitContainerLineViewRecursively (View v)
 		private List<SplitContainerLineView> GetAllChildSplitContainerLineViewRecursively (View v)

+ 1 - 1
UnitTests/SplitViewTests.cs

@@ -541,7 +541,7 @@ namespace UnitTests {
 		private SplitView GetNestedContainer2Left1Right(bool withBorder)
 		private SplitView GetNestedContainer2Left1Right(bool withBorder)
 		{
 		{
 			var container = GetSplitView (20, 10,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.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
 			newContainer.ColorScheme = new ColorScheme ();
 			newContainer.ColorScheme = new ColorScheme ();