Merge branch 'control-child-size-update' of https://github.com/Swiggies/FlaxEngine into Swiggies-control-child-size-update
This commit is contained in:
@@ -44,6 +44,11 @@ namespace FlaxEngine.GUI
|
||||
float h = Height - _margin.Height;
|
||||
float maxHeight = h;
|
||||
bool hasAnyLeft = false, hasAnyRight = false;
|
||||
|
||||
float totalGaps = (_children.Count - 1) * Spacing;
|
||||
float availableWidth = Width - totalGaps - LeftMargin - RightMargin;
|
||||
float itemWidth = availableWidth / _children.Count;
|
||||
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
Control c = _children[i];
|
||||
@@ -64,6 +69,11 @@ namespace FlaxEngine.GUI
|
||||
hasAnyRight = true;
|
||||
}
|
||||
maxHeight = Mathf.Max(maxHeight, ch);
|
||||
|
||||
if (ExpandChildren)
|
||||
{
|
||||
c.Width = itemWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasAnyLeft)
|
||||
|
||||
@@ -173,6 +173,12 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value indicating whenever the panel can resize children controls (eg. auto-fit width/height).
|
||||
/// </summary>
|
||||
[EditorOrder(36), DefaultValue(false), Tooltip("If checked, the panel will expand all children in the relevant direction with even spacing and size. (Horizontally for Horizontal Panel, Vertically for Vertical Panel).")]
|
||||
public bool ExpandChildren { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the panel area margin.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Copyright (c) Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.Globalization;
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
@@ -44,6 +46,11 @@ namespace FlaxEngine.GUI
|
||||
float w = Width - _margin.Width;
|
||||
float maxWidth = w;
|
||||
bool hasAnyTop = false, hasAnyBottom = false;
|
||||
|
||||
float totalGaps = (_children.Count - 1) * Spacing;
|
||||
float availableHeight = Height - totalGaps - TopMargin - BottomMargin;
|
||||
float itemHeight = availableHeight / _children.Count;
|
||||
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
Control c = _children[i];
|
||||
@@ -64,6 +71,11 @@ namespace FlaxEngine.GUI
|
||||
hasAnyBottom = true;
|
||||
}
|
||||
maxWidth = Mathf.Max(maxWidth, cw);
|
||||
|
||||
if (ExpandChildren)
|
||||
{
|
||||
c.Height = itemHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasAnyTop)
|
||||
|
||||
Reference in New Issue
Block a user