diff --git a/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs b/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs
index 9d30c44a11..649dc7f6a4 100644
--- a/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs
+++ b/osu.Game.Tests/Visual/SongSelectV2/BeatmapCarouselTestScene.cs
@@ -49,6 +49,8 @@ namespace osu.Game.Tests.Visual.SongSelectV2
private int beatmapCount;
+ protected int NewItemsPresentedInvocationCount;
+
protected BeatmapCarouselTestScene()
{
store = new TestBeatmapStore
@@ -65,6 +67,8 @@ namespace osu.Game.Tests.Visual.SongSelectV2
{
AddStep("create components", () =>
{
+ NewItemsPresentedInvocationCount = 0;
+
Box topBox;
Children = new Drawable[]
{
@@ -98,6 +102,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
{
Carousel = new BeatmapCarousel
{
+ NewItemsPresented = () => NewItemsPresentedInvocationCount++,
BleedTop = 50,
BleedBottom = 50,
Anchor = Anchor.Centre,
diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselFiltering.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselFiltering.cs
index 21c726f9ac..2381ebcf6e 100644
--- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselFiltering.cs
+++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselFiltering.cs
@@ -34,9 +34,13 @@ namespace osu.Game.Tests.Visual.SongSelectV2
AddBeatmaps(10, 3);
WaitForDrawablePanels();
+ AddAssert("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(1));
+
ApplyToFilter("filter", c => c.SearchText = BeatmapSets[2].Metadata.Title);
WaitForFiltering();
+ AddAssert("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(2));
+
CheckDisplayedBeatmapSetsCount(1);
CheckDisplayedBeatmapsCount(3);
@@ -54,6 +58,8 @@ namespace osu.Game.Tests.Visual.SongSelectV2
ApplyToFilter("remove filter", c => c.SearchText = string.Empty);
WaitForFiltering();
+ AddAssert("invocation count correct", () => NewItemsPresentedInvocationCount, () => Is.EqualTo(3));
+
CheckDisplayedBeatmapSetsCount(10);
CheckDisplayedBeatmapsCount(30);
}
diff --git a/osu.Game/Graphics/Carousel/Carousel.cs b/osu.Game/Graphics/Carousel/Carousel.cs
index 77d4938a6a..34d1c39dcb 100644
--- a/osu.Game/Graphics/Carousel/Carousel.cs
+++ b/osu.Game/Graphics/Carousel/Carousel.cs
@@ -35,6 +35,11 @@ namespace osu.Game.Graphics.Carousel
{
#region Properties and methods for external usage
+ ///
+ /// Called after a filter operation or change in items results in the visible carousel items changing.
+ ///
+ public Action? NewItemsPresented { private get; init; }
+
///
/// Height of the area above the carousel that should be treated as visible due to transparency of elements in front of it.
///
@@ -304,6 +309,8 @@ namespace osu.Game.Graphics.Carousel
HandleItemSelected(currentSelection.Model);
refreshAfterSelection();
+
+ NewItemsPresented?.Invoke();
});
void log(string text) => Logger.Log($"Carousel[op {cts.GetHashCode().ToString()}] {stopwatch.ElapsedMilliseconds} ms: {text}");