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:
parent
a5aedded16
commit
9384cbcdd8
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user