move scroller bounds to be set in Open()

This commit is contained in:
neilmjain committed 2026-10-22 19:26:07 -04:00
1 parent 13864b8fd9
commit 0596278b78
1 file changed
+8 -3
+8 -3
View File
@@ -74,6 +74,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
protected int TabIndex => LocalSettingsManager.Tabs.IndexOf(this) + 10;
private Scroller? Scroller { get; set; }
private float MaxScroll { get; set; }
/// <summary>
/// Invoked when an option value is changed.
@@ -104,6 +105,12 @@ public abstract class LocalSettingsTab(ConfigFile config)
label.Key.text =
$"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{label.Value.Translate()}</b></font>";
}
if (Scroller != null)
{
Scroller.SetBounds(new FloatRange(0, MaxScroll), new FloatRange(0, 0));
Scroller.ScrollToTop();
}
}
/// <summary>
@@ -222,9 +229,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
const float extraPadding = 0.25f;
var itemRange = (Settings.Count + Buttons.Count) * 0.5f - visibleHeight;
var offsetRange = contentOffset - visibleHeight + extraPadding;
var maxScroll = Mathf.Max(0f, itemRange, offsetRange);
Scroller.SetBounds(new FloatRange(0, maxScroll), new FloatRange(0, 0));
Scroller.ScrollToTop();
MaxScroll = Mathf.Max(0f, itemRange, offsetRange);
return tab;
}