Browse Source

Fix tests and drawing of splitter moving Rune

tznind 2 years ago
parent
commit
a3281a437f
2 changed files with 19 additions and 58 deletions
  1. 17 53
      Terminal.Gui/Views/SplitContainer.cs
  2. 2 5
      UnitTests/SplitContainerTests.cs

+ 17 - 53
Terminal.Gui/Views/SplitContainer.cs

@@ -94,9 +94,6 @@ namespace Terminal.Gui {
 
 		public override void LayoutSubviews ()
 		{
-
-			splitterLine.moveRuneRenderLocation = null;
-
 			if(this.IsRootSplitContainer()) {
 
 				var contentArea = Bounds;
@@ -163,8 +160,10 @@ namespace Terminal.Gui {
 			base.Redraw (bounds);
 
 			var lc = new LineCanvas(Application.Driver);
-	
-			if(IsRootSplitContainer())
+
+			var allLines = GetAllChildSplitContainerLineViewRecursively (this);
+
+			if (IsRootSplitContainer())
 			{
 				if(HasBorder ()) {
 
@@ -175,7 +174,7 @@ namespace Terminal.Gui {
 					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, IntegratedBorder);
 				}
 
-				foreach (var line in GetAllChildSplitContainerLineViewRecursively(this))
+				foreach (var line in allLines)
 				{
 					bool isRoot = line == splitterLine;
 
@@ -203,6 +202,11 @@ namespace Terminal.Gui {
 			Driver.SetAttribute (ColorScheme.Normal);
 			lc.Draw(this,bounds);
 
+			// Redraw the lines so that focus/drag symbol renders
+			foreach(var line in allLines) {
+				line.DrawSplitterSymbol ();
+			}
+
 			// Draw Titles over Border
 			var screen = ViewToScreen (bounds);
 			if (Panel1.Visible && Panel1Title.Length > 0) {
@@ -374,52 +378,7 @@ namespace Terminal.Gui {
 			// this splitter position is fine, there is enough space for everyone
 			return pos;
 		}
-
-		/// <summary>
-		/// A panel within a <see cref="SplitterPanel"/>. 
-		/// </summary>
-		public class SplitterPanel : View {
-			Pos minSize = 1;
-
-			/// <summary>
-			/// Gets or sets the minimum size for the panel.
-			/// </summary>
-			public Pos MinSize { get => minSize;
-				set { 
-					minSize = value;
-					SuperView?.SetNeedsLayout ();
-				} 
-			}
-
-			ustring title = ustring.Empty;
-			/// <summary>
-			/// The title to be displayed for this <see cref="SplitterPanel"/>. The title will be rendered 
-			/// on the top border aligned to the left of the panel.
-			/// </summary>
-			/// <value>The title.</value>
-			public ustring Title {
-				get => title;
-				set {
-					title = value;
-					SetNeedsDisplay ();
-				}
-			}
-
-			/// <inheritdoc/>
-			public override void Redraw (Rect bounds)
-			{
-				Driver.SetAttribute (ColorScheme.Normal);
-				base.Redraw (bounds);
-			}
-
-			/// <inheritdoc/>
-			public override void OnVisibleChanged ()
-			{
-				base.OnVisibleChanged ();
-				SuperView?.SetNeedsLayout ();
-			}
-		}
-
+		
 		private class SplitContainerLineView : LineView {
 			public SplitContainer Parent { get; private set; }
 
@@ -489,6 +448,11 @@ namespace Terminal.Gui {
 			{
 				base.Redraw (bounds);
 
+				DrawSplitterSymbol ();
+			}
+
+			public void DrawSplitterSymbol()
+			{
 				if (CanFocus && HasFocus) {
 					var location = moveRuneRenderLocation ??
 						new Point (Bounds.Width / 2, Bounds.Height / 2);
@@ -553,7 +517,7 @@ namespace Terminal.Gui {
 						dragOrignalPos,
 						Orientation == Orientation.Horizontal ? Y : X);
 					dragPosition = null;
-					//moveRuneRenderLocation = null;
+					moveRuneRenderLocation = null;
 				}
 
 				return false;

+ 2 - 5
UnitTests/SplitContainerTests.cs

@@ -483,7 +483,7 @@ namespace UnitTests {
 
 		private LineView GetSplitContainerLineView (SplitContainer splitContainer)
 		{
-			return splitContainer.Subviews [0].Subviews.OfType<LineView> ().Single ();
+			return splitContainer.Subviews.OfType<LineView> ().Single ();
 		}
 
 		private void SetInputFocusLine (SplitContainer splitContainer)
@@ -508,10 +508,7 @@ namespace UnitTests {
 				Height = 3,
 			};
 
-			if (!withBorder) {
-				container.Border.BorderStyle = BorderStyle.None;
-				container.Border.DrawMarginFrame = false;
-			}
+			container.IntegratedBorder = withBorder ? BorderStyle.Single : BorderStyle.None;
 
 			container.Panel1.Add (new Label (new string ('1', 100)));
 			container.Panel2.Add (new Label (new string ('2', 100)));