From e8c98566653e257948587a934bde03b69416de63 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 23 Mar 2021 09:24:56 +0100 Subject: [PATCH] Fix Vertical/Horizontal panels issue with anchored child controls #378 --- Source/Engine/UI/GUI/Margin.cs | 7 ++++++- Source/Engine/UI/GUI/Panels/HorizontalPanel.cs | 2 +- Source/Engine/UI/GUI/Panels/VerticalPanel.cs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/Engine/UI/GUI/Margin.cs b/Source/Engine/UI/GUI/Margin.cs index 40dab7093..01c0ac3ab 100644 --- a/Source/Engine/UI/GUI/Margin.cs +++ b/Source/Engine/UI/GUI/Margin.cs @@ -47,7 +47,12 @@ namespace FlaxEngine.GUI public float Bottom; /// - /// Gets the margin's total size. Cumulative margin size. + /// Gets the margin's location (Left, Top). + /// + public Vector2 Location => new Vector2(Left, Top); + + /// + /// Gets the margin's total size. Cumulative margin size (Left + Right, Top + Bottom). /// public Vector2 Size => new Vector2(Left + Right, Top + Bottom); diff --git a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs index d7b54a835..4ff92834d 100644 --- a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs +++ b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs @@ -25,7 +25,7 @@ namespace FlaxEngine.GUI for (int i = 0; i < _children.Count; i++) { Control c = _children[i]; - if (c.Visible) + if (c.Visible && Mathf.IsZero(c.AnchorMin.Y) && Mathf.IsZero(c.AnchorMax.Y)) { c.Height = h; } diff --git a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs index 2c821bd3f..b3e51fb86 100644 --- a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs +++ b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs @@ -25,7 +25,7 @@ namespace FlaxEngine.GUI for (int i = 0; i < _children.Count; i++) { Control c = _children[i]; - if (c.Visible) + if (c.Visible && Mathf.IsZero(c.AnchorMin.X) && Mathf.IsZero(c.AnchorMax.X)) { c.Width = w; }