From 281a6f7588501465c5e4de53fd14e6bc8bb328f5 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 14 Oct 2023 17:22:05 +0200 Subject: [PATCH] Revert "fixed 0571e8a not updating older panels correctly" This reverts commit 7bfe44de077f906b05c6450efda72ad057fa20e8. --- 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 0ab70ed..d5006ea 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 List scrollBarMaxHistory = new List(); + private readonly float[] scrollBarMaxHistory = new float[3]; private readonly bool scrollOverflow; private RenderTarget2D renderTarget; @@ -113,7 +113,7 @@ namespace MLEM.Ui.Elements { } base.ForceUpdateArea(); - this.scrollBarMaxHistory.Clear(); + Array.Clear(this.scrollBarMaxHistory, 0, this.scrollBarMaxHistory.Length); 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.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); + 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; this.ScrollBar.MaxValue = scrollBarMax; this.relevantChildrenDirty = true;