瀏覽代碼

Fixed CheckDimAuto

Tig Kindel 1 年之前
父節點
當前提交
fab7f17373
共有 3 個文件被更改,包括 8 次插入4 次删除
  1. 5 3
      Terminal.Gui/View/Layout/ViewLayout.cs
  2. 1 0
      Terminal.Gui/View/ViewSubViews.cs
  3. 2 1
      UnitTests/View/Layout/DimAutoTests.cs

+ 5 - 3
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -432,13 +432,13 @@ public partial class View {
 	public bool ValidatePosDim { get; set; }
 	public bool ValidatePosDim { get; set; }
 
 
 	/// <summary>
 	/// <summary>
-	/// Throws an <see cref="InvalidOperationException"/> if any of the SubViews are using Dim objects that depend on this
+	/// Throws an <see cref="InvalidOperationException"/> if any SubViews are using Dim objects that depend on this
 	/// Views dimensions.
 	/// Views dimensions.
 	/// </summary>
 	/// </summary>
 	/// <exception cref="InvalidOperationException"></exception>
 	/// <exception cref="InvalidOperationException"></exception>
 	void CheckDimAuto ()
 	void CheckDimAuto ()
 	{
 	{
-		if (!ValidatePosDim || !IsInitialized || Width is not Dim.DimAuto && Height is not Dim.DimAuto) {
+		if (!ValidatePosDim && Width is not Dim.DimAuto && Height is not Dim.DimAuto) {
 			return;
 			return;
 		}
 		}
 
 
@@ -632,6 +632,8 @@ public partial class View {
 	/// </remarks>
 	/// </remarks>
 	internal void OnResizeNeeded ()
 	internal void OnResizeNeeded ()
 	{
 	{
+		SuperView?.CheckDimAuto ();
+		
 		// TODO: Identify a real-world use-case where this API should be virtual. 
 		// TODO: Identify a real-world use-case where this API should be virtual. 
 		// TODO: Until then leave it `internal` and non-virtual
 		// TODO: Until then leave it `internal` and non-virtual
 		// First try SuperView.Bounds, then Application.Top, then Driver.Bounds.
 		// First try SuperView.Bounds, then Application.Top, then Driver.Bounds.
@@ -641,7 +643,7 @@ public partial class View {
 										   Application.Driver?.Bounds ??
 										   Application.Driver?.Bounds ??
 										   new Rect (0, 0, int.MaxValue, int.MaxValue);
 										   new Rect (0, 0, int.MaxValue, int.MaxValue);
 		SetRelativeLayout (relativeBounds);
 		SetRelativeLayout (relativeBounds);
-
+		
 		// TODO: Determine what, if any of the below is actually needed here.
 		// TODO: Determine what, if any of the below is actually needed here.
 		if (IsInitialized) {
 		if (IsInitialized) {
 			SetFrameToFitText ();
 			SetFrameToFitText ();

+ 1 - 0
Terminal.Gui/View/ViewSubViews.cs

@@ -89,6 +89,7 @@ public partial class View {
 			view.EndInit ();
 			view.EndInit ();
 		}
 		}
 
 
+		CheckDimAuto ();
 		SetNeedsLayout ();
 		SetNeedsLayout ();
 		SetNeedsDisplay ();
 		SetNeedsDisplay ();
 	}
 	}

+ 2 - 1
UnitTests/View/Layout/DimAutoTests.cs

@@ -184,7 +184,8 @@ public class DimAutoTests {
 			X = 0,
 			X = 0,
 			Y = 0,
 			Y = 0,
 			Width = Dim.Fill (),
 			Width = Dim.Fill (),
-			Height = 10
+			Height = 10,
+			ValidatePosDim = true,
 		};
 		};
 
 
 		superView.BeginInit ();
 		superView.BeginInit ();