diff --git a/CHANGELOG.md b/CHANGELOG.md index b435f63..5d36f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Improvements - Added style properties for a lot of hardcoded default element styles - Allow style properties to set style values with a higher priority, which allows elements to style their default children - Allow changing the entire ui style for a single element +- Skip unnecessary area updates for elements with dirty parents Fixes - Fixed VerticalSpace height parameter being an integer diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index 19bfa3a..c468aaa 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -531,6 +531,12 @@ namespace MLEM.Ui.Elements { this.areaDirty = false; if (this.IsHidden) return; + // if the parent's area is dirty, it would get updated anyway when querying its ChildPaddedArea, + // which would cause our ForceUpdateArea code to be run twice, so we only update our parent instead + if (this.Parent != null && this.Parent.areaDirty) { + this.Parent.ForceUpdateArea(); + return; + } var parentArea = this.Parent != null ? this.Parent.ChildPaddedArea : (RectangleF) this.system.Viewport; var parentCenterX = parentArea.X + parentArea.Width / 2;