From 7bfe44de077f906b05c6450efda72ad057fa20e8 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 14 Oct 2023 17:05:41 +0200 Subject: [PATCH] fixed 0571e8a not updating older panels correctly --- MLEM.Ui/Elements/Panel.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index d5006ea..0ab70ed 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -56,7 +56,7 @@ namespace MLEM.Ui.Elements { private readonly List relevantChildren = new List(); private readonly HashSet scrolledChildren = new HashSet(); - private readonly float[] scrollBarMaxHistory = new float[3]; + private readonly List scrollBarMaxHistory = new List(); private readonly bool scrollOverflow; private RenderTarget2D renderTarget; @@ -113,7 +113,7 @@ namespace MLEM.Ui.Elements { } base.ForceUpdateArea(); - Array.Clear(this.scrollBarMaxHistory, 0, this.scrollBarMaxHistory.Length); + this.scrollBarMaxHistory.Clear(); this.SetScrollBarStyle(); } @@ -278,10 +278,10 @@ namespace MLEM.Ui.Elements { var scrollBarMax = Math.Max(0, (childrenHeight - this.ChildPaddedArea.Height) / this.Scale); if (!this.ScrollBar.MaxValue.Equals(scrollBarMax, Element.Epsilon)) { // avoid a show/hide oscillation that occurs while updating our area with children that can lose height when the scroll bar is shown (like long paragraphs) - if (!this.scrollBarMaxHistory[0].Equals(this.scrollBarMaxHistory[2], Element.Epsilon) || !this.scrollBarMaxHistory[1].Equals(scrollBarMax, Element.Epsilon)) { - this.scrollBarMaxHistory[0] = this.scrollBarMaxHistory[1]; - this.scrollBarMaxHistory[1] = this.scrollBarMaxHistory[2]; - this.scrollBarMaxHistory[2] = scrollBarMax; + if (this.scrollBarMaxHistory.Count < 3 || !this.scrollBarMaxHistory[0].Equals(this.scrollBarMaxHistory[2], Element.Epsilon) || !this.scrollBarMaxHistory[1].Equals(scrollBarMax, Element.Epsilon)) { + if (this.scrollBarMaxHistory.Count > 0) + this.scrollBarMaxHistory.RemoveAt(0); + this.scrollBarMaxHistory.Add(scrollBarMax); this.ScrollBar.MaxValue = scrollBarMax; this.relevantChildrenDirty = true;