Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ordering certain carousel panels behind others #31802

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

frenzibyte
Copy link
Member

There is no appropriate example to show where this helps currently, but this becomes more apparent during beatmap carousel transitions where beatmap difficulty panels may temporarily overlap with a beatmap set panel during transition, and at that point the difficulty panel should logically always be behind it. This is what this change aims to achieve.

I was considering to approach this with a virtual method computing the final depth value of each item, but I realised 99% of the logic is strongly attached to the internals of Carousel, and I was between making the virtual method accept many parameters to not deal with those internals or expose them to BeatmapCarousel, both of which sound bad quality-wise.

@@ -29,6 +29,12 @@ public sealed class CarouselItem : IComparable<CarouselItem>
/// </summary>
public float DrawHeight { get; set; } = DEFAULT_HEIGHT;

/// <summary>
/// A number that defines the layer which this <see cref="CarouselItem"/> should be placed on depth-wise.
/// The higher the number, the farther the panel associated with this item is taken to the background.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should mention that this is relative to other panels, rather than "to the background" (because it doesn't make too much sense when they are never really approaching any background).

@@ -550,6 +550,9 @@ protected override void Update()
updateDisplayedRange(range);
}

double selectedYPos = currentSelection?.CarouselItem?.CarouselYPosition ?? 0;
double maximumDistanceFromSelection = scroll.Panels.Select(p => Math.Abs(((ICarouselPanel)p).DrawYPosition - selectedYPos)).DefaultIfEmpty().Max();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't run linq in Update as a rule. Why can't this just be scroll.Panels[^1]?

@peppy peppy self-requested a review February 6, 2025 04:26
@peppy
Copy link
Member

peppy commented Feb 6, 2025

@frenzibyte I've applied fixes for the issues I pointed out. Please double-check everything still works as you expect.

@frenzibyte
Copy link
Member Author

Seems to work fine, using DrawHeight as a sane maximum distance sounds good.

@peppy peppy merged commit f4bb3bc into ppy:master Feb 6, 2025
7 of 10 checks passed
@frenzibyte frenzibyte deleted the carousel-v2-depth-ordering branch February 6, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants