Skip to content

Commit

Permalink
Fix scroll-into-view on control point table not working as it is supp…
Browse files Browse the repository at this point in the history
…osed to
  • Loading branch information
bdach committed Jun 27, 2024
1 parent a5aedde commit 9384cbc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions osu.Game/Screens/Edit/Timing/ControlPointTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,20 @@ protected override void LoadComplete()

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);
});
}
}
Expand Down

0 comments on commit 9384cbc

Please sign in to comment.