1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-22 03:31:54 +08:00

Merge pull request #32760 from peppy/fix-carousel-bleed

Fix carousel handling of bleed areas
This commit is contained in:
Dean Herbert
2025-04-11 18:10:51 +09:00
committed by GitHub
Unverified
2 changed files with 13 additions and 7 deletions
@@ -96,6 +96,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Carousel = new BeatmapCarousel
{
BleedTop = 50,
BleedBottom = 50,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 800,
+11 -7
View File
@@ -38,12 +38,12 @@ namespace osu.Game.Screens.SelectV2
/// <summary>
/// Height of the area above the carousel that should be treated as visible due to transparency of elements in front of it.
/// </summary>
public float BleedTop { get; set; } = 0;
public float BleedTop { get; set; }
/// <summary>
/// Height of the area below the carousel that should be treated as visible due to transparency of elements in front of it.
/// </summary>
public float BleedBottom { get; set; } = 0;
public float BleedBottom { get; set; }
/// <summary>
/// The number of pixels outside the carousel's vertical bounds to manifest drawables.
@@ -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);
}