1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:03:13 +08:00

Ensure selected playlist item is always scrolled into view

This commit is contained in:
Bartłomiej Dach 2022-05-04 13:15:26 +02:00
parent ec27fa8e85
commit 0405c1c34a
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -173,6 +174,21 @@ namespace osu.Game.Screens.OnlinePlay
protected virtual DrawableRoomPlaylistItem CreateDrawablePlaylistItem(PlaylistItem item) => new DrawableRoomPlaylistItem(item);
protected override void LoadComplete()
{
base.LoadComplete();
SelectedItem.BindValueChanged(_ => scrollToSelection(), true);
}
private void scrollToSelection()
{
if (SelectedItem.Value == null) return;
Debug.Assert(ItemMap.TryGetValue(SelectedItem.Value, out var drawableItem));
ScrollContainer.ScrollIntoView(drawableItem);
}
#region Key selection logic (shared with BeatmapCarousel and RoomsContainer)
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)