mirror of
https://github.com/ppy/osu.git
synced 2025-02-07 19:02:58 +08:00
Reorder carousel methods into logical regions
This commit is contained in:
parent
8657576210
commit
6ac2dbc818
@ -30,10 +30,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract partial class Carousel<T> : CompositeDrawable
|
public abstract partial class Carousel<T> : CompositeDrawable
|
||||||
{
|
{
|
||||||
/// <summary>
|
#region Properties and methods for external usage
|
||||||
/// A collection of filters which should be run each time a <see cref="FilterAsync"/> is executed.
|
|
||||||
/// </summary>
|
|
||||||
protected IEnumerable<ICarouselFilter> Filters { get; init; } = Enumerable.Empty<ICarouselFilter>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Height of the area above the carousel that should be treated as visible due to transparency of elements in front of it.
|
/// Height of the area above the carousel that should be treated as visible due to transparency of elements in front of it.
|
||||||
@ -82,15 +79,6 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int VisibleItems => scroll.Panels.Count;
|
public int VisibleItems => scroll.Panels.Count;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// All items which are to be considered for display in this carousel.
|
|
||||||
/// Mutating this list will automatically queue a <see cref="FilterAsync"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Note that an <see cref="ICarouselFilter"/> may add new items which are displayed but not tracked in this list.
|
|
||||||
/// </remarks>
|
|
||||||
protected readonly BindableList<T> Items = new BindableList<T>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The currently selected model.
|
/// The currently selected model.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -114,20 +102,31 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CarouselItem>? displayedCarouselItems;
|
#endregion
|
||||||
|
|
||||||
private readonly CarouselScrollContainer scroll;
|
#region Properties and methods concerning implementations
|
||||||
|
|
||||||
protected Carousel()
|
/// <summary>
|
||||||
{
|
/// A collection of filters which should be run each time a <see cref="FilterAsync"/> is executed.
|
||||||
InternalChild = scroll = new CarouselScrollContainer
|
/// </summary>
|
||||||
{
|
/// <remarks>
|
||||||
RelativeSizeAxes = Axes.Both,
|
/// Implementations should add all required filters as part of their initialisation.
|
||||||
Masking = false,
|
///
|
||||||
};
|
/// Importantly, each filter is sequentially run in the order provided.
|
||||||
|
/// Each filter receives the output of the previous filter.
|
||||||
|
///
|
||||||
|
/// A filter may add, mutate or remove items.
|
||||||
|
/// </remarks>
|
||||||
|
protected IEnumerable<ICarouselFilter> Filters { get; init; } = Enumerable.Empty<ICarouselFilter>();
|
||||||
|
|
||||||
Items.BindCollectionChanged((_, _) => FilterAsync());
|
/// <summary>
|
||||||
}
|
/// All items which are to be considered for display in this carousel.
|
||||||
|
/// Mutating this list will automatically queue a <see cref="FilterAsync"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Note that an <see cref="ICarouselFilter"/> may add new items which are displayed but not tracked in this list.
|
||||||
|
/// </remarks>
|
||||||
|
protected readonly BindableList<T> Items = new BindableList<T>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queue an asynchronous filter operation.
|
/// Queue an asynchronous filter operation.
|
||||||
@ -151,8 +150,29 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
/// <returns>A <see cref="CarouselItem"/> representing the model.</returns>
|
/// <returns>A <see cref="CarouselItem"/> representing the model.</returns>
|
||||||
protected abstract CarouselItem CreateCarouselItemForModel(T model);
|
protected abstract CarouselItem CreateCarouselItemForModel(T model);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Initialisation
|
||||||
|
|
||||||
|
private readonly CarouselScrollContainer scroll;
|
||||||
|
|
||||||
|
protected Carousel()
|
||||||
|
{
|
||||||
|
InternalChild = scroll = new CarouselScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
Items.BindCollectionChanged((_, _) => FilterAsync());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Filtering and display preparation
|
#region Filtering and display preparation
|
||||||
|
|
||||||
|
private List<CarouselItem>? displayedCarouselItems;
|
||||||
|
|
||||||
private Task filterTask = Task.CompletedTask;
|
private Task filterTask = Task.CompletedTask;
|
||||||
private CancellationTokenSource cancellationSource = new CancellationTokenSource();
|
private CancellationTokenSource cancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user