Browse Source

Remove `SetView1` and `SetView2` methods and just mount tab views properly

tznind 2 years ago
parent
commit
56072f3865
2 changed files with 4 additions and 51 deletions
  1. 0 35
      Terminal.Gui/Views/SplitView.cs
  2. 4 16
      UICatalog/Scenarios/Notepad.cs

+ 0 - 35
Terminal.Gui/Views/SplitView.cs

@@ -734,41 +734,6 @@ namespace Terminal.Gui {
 
 
 		}
 		}
 
 
-		/// <summary>
-		/// Replaces <see cref="View1"/> with the provided <paramref name="view"/>.
-		/// The new <paramref name="view"/> will be resized to fill available 
-		/// area and resized on <see cref="SplitterMoved"/>.
-		/// </summary>
-		/// <param name="view"></param>
-		public void SetView1 (View view)
-		{
-			if(View1 != null) {
-				Remove (View1);
-			}
-
-			Add (view);
-			View1 = view;
-			LayoutSubviews ();
-		}
-
-		/// <summary>
-		/// Replaces <see cref="View2"/> with the provided <paramref name="view"/>.
-		/// The new <paramref name="view"/> will be resized to fill available 
-		/// area and resized on <see cref="SplitterMoved"/>.
-		/// </summary>
-		/// <param name="view"></param>
-		public void SetView2 (View view)
-		{
-			if (View2 != null) {
-				Remove (View2);
-			}
-
-			Add (view);
-
-			View2 = view;
-			LayoutSubviews ();
-		}
-
 		private class ChildSplitterLine {
 		private class ChildSplitterLine {
 
 
 			readonly SplitContainerLineView currentLine;
 			readonly SplitContainerLineView currentLine;

+ 4 - 16
UICatalog/Scenarios/Notepad.cs

@@ -32,14 +32,7 @@ namespace UICatalog.Scenarios {
 				});
 				});
 			Application.Top.Add (menu);
 			Application.Top.Add (menu);
 
 
-			tabView = new TabView () {
-				X = 0,
-				Y = 1,
-				Width = Dim.Fill (),
-				Height = Dim.Fill (1),
-			};
-
-			tabView.TabClicked += TabView_TabClicked;
+			tabView = CreateNewTabView ();
 
 
 			tabView.Style.ShowBorder = true;
 			tabView.Style.ShowBorder = true;
 			tabView.ApplyStyleChanges ();
 			tabView.ApplyStyleChanges ();
@@ -52,7 +45,7 @@ namespace UICatalog.Scenarios {
 				Height = Dim.Fill (1),
 				Height = Dim.Fill (1),
 			};
 			};
 			split.View2.Visible = false;
 			split.View2.Visible = false;
-			split.SetView1 (tabView);
+			split.View1.Add (tabView);
 			split.IntegratedBorder = BorderStyle.None;
 			split.IntegratedBorder = BorderStyle.None;
 
 
 			Application.Top.Add (split);
 			Application.Top.Add (split);
@@ -129,18 +122,13 @@ namespace UICatalog.Scenarios {
 		}
 		}
 		private void SplitRight (TabView sender, OpenedFile tab)
 		private void SplitRight (TabView sender, OpenedFile tab)
 		{
 		{
-			var split = (SplitView)sender.SuperView;
-
-			// TODO: How can SuperView sometimes be null?!
-			if(split == null) {
-				throw new NullReferenceException ("Much confusion, sender.SuperView is null");
-			}
+			var split = (SplitView)sender.SuperView.SuperView;
 
 
 			split.TrySplitView1 (out var sub);
 			split.TrySplitView1 (out var sub);
 			sub.Orientation = Terminal.Gui.Graphs.Orientation.Vertical;
 			sub.Orientation = Terminal.Gui.Graphs.Orientation.Vertical;
 			var newTabView = CreateNewTabView ();
 			var newTabView = CreateNewTabView ();
 			tab.CloneTo (newTabView);
 			tab.CloneTo (newTabView);
-			sub.SetView2 (newTabView);
+			sub.View2.Add (newTabView);
 		}
 		}
 
 
 		private TabView CreateNewTabView ()
 		private TabView CreateNewTabView ()