1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-31 23:52:55 +08:00

Move Selected status to drawables

Basically, I don't want bindables in `CarouselItem`. It means there
needs to be a bind-unbind process on pooling. By moving these to the
drawable and just updating every frame, we can simplify things a lot.
This commit is contained in:
Dean Herbert 2025-01-23 16:07:18 +09:00
parent beaadfa1fa
commit c67c0a7fc0
No known key found for this signature in database

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Bindables;
namespace osu.Game.Screens.SelectV2
{
@ -10,9 +9,9 @@ namespace osu.Game.Screens.SelectV2
/// Represents a single display item for display in a <see cref="Carousel{T}"/>.
/// This is used to house information related to the attached model that helps with display and tracking.
/// </summary>
public abstract class CarouselItem : IComparable<CarouselItem>
public sealed class CarouselItem : IComparable<CarouselItem>
{
public readonly BindableBool Selected = new BindableBool();
public const float DEFAULT_HEIGHT = 40;
/// <summary>
/// The model this item is representing.
@ -20,16 +19,27 @@ namespace osu.Game.Screens.SelectV2
public readonly object Model;
/// <summary>
/// The current Y position in the carousel. This is managed by <see cref="Carousel{T}"/> and should not be set manually.
/// The current Y position in the carousel.
/// This is managed by <see cref="Carousel{T}"/> and should not be set manually.
/// </summary>
public double CarouselYPosition { get; set; }
/// <summary>
/// The height this item will take when displayed.
/// The height this item will take when displayed. Defaults to <see cref="DEFAULT_HEIGHT"/>.
/// </summary>
public abstract float DrawHeight { get; }
public float DrawHeight { get; set; } = DEFAULT_HEIGHT;
protected CarouselItem(object model)
/// <summary>
/// Whether this item should be a valid target for user group selection hotkeys.
/// </summary>
public bool IsGroupSelectionTarget { get; set; }
/// <summary>
/// Whether this item is visible or collapsed (hidden).
/// </summary>
public bool IsVisible { get; set; } = true;
public CarouselItem(object model)
{
Model = model;
}