From a9a7f2b421b28287a3ef39d345995d4b95a71fdb Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 5 Aug 2021 03:47:03 +0200 Subject: [PATCH] Revert "(attempt to) reduce element sizing incompatibilities for auto-width/height elements" This reverts commit 094de058c4dadcb4f3f7ca153fa44f9433e2eaaf. --- CHANGELOG.md | 1 - MLEM.Ui/Elements/Element.cs | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa1ad9d..5ecf16e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,6 @@ Improvements - Removed LINQ Any and All usage in various methods to improve memory usage - Explicitly disallow creating Paragraphs without fonts to make starting out with MLEM.Ui less confusing - Allow adding Link children to non-Paragraph elements -- Reduce sizing incompatibilities by ignoring percentage-based width and height for elements that set their width and height based on their children Fixes - Fixed a crash if a paragraph has a link formatting code, but no font diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index bf52c46..689c75e 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -693,11 +693,11 @@ namespace MLEM.Ui.Elements { /// The actual size of this element, taking into account protected virtual Vector2 CalcActualSize(RectangleF parentArea) { var ret = new Vector2( - this.size.X > 1 && !this.SetWidthBasedOnChildren ? this.ScaledSize.X : parentArea.Width * this.size.X, - this.size.Y > 1 && !this.SetHeightBasedOnChildren ? this.ScaledSize.Y : parentArea.Height * this.size.Y); - if (this.size.X < 0 && !this.SetWidthBasedOnChildren) + this.size.X > 1 ? this.ScaledSize.X : parentArea.Width * this.size.X, + this.size.Y > 1 ? this.ScaledSize.Y : parentArea.Height * this.size.Y); + if (this.size.X < 0) ret.X = -this.size.X * ret.Y; - if (this.size.Y < 0 && !this.SetHeightBasedOnChildren) + if (this.size.Y < 0) ret.Y = -this.size.Y * ret.X; return ret; }