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

Expose a way of knowing when carousel's displayed items are updated

This commit is contained in:
Dean Herbert
2025-05-09 14:49:38 +09:00
Unverified
parent 7311196708
commit a957f41ffc
3 changed files with 18 additions and 0 deletions
@@ -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,
@@ -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);
}
+7
View File
@@ -35,6 +35,11 @@ namespace osu.Game.Graphics.Carousel
{
#region Properties and methods for external usage
/// <summary>
/// Called after a filter operation or change in items results in the visible carousel items changing.
/// </summary>
public Action? NewItemsPresented { private get; init; }
/// <summary>
/// Height of the area above the carousel that should be treated as visible due to transparency of elements in front of it.
/// </summary>
@@ -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}");