|
@@ -2098,17 +2098,20 @@ namespace Terminal.Gui {
|
|
|
|
|
|
bool SetWidthHeight (Rect nBounds)
|
|
bool SetWidthHeight (Rect nBounds)
|
|
{
|
|
{
|
|
- bool aSize;
|
|
|
|
|
|
+ bool aSize = false;
|
|
var canSizeW = SetWidth (nBounds.Width, out int rW);
|
|
var canSizeW = SetWidth (nBounds.Width, out int rW);
|
|
var canSizeH = SetHeight (nBounds.Height, out int rH);
|
|
var canSizeH = SetHeight (nBounds.Height, out int rH);
|
|
- if (canSizeW && canSizeH) {
|
|
|
|
|
|
+ if (canSizeW) {
|
|
aSize = true;
|
|
aSize = true;
|
|
- Bounds = nBounds;
|
|
|
|
width = rW;
|
|
width = rW;
|
|
|
|
+ }
|
|
|
|
+ if (canSizeH) {
|
|
|
|
+ aSize = true;
|
|
height = rH;
|
|
height = rH;
|
|
|
|
+ }
|
|
|
|
+ if (aSize) {
|
|
|
|
+ Bounds = new Rect (Bounds.X, Bounds.Y, canSizeW ? rW : Bounds.Width, canSizeH ? rH : Bounds.Height);
|
|
textFormatter.Size = Bounds.Size;
|
|
textFormatter.Size = Bounds.Size;
|
|
- } else {
|
|
|
|
- aSize = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return aSize;
|
|
return aSize;
|
|
@@ -2266,15 +2269,13 @@ namespace Terminal.Gui {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- bool CanSetWidth (int desiredWidth, out int resultWidth, out int currentWidth)
|
|
|
|
|
|
+ bool CanSetWidth (int desiredWidth, out int resultWidth)
|
|
{
|
|
{
|
|
int w = desiredWidth;
|
|
int w = desiredWidth;
|
|
- currentWidth = Width != null ? Width.Anchor (0) : 0;
|
|
|
|
bool canSetWidth;
|
|
bool canSetWidth;
|
|
if (Width is Dim.DimCombine || Width is Dim.DimView || Width is Dim.DimFill) {
|
|
if (Width is Dim.DimCombine || Width is Dim.DimView || Width is Dim.DimFill) {
|
|
// It's a Dim.DimCombine and so can't be assigned. Let it have it's width anchored.
|
|
// It's a Dim.DimCombine and so can't be assigned. Let it have it's width anchored.
|
|
w = Width.Anchor (w);
|
|
w = Width.Anchor (w);
|
|
- currentWidth = Width.Anchor (w);
|
|
|
|
canSetWidth = false;
|
|
canSetWidth = false;
|
|
} else if (Width is Dim.DimFactor factor) {
|
|
} else if (Width is Dim.DimFactor factor) {
|
|
// Tries to get the SuperView width otherwise the view width.
|
|
// Tries to get the SuperView width otherwise the view width.
|
|
@@ -2283,7 +2284,6 @@ namespace Terminal.Gui {
|
|
sw -= Frame.X;
|
|
sw -= Frame.X;
|
|
}
|
|
}
|
|
w = Width.Anchor (sw);
|
|
w = Width.Anchor (sw);
|
|
- currentWidth = Width.Anchor (sw);
|
|
|
|
canSetWidth = false;
|
|
canSetWidth = false;
|
|
} else {
|
|
} else {
|
|
canSetWidth = true;
|
|
canSetWidth = true;
|
|
@@ -2293,15 +2293,13 @@ namespace Terminal.Gui {
|
|
return canSetWidth;
|
|
return canSetWidth;
|
|
}
|
|
}
|
|
|
|
|
|
- bool CanSetHeight (int desiredHeight, out int resultHeight, out int currentHeight)
|
|
|
|
|
|
+ bool CanSetHeight (int desiredHeight, out int resultHeight)
|
|
{
|
|
{
|
|
int h = desiredHeight;
|
|
int h = desiredHeight;
|
|
- currentHeight = Height != null ? Height.Anchor (0) : 0;
|
|
|
|
bool canSetHeight;
|
|
bool canSetHeight;
|
|
if (Height is Dim.DimCombine || Height is Dim.DimView || Height is Dim.DimFill) {
|
|
if (Height is Dim.DimCombine || Height is Dim.DimView || Height is Dim.DimFill) {
|
|
// It's a Dim.DimCombine and so can't be assigned. Let it have it's height anchored.
|
|
// It's a Dim.DimCombine and so can't be assigned. Let it have it's height anchored.
|
|
h = Height.Anchor (h);
|
|
h = Height.Anchor (h);
|
|
- currentHeight = Height.Anchor (h);
|
|
|
|
canSetHeight = false;
|
|
canSetHeight = false;
|
|
} else if (Height is Dim.DimFactor factor) {
|
|
} else if (Height is Dim.DimFactor factor) {
|
|
// Tries to get the SuperView height otherwise the view height.
|
|
// Tries to get the SuperView height otherwise the view height.
|
|
@@ -2310,7 +2308,6 @@ namespace Terminal.Gui {
|
|
sh -= Frame.Y;
|
|
sh -= Frame.Y;
|
|
}
|
|
}
|
|
h = Height.Anchor (sh);
|
|
h = Height.Anchor (sh);
|
|
- currentHeight = Height.Anchor (sh);
|
|
|
|
canSetHeight = false;
|
|
canSetHeight = false;
|
|
} else {
|
|
} else {
|
|
canSetHeight = true;
|
|
canSetHeight = true;
|
|
@@ -2328,7 +2325,7 @@ namespace Terminal.Gui {
|
|
/// <returns><c>true</c> if the width can be directly assigned, <c>false</c> otherwise.</returns>
|
|
/// <returns><c>true</c> if the width can be directly assigned, <c>false</c> otherwise.</returns>
|
|
public bool SetWidth (int desiredWidth, out int resultWidth)
|
|
public bool SetWidth (int desiredWidth, out int resultWidth)
|
|
{
|
|
{
|
|
- return CanSetWidth (desiredWidth, out resultWidth, out _);
|
|
|
|
|
|
+ return CanSetWidth (desiredWidth, out resultWidth);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -2339,7 +2336,7 @@ namespace Terminal.Gui {
|
|
/// <returns><c>true</c> if the height can be directly assigned, <c>false</c> otherwise.</returns>
|
|
/// <returns><c>true</c> if the height can be directly assigned, <c>false</c> otherwise.</returns>
|
|
public bool SetHeight (int desiredHeight, out int resultHeight)
|
|
public bool SetHeight (int desiredHeight, out int resultHeight)
|
|
{
|
|
{
|
|
- return CanSetHeight (desiredHeight, out resultHeight, out _);
|
|
|
|
|
|
+ return CanSetHeight (desiredHeight, out resultHeight);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -2349,7 +2346,10 @@ namespace Terminal.Gui {
|
|
/// <returns><c>true</c> if the width can be directly assigned, <c>false</c> otherwise.</returns>
|
|
/// <returns><c>true</c> if the width can be directly assigned, <c>false</c> otherwise.</returns>
|
|
public bool GetCurrentWidth (out int currentWidth)
|
|
public bool GetCurrentWidth (out int currentWidth)
|
|
{
|
|
{
|
|
- return CanSetWidth (0, out _, out currentWidth);
|
|
|
|
|
|
+ SetRelativeLayout (SuperView == null ? Frame : SuperView.Frame);
|
|
|
|
+ currentWidth = Frame.Width;
|
|
|
|
+
|
|
|
|
+ return CanSetWidth (0, out _);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -2359,7 +2359,10 @@ namespace Terminal.Gui {
|
|
/// <returns><c>true</c> if the height can be directly assigned, <c>false</c> otherwise.</returns>
|
|
/// <returns><c>true</c> if the height can be directly assigned, <c>false</c> otherwise.</returns>
|
|
public bool GetCurrentHeight (out int currentHeight)
|
|
public bool GetCurrentHeight (out int currentHeight)
|
|
{
|
|
{
|
|
- return CanSetHeight (0, out _, out currentHeight);
|
|
|
|
|
|
+ SetRelativeLayout (SuperView == null ? Frame : SuperView.Frame);
|
|
|
|
+ currentHeight = Frame.Height;
|
|
|
|
+
|
|
|
|
+ return CanSetHeight (0, out _);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|