From f9112066d3638477b088e0502665bbb97ede9a3f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Apr 2025 17:42:17 +0900 Subject: [PATCH 1/3] 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). --- .../SongSelect/BeatmapCarouselV2TestScene.cs | 2 ++ osu.Game/Screens/SelectV2/Carousel.cs | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs b/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs index 2c902a466f..ad8004304a 100644 --- a/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs +++ b/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs @@ -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, diff --git a/osu.Game/Screens/SelectV2/Carousel.cs b/osu.Game/Screens/SelectV2/Carousel.cs index 5339b5358b..21310b76a1 100644 --- a/osu.Game/Screens/SelectV2/Carousel.cs +++ b/osu.Game/Screens/SelectV2/Carousel.cs @@ -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 /// /// The position of the lower visible bound with respect to the current scroll position. /// - private float visibleBottomBound => (float)(Scroll.Current + DrawHeight + BleedBottom); + private float visibleBottomBound; /// /// The position of the upper visible bound with respect to the current scroll position. /// - private float visibleUpperBound => (float)(Scroll.Current - BleedTop); + private float visibleUpperBound; /// /// Half the height of the visible content. /// - 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); } From 5c54e57d6d8aa803d3794be3581c81c73af77a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 11 Apr 2025 08:01:34 +0200 Subject: [PATCH 2/3] Remove redundant initialisers --- osu.Game/Screens/SelectV2/Carousel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/SelectV2/Carousel.cs b/osu.Game/Screens/SelectV2/Carousel.cs index 21310b76a1..7b1fd6e999 100644 --- a/osu.Game/Screens/SelectV2/Carousel.cs +++ b/osu.Game/Screens/SelectV2/Carousel.cs @@ -38,12 +38,12 @@ namespace osu.Game.Screens.SelectV2 /// /// Height of the area above the carousel that should be treated as visible due to transparency of elements in front of it. /// - public float BleedTop { get; set; } = 0; + public float BleedTop { get; set; } /// /// Height of the area below the carousel that should be treated as visible due to transparency of elements in front of it. /// - public float BleedBottom { get; set; } = 0; + public float BleedBottom { get; set; } /// /// The number of pixels outside the carousel's vertical bounds to manifest drawables. From 9911e0819eabe986eabe310cfac97ff6330e36c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 11 Apr 2025 10:13:49 +0200 Subject: [PATCH 3/3] Reduce bleed in tests to allow them to pass --- .../Visual/SongSelect/BeatmapCarouselV2TestScene.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs b/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs index ad8004304a..f2faeab1c4 100644 --- a/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs +++ b/osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs @@ -96,8 +96,8 @@ namespace osu.Game.Tests.Visual.SongSelect { Carousel = new BeatmapCarousel { - BleedTop = 200, - BleedBottom = 200, + BleedTop = 50, + BleedBottom = 50, Anchor = Anchor.Centre, Origin = Anchor.Centre, Width = 800,