From fe46722d55420eee4c680f94c1e51b7891a2674f Mon Sep 17 00:00:00 2001 From: Alek-ban Date: Thu, 5 Mar 2026 07:36:17 +0300 Subject: [PATCH] fix: SectionPanel resizing --- GSS2.UI.Core/SectionPanel.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/GSS2.UI.Core/SectionPanel.cs b/GSS2.UI.Core/SectionPanel.cs index 99db317..3107afe 100644 --- a/GSS2.UI.Core/SectionPanel.cs +++ b/GSS2.UI.Core/SectionPanel.cs @@ -94,7 +94,6 @@ public class SectionPanel : Panel private readonly Dictionary _childIndeces = new Dictionary(); private bool _initialized = false; private int _previousIndex = 0; - private bool _isChangingIndex = false; public SectionPanel() : base() @@ -105,7 +104,6 @@ public class SectionPanel : Panel return; panel.CanScrollBackward = panel.Cyclic || panel.CurrentIndex != 0; panel.CanScrollForward = panel.Cyclic || panel.CurrentIndex != panel.Children.Count() - 1; - _isChangingIndex = true; panel.InvalidateArrange(); }); ChildrenSourceProperty.Changed.AddClassHandler((panel, ea) => @@ -309,21 +307,21 @@ public class SectionPanel : Panel _initialized = true; } - if (!_isChangingIndex) + if (_previousIndex == CurrentIndex) + { foreach (var (child, i) in _childIndeces) { var rect = Orientation switch { - Orientation.Vertical => new Rect(0, (i - _previousIndex) * finalSize.Height, finalSize.Width, finalSize.Height), - Orientation.Horizontal => new Rect((i - _previousIndex) * finalSize.Width, 0, finalSize.Width, finalSize.Height), + Orientation.Vertical => new Rect(0, i * finalSize.Height, finalSize.Width, finalSize.Height), + Orientation.Horizontal => new Rect(i * finalSize.Width, 0, finalSize.Width, finalSize.Height), _ => default }; child.Arrange(rect); } - if (Children.Count() > 1) + } + else if (Children.Count() > 1) Dispatcher.UIThread.Post(async () => _ = ApplyOffset(finalSize, true), DispatcherPriority.Render); - - _isChangingIndex = false; return finalSize; }