Add resizing panel based on highest child if ControlChildSize is disabled but AutoSize is enabled
#2599 #2511
This commit is contained in:
@@ -42,6 +42,7 @@ namespace FlaxEngine.GUI
|
||||
float left = _margin.Left;
|
||||
float right = _margin.Right;
|
||||
float h = Height - _margin.Height;
|
||||
float maxHeight = h;
|
||||
bool hasAnyLeft = false, hasAnyRight = false;
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
@@ -62,6 +63,7 @@ namespace FlaxEngine.GUI
|
||||
c.Bounds = new Rectangle(Width - right + _offset.X, _margin.Top + _offset.Y, w, ch);
|
||||
hasAnyRight = true;
|
||||
}
|
||||
maxHeight = Mathf.Max(maxHeight, ch);
|
||||
}
|
||||
}
|
||||
if (hasAnyLeft)
|
||||
@@ -71,7 +73,13 @@ namespace FlaxEngine.GUI
|
||||
|
||||
// Update size
|
||||
if (_autoSize)
|
||||
Width = left + right;
|
||||
{
|
||||
var size = Size;
|
||||
size.X = left + right;
|
||||
if (!ControlChildSize)
|
||||
size.Y = maxHeight;
|
||||
Size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace FlaxEngine.GUI
|
||||
float top = _margin.Top;
|
||||
float bottom = _margin.Bottom;
|
||||
float w = Width - _margin.Width;
|
||||
float maxWidth = w;
|
||||
bool hasAnyTop = false, hasAnyBottom = false;
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
@@ -62,6 +63,7 @@ namespace FlaxEngine.GUI
|
||||
c.Bounds = new Rectangle(_margin.Left + _offset.X, Height - bottom + _offset.Y, cw, h);
|
||||
hasAnyBottom = true;
|
||||
}
|
||||
maxWidth = Mathf.Max(maxWidth, cw);
|
||||
}
|
||||
}
|
||||
if (hasAnyTop)
|
||||
@@ -71,7 +73,13 @@ namespace FlaxEngine.GUI
|
||||
|
||||
// Update size
|
||||
if (_autoSize)
|
||||
Height = top + bottom;
|
||||
{
|
||||
var size = Size;
|
||||
size.Y = top + bottom;
|
||||
if (!ControlChildSize)
|
||||
size.X = maxWidth;
|
||||
Size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user