1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-01 23:40:39 +08:00

Merge pull request #35179 from bdach/song-select-scroll-closest-expanded-thing-into-view

Attempt to scroll carousel to nearest expanded panel when the current selection is filtered out
This commit is contained in:
Dean Herbert
2025-10-06 14:42:54 +09:00
committed by GitHub
Unverified
2 changed files with 25 additions and 2 deletions
+7 -2
View File
@@ -876,13 +876,18 @@ namespace osu.Game.Graphics.Carousel
if (!scrollToSelection.IsValid)
{
if (currentKeyboardSelection.YPosition != null)
Scroll.ScrollTo(currentKeyboardSelection.YPosition.Value - visibleHalfHeight + BleedTop);
if (GetScrollTarget() is double scrollTarget)
Scroll.ScrollTo(scrollTarget - visibleHalfHeight + BleedTop);
scrollToSelection.Validate();
}
}
/// <summary>
/// Returns the Y position to scroll to in order to show the most relevant carousel item(s).
/// </summary>
protected virtual double? GetScrollTarget() => currentKeyboardSelection.YPosition;
protected virtual float GetPanelXOffset(Drawable panel)
{
Vector2 posInScroll = Scroll.ToLocalSpace(panel.ScreenSpaceDrawQuad.Centre);
@@ -661,6 +661,24 @@ namespace osu.Game.Screens.SelectV2
}
}
protected override double? GetScrollTarget()
{
double? target = base.GetScrollTarget();
// if the base implementation returned null, it means that the keyboard selection has been filtered out and is no longer visible
// attempt a fallback to other possibly expanded panels (set first, then group)
if (target == null)
{
var items = GetCarouselItems();
var targetItem = items?.FirstOrDefault(i => CheckModelEquality(i.Model, ExpandedBeatmapSet))
?? items?.FirstOrDefault(i => CheckModelEquality(i.Model, ExpandedGroup));
target = targetItem?.CarouselYPosition;
}
return target;
}
#endregion
#region Audio