@@ -80,6 +80,24 @@ namespace FlaxEngine.GUI
|
|||||||
size.Y = maxHeight;
|
size.Y = maxHeight;
|
||||||
Size = size;
|
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>
|
/// </summary>
|
||||||
protected Float2 _offset;
|
protected Float2 _offset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The child controls alignment within layout area.
|
||||||
|
/// </summary>
|
||||||
|
protected TextAlignment _alignment = TextAlignment.Near;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the left margin.
|
/// Gets or sets the left margin.
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PanelWithMargins"/> class.
|
/// Initializes a new instance of the <see cref="PanelWithMargins"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -80,6 +80,24 @@ namespace FlaxEngine.GUI
|
|||||||
size.X = maxWidth;
|
size.X = maxWidth;
|
||||||
Size = size;
|
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