Fix UI Controls layout auto-resizing to always use pivot-relative logic
#3031
This commit is contained in:
@@ -337,9 +337,7 @@ namespace FlaxEngine.GUI
|
||||
size.X = _textSize.X + Margin.Width;
|
||||
if (_autoHeight)
|
||||
size.Y = _textSize.Y + Margin.Height;
|
||||
var pivotRelative = PivotRelative;
|
||||
Size = size;
|
||||
PivotRelative = pivotRelative;
|
||||
Resize(ref size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,6 +419,19 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the control based on where the pivot is rather than just the top-left.
|
||||
/// </summary>
|
||||
[NoAnimate]
|
||||
public void Resize(ref Float2 value)
|
||||
{
|
||||
if (_bounds.Size.Equals(ref value))
|
||||
return;
|
||||
var bounds = new Rectangle(_bounds.Location, value);
|
||||
bounds.Location += (_bounds.Size - value) * Pivot; // Pivot-relative resizing
|
||||
SetBounds(ref bounds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the control cached bounds (based on anchors and offsets).
|
||||
/// </summary>
|
||||
|
||||
@@ -585,7 +585,8 @@ namespace FlaxEngine.GUI
|
||||
_cachedHeight = height;
|
||||
if (_animationProgress >= 1.0f && _isClosed)
|
||||
y = minHeight;
|
||||
Height = Mathf.Max(minHeight, y);
|
||||
var size = new Float2(Width, Mathf.Max(minHeight, y));
|
||||
Resize(ref size);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace FlaxEngine.GUI
|
||||
size.X = left + right;
|
||||
if (!ControlChildSize)
|
||||
size.Y = maxHeight;
|
||||
Size = size;
|
||||
Resize(ref size);
|
||||
}
|
||||
else if (_alignment != TextAlignment.Near && hasAnyLeft)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace FlaxEngine.GUI
|
||||
size.Y = top + bottom;
|
||||
if (!ControlChildSize)
|
||||
size.X = maxWidth;
|
||||
Size = size;
|
||||
Resize(ref size);
|
||||
}
|
||||
else if (_alignment != TextAlignment.Near && hasAnyTop)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user