@@ -80,6 +80,24 @@ namespace FlaxEngine.GUI
|
||||
size.Y = maxHeight;
|
||||
Size = size;
|
||||
}
|
||||
else if (_alignment != TextAlignment.Near && hasAnyLeft)
|
||||
{
|
||||
// Apply layout alignment
|
||||
var offset = Width - left - _margin.Right;
|
||||
if (_alignment == TextAlignment.Center)
|
||||
offset *= 0.5f;
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
Control c = _children[i];
|
||||
if (c.Visible)
|
||||
{
|
||||
if (Mathf.IsZero(c.AnchorMin.X) && Mathf.IsZero(c.AnchorMax.X))
|
||||
{
|
||||
c.X += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,11 @@ namespace FlaxEngine.GUI
|
||||
/// </summary>
|
||||
protected Float2 _offset;
|
||||
|
||||
/// <summary>
|
||||
/// The child controls alignment within layout area.
|
||||
/// </summary>
|
||||
protected TextAlignment _alignment = TextAlignment.Near;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left margin.
|
||||
/// </summary>
|
||||
@@ -172,6 +177,23 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the child controls alignment within layout area.
|
||||
/// </summary>
|
||||
[EditorOrder(50), VisibleIf(nameof(AutoSize), true)]
|
||||
public TextAlignment Alignment
|
||||
{
|
||||
get => _alignment;
|
||||
set
|
||||
{
|
||||
if (_alignment != value)
|
||||
{
|
||||
_alignment = value;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PanelWithMargins"/> class.
|
||||
/// </summary>
|
||||
|
||||
@@ -80,6 +80,24 @@ namespace FlaxEngine.GUI
|
||||
size.X = maxWidth;
|
||||
Size = size;
|
||||
}
|
||||
else if (_alignment != TextAlignment.Near && hasAnyTop)
|
||||
{
|
||||
// Apply layout alignment
|
||||
var offset = Height - top - _margin.Bottom;
|
||||
if (_alignment == TextAlignment.Center)
|
||||
offset *= 0.5f;
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
Control c = _children[i];
|
||||
if (c.Visible)
|
||||
{
|
||||
if (Mathf.IsZero(c.AnchorMin.Y) && Mathf.IsZero(c.AnchorMax.Y))
|
||||
{
|
||||
c.Y += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user