1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:57:24 +08:00

Fix scroll-into-view on control point table not working as it is supposed to

This commit is contained in:
Bartłomiej Dach 2024-06-27 09:46:35 +02:00
parent a5aedded16
commit 9384cbcdd8
No known key found for this signature in database

View File

@ -100,9 +100,20 @@ namespace osu.Game.Screens.Edit.Timing
selectedGroup.BindValueChanged(val =>
{
// can't use `.ScrollIntoView()` here because of the list virtualisation not giving
// child items valid coordinates from the start, so ballpark something similar
// using estimated row height.
var row = Items.FlowingChildren.SingleOrDefault(item => item.Row.Equals(val.NewValue));
if (row != null)
Scroll.ScrollIntoView(row);
if (row == null)
return;
float minPos = Items.GetLayoutPosition(row) * row_height;
float maxPos = minPos + row_height;
if (minPos < Scroll.Current)
Scroll.ScrollTo(minPos);
else if (maxPos > Scroll.Current + Scroll.DisplayableContent)
Scroll.ScrollTo(maxPos - Scroll.DisplayableContent);
});
}
}