Browse Source

Merge pull request #3402 from tznind/disable-autosize

Fixes #3366 - Add ability to disable AutoSize
Tig 1 year ago
parent
commit
78bde18d4f
1 changed files with 8 additions and 4 deletions
  1. 8 4
      Terminal.Gui/View/Layout/ViewLayout.cs

+ 8 - 4
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -221,7 +221,8 @@ public partial class View
 
             if (AutoSize)
             {
-                throw new InvalidOperationException (@$"Must set AutoSize to false before setting {nameof (Height)}.");
+                Debug.WriteLine (@$"Must set AutoSize to false before setting {nameof (Height)}.");
+                AutoSize = false;
             }
 
             //if (ValidatePosDim) {
@@ -229,9 +230,10 @@ public partial class View
 
             if (IsAdded && AutoSize && !isValidNewAutoSize)
             {
-                throw new InvalidOperationException (
+                Debug.WriteLine (
                                                      @$"Must set AutoSize to false before setting the {nameof (Height)}."
                                                     );
+                AutoSize = false;
             }
 
             //}
@@ -268,14 +270,16 @@ public partial class View
 
             if (AutoSize)
             {
-                throw new InvalidOperationException (@$"Must set AutoSize to false before setting {nameof (Width)}.");
+                Debug.WriteLine($@"Must set AutoSize to false before setting {nameof(Width)}.");
+                AutoSize = false;
             }
 
             bool isValidNewAutoSize = AutoSize && IsValidAutoSizeWidth (_width);
 
             if (IsAdded && AutoSize && !isValidNewAutoSize)
             {
-                throw new InvalidOperationException (@$"Must set AutoSize to false before setting {nameof (Width)}.");
+                Debug.WriteLine($@"Must set AutoSize to false before setting {nameof(Width)}.");
+                AutoSize = false;
             }
 
             OnResizeNeeded ();