diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs
index b3c0d208f..69f75e3a3 100644
--- a/Terminal.Gui/Core/Toplevel.cs
+++ b/Terminal.Gui/Core/Toplevel.cs
@@ -370,7 +370,7 @@ namespace Terminal.Gui {
l = SuperView.Frame.Width;
}
nx = nx + top.Frame.Width > l ? Math.Max (l - top.Frame.Width, 0) : nx;
- SetWidth (top.Frame.Width, out int rWidth, out _);
+ SetWidth (top.Frame.Width, out int rWidth);
if (rWidth < 0 && nx >= top.Frame.X) {
nx = Math.Max (top.Frame.Right - 2, 0);
}
@@ -399,7 +399,7 @@ namespace Terminal.Gui {
}
ny = Math.Min (ny, l);
ny = ny + top.Frame.Height > l ? Math.Max (l - top.Frame.Height, m ? 1 : 0) : ny;
- SetHeight (top.Frame.Height, out int rHeight, out _);
+ SetHeight (top.Frame.Height, out int rHeight);
if (rHeight < 0 && ny >= top.Frame.Y) {
ny = Math.Max (top.Frame.Bottom - 2, 0);
}
diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs
index 53a95ed1c..6d7a5ef4c 100644
--- a/Terminal.Gui/Core/View.cs
+++ b/Terminal.Gui/Core/View.cs
@@ -2188,14 +2188,7 @@ namespace Terminal.Gui {
return true;
}
- ///
- /// Calculate the width based on the settings.
- ///
- /// The desired width.
- /// The real result width.
- /// The real current width.
- /// True if the width can be directly assigned, false otherwise.
- public bool SetWidth (int desiredWidth, out int resultWidth, out int currentWidth)
+ bool CanSetWidth (int desiredWidth, out int resultWidth, out int currentWidth)
{
int w = desiredWidth;
currentWidth = Width != null ? Width.Anchor (0) : 0;
@@ -2222,14 +2215,7 @@ namespace Terminal.Gui {
return canSetWidth;
}
- ///
- /// Calculate the height based on the settings.
- ///
- /// The desired height.
- /// The real result height.
- /// The real current height.
- /// True if the height can be directly assigned, false otherwise.
- public bool SetHeight (int desiredHeight, out int resultHeight, out int currentHeight)
+ bool CanSetHeight (int desiredHeight, out int resultHeight, out int currentHeight)
{
int h = desiredHeight;
currentHeight = Height != null ? Height.Anchor (0) : 0;
@@ -2255,5 +2241,47 @@ namespace Terminal.Gui {
return canSetHeight;
}
+
+ ///
+ /// Calculate the width based on the settings.
+ ///
+ /// The desired width.
+ /// The real result width.
+ /// true if the width can be directly assigned, false otherwise.
+ public bool SetWidth (int desiredWidth, out int resultWidth)
+ {
+ return CanSetWidth (desiredWidth, out resultWidth, out _);
+ }
+
+ ///
+ /// Calculate the height based on the settings.
+ ///
+ /// The desired height.
+ /// The real result height.
+ /// true if the height can be directly assigned, false otherwise.
+ public bool SetHeight (int desiredHeight, out int resultHeight)
+ {
+ return CanSetHeight (desiredHeight, out resultHeight, out _);
+ }
+
+ ///
+ /// Gets the current width based on the settings.
+ ///
+ /// The real current width.
+ /// true if the width can be directly assigned, false otherwise.
+ public bool GetCurrentWidth (out int currentWidth)
+ {
+ return CanSetWidth (0, out _, out currentWidth);
+ }
+
+ ///
+ /// Calculate the height based on the settings.
+ ///
+ /// The real current height.
+ /// true if the height can be directly assigned, false otherwise.
+ public bool GetCurrentHeight (out int currentHeight)
+ {
+ return CanSetHeight (0, out _, out currentHeight);
+ }
}
}
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index f0685f636..3a2ba7715 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -146,7 +146,8 @@ namespace Terminal.Gui {
base.Text = ustring.Make (_leftBracket) + " " + text + " " + ustring.Make (_rightBracket);
int w = base.Text.RuneCount - (base.Text.Contains (HotKeySpecifier) ? 1 : 0);
- var canSetWidth = SetWidth (w, out int rWidth, out int cWidth);
+ GetCurrentWidth (out int cWidth);
+ var canSetWidth = SetWidth (w, out int rWidth);
if (canSetWidth && (cWidth < rWidth || AutoSize)) {
Width = rWidth;
w = rWidth;