1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 19:07:19 +08:00

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2.0 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 18:19:50 +09:00
2022-06-17 16:37:17 +09:00
#nullable disable
using System;
2019-02-21 19:04:31 +09:00
using osu.Framework.Bindables;
2018-04-13 18:19:50 +09:00
2017-12-12 17:48:38 +09:00
namespace osu.Game.Screens.Select.Carousel
{
public abstract class CarouselItem : IComparable<CarouselItem>
2017-12-12 17:48:38 +09:00
{
public virtual float TotalHeight => 0;
/// <summary>
/// An externally defined value used to determine this item's vertical display offset relative to the carousel.
/// </summary>
public float CarouselYPosition;
2017-12-12 17:48:38 +09:00
public readonly BindableBool Filtered = new BindableBool();
2018-04-13 18:19:50 +09:00
2017-12-12 17:48:38 +09:00
public readonly Bindable<CarouselItemState> State = new Bindable<CarouselItemState>(CarouselItemState.NotSelected);
2018-04-13 18:19:50 +09:00
/// <summary>
/// This item is not in a hidden state.
/// </summary>
public bool Visible => State.Value != CarouselItemState.Collapsed && !Filtered.Value;
2018-04-13 18:19:50 +09:00
2017-12-14 20:40:58 +09:00
protected CarouselItem()
{
Filtered.ValueChanged += filtered =>
{
if (filtered.NewValue && State.Value == CarouselItemState.Selected)
State.Value = CarouselItemState.NotSelected;
};
2017-12-12 17:48:38 +09:00
}
2018-04-13 18:19:50 +09:00
/// <summary>
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
/// </summary>
internal ulong ItemID;
/// <summary>
/// Create a fresh drawable version of this item.
/// </summary>
public abstract DrawableCarouselItem CreateDrawableRepresentation();
2018-04-13 18:19:50 +09:00
2017-12-14 20:40:58 +09:00
public virtual void Filter(FilterCriteria criteria)
{
}
2018-04-13 18:19:50 +09:00
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ItemID.CompareTo(other.ItemID);
public int CompareTo(CarouselItem other) => CarouselYPosition.CompareTo(other.CarouselYPosition);
2017-12-12 17:48:38 +09:00
}
2018-04-13 18:19:50 +09:00
2017-12-13 19:56:16 +09:00
public enum CarouselItemState
{
2017-12-16 23:56:14 +09:00
Collapsed,
2017-12-13 19:56:16 +09:00
NotSelected,
Selected,
}
2017-12-12 17:48:38 +09:00
}