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;
|
size.X = _textSize.X + Margin.Width;
|
||||||
if (_autoHeight)
|
if (_autoHeight)
|
||||||
size.Y = _textSize.Y + Margin.Height;
|
size.Y = _textSize.Y + Margin.Height;
|
||||||
var pivotRelative = PivotRelative;
|
Resize(ref size);
|
||||||
Size = size;
|
|
||||||
PivotRelative = pivotRelative;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
/// <summary>
|
||||||
/// Updates the control cached bounds (based on anchors and offsets).
|
/// Updates the control cached bounds (based on anchors and offsets).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -585,7 +585,8 @@ namespace FlaxEngine.GUI
|
|||||||
_cachedHeight = height;
|
_cachedHeight = height;
|
||||||
if (_animationProgress >= 1.0f && _isClosed)
|
if (_animationProgress >= 1.0f && _isClosed)
|
||||||
y = minHeight;
|
y = minHeight;
|
||||||
Height = Mathf.Max(minHeight, y);
|
var size = new Float2(Width, Mathf.Max(minHeight, y));
|
||||||
|
Resize(ref size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace FlaxEngine.GUI
|
|||||||
size.X = left + right;
|
size.X = left + right;
|
||||||
if (!ControlChildSize)
|
if (!ControlChildSize)
|
||||||
size.Y = maxHeight;
|
size.Y = maxHeight;
|
||||||
Size = size;
|
Resize(ref size);
|
||||||
}
|
}
|
||||||
else if (_alignment != TextAlignment.Near && hasAnyLeft)
|
else if (_alignment != TextAlignment.Near && hasAnyLeft)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace FlaxEngine.GUI
|
|||||||
size.Y = top + bottom;
|
size.Y = top + bottom;
|
||||||
if (!ControlChildSize)
|
if (!ControlChildSize)
|
||||||
size.X = maxWidth;
|
size.X = maxWidth;
|
||||||
Size = size;
|
Resize(ref size);
|
||||||
}
|
}
|
||||||
else if (_alignment != TextAlignment.Near && hasAnyTop)
|
else if (_alignment != TextAlignment.Near && hasAnyTop)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user