Add resizing panel based on highest child if ControlChildSize is disabled but AutoSize is enabled

#2599 #2511
This commit is contained in:
Wojtek Figat
2024-09-18 23:37:05 +02:00
parent 596b61b23f
commit fb4b0b2f75
2 changed files with 18 additions and 2 deletions

View File

@@ -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;
}
}
}
}

View File

@@ -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;
}
}
}
}