Skip to content

Commit

Permalink
Merge pull request gui-cs#3402 from tznind/disable-autosize
Browse files Browse the repository at this point in the history
Fixes gui-cs#3366 - Add ability to disable AutoSize
  • Loading branch information
tig authored Apr 14, 2024
2 parents f1bc42a + fadecc1 commit 78bde18
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Terminal.Gui/View/Layout/ViewLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,19 @@ public Dim Height

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) {
bool isValidNewAutoSize = AutoSize && IsValidAutoSizeHeight (_height);

if (IsAdded && AutoSize && !isValidNewAutoSize)
{
throw new InvalidOperationException (
Debug.WriteLine (
@$"Must set AutoSize to false before setting the {nameof (Height)}."
);
AutoSize = false;
}

//}
Expand Down Expand Up @@ -268,14 +270,16 @@ public Dim Width

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 ();
Expand Down

0 comments on commit 78bde18

Please sign in to comment.