1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-28 03:53:45 +08:00

Fix carousel handling of bleed areas

The idea of specifying "bleed" is to make the carousel aware of its
vertical display area. The top bleed is under the filter control; bottom
beneath the toolbar. At the end of the day, the point of panel X offset
incursion, and the scroll target for current selection, should be at the
centre of the screen.

The fixes match code which already exists in the previous
implementation. Basically, without incorporating `BleedTop` into
calculations a second time, the centre position would not match
expectations (of being the centre including bleed).
This commit is contained in:
Dean Herbert
2025-04-10 17:42:17 +09:00
Unverified
parent 244bae5d43
commit f9112066d3
2 changed files with 11 additions and 5 deletions
@@ -96,6 +96,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Carousel = new BeatmapCarousel
{
BleedTop = 200,
BleedBottom = 200,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 800,
+9 -5
View File
@@ -505,7 +505,7 @@ namespace osu.Game.Screens.SelectV2
private void scrollToSelection()
{
if (currentKeyboardSelection.CarouselItem != null)
Scroll.ScrollTo(currentKeyboardSelection.CarouselItem.CarouselYPosition - visibleHalfHeight);
Scroll.ScrollTo(currentKeyboardSelection.CarouselItem.CarouselYPosition - visibleHalfHeight + BleedTop);
}
#endregion
@@ -519,17 +519,17 @@ namespace osu.Game.Screens.SelectV2
/// <summary>
/// The position of the lower visible bound with respect to the current scroll position.
/// </summary>
private float visibleBottomBound => (float)(Scroll.Current + DrawHeight + BleedBottom);
private float visibleBottomBound;
/// <summary>
/// The position of the upper visible bound with respect to the current scroll position.
/// </summary>
private float visibleUpperBound => (float)(Scroll.Current - BleedTop);
private float visibleUpperBound;
/// <summary>
/// Half the height of the visible content.
/// </summary>
private float visibleHalfHeight => (DrawHeight + BleedBottom + BleedTop) / 2;
private float visibleHalfHeight;
protected override void Update()
{
@@ -538,6 +538,10 @@ namespace osu.Game.Screens.SelectV2
if (carouselItems == null)
return;
visibleBottomBound = (float)(Scroll.Current + DrawHeight + BleedBottom);
visibleUpperBound = (float)(Scroll.Current - BleedTop);
visibleHalfHeight = (DrawHeight + BleedBottom + BleedTop) / 2;
if (!selectionValid.IsValid)
{
refreshAfterSelection();
@@ -582,7 +586,7 @@ namespace osu.Game.Screens.SelectV2
protected virtual float GetPanelXOffset(Drawable panel)
{
Vector2 posInScroll = Scroll.ToLocalSpace(panel.ScreenSpaceDrawQuad.Centre);
float dist = Math.Abs(1f - posInScroll.Y / visibleHalfHeight);
float dist = Math.Abs(1f - (posInScroll.Y + BleedTop) / visibleHalfHeight);
return offsetX(dist, visibleHalfHeight);
}