mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 11:02:57 +08:00
Some Carousel
classes can be abstract
This commit is contained in:
parent
89e3c551ff
commit
de31a48beb
@ -10,8 +10,31 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
/// <summary>
|
||||
/// A group which ensures only one item is selected.
|
||||
/// </summary>
|
||||
public class CarouselGroup : CarouselItem
|
||||
public abstract class CarouselGroup : CarouselItem
|
||||
{
|
||||
protected CarouselGroup(List<CarouselItem>? items = null)
|
||||
{
|
||||
if (items != null) this.items = items;
|
||||
|
||||
State.ValueChanged += state =>
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
case CarouselItemState.Collapsed:
|
||||
case CarouselItemState.NotSelected:
|
||||
this.items.ForEach(c => c.State.Value = CarouselItemState.Collapsed);
|
||||
break;
|
||||
|
||||
case CarouselItemState.Selected:
|
||||
this.items.ForEach(c =>
|
||||
{
|
||||
if (c.State.Value == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected;
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override DrawableCarouselItem? CreateDrawableRepresentation() => null;
|
||||
|
||||
public SlimReadOnlyListWrapper<CarouselItem> Items => items.AsSlimReadOnly();
|
||||
@ -67,29 +90,6 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
TotalItemsNotFiltered++;
|
||||
}
|
||||
|
||||
public CarouselGroup(List<CarouselItem>? items = null)
|
||||
{
|
||||
if (items != null) this.items = items;
|
||||
|
||||
State.ValueChanged += state =>
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
case CarouselItemState.Collapsed:
|
||||
case CarouselItemState.NotSelected:
|
||||
this.items.ForEach(c => c.State.Value = CarouselItemState.Collapsed);
|
||||
break;
|
||||
|
||||
case CarouselItemState.Selected:
|
||||
this.items.ForEach(c =>
|
||||
{
|
||||
if (c.State.Value == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected;
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void Filter(FilterCriteria criteria)
|
||||
{
|
||||
base.Filter(criteria);
|
||||
|
@ -10,9 +10,9 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
/// <summary>
|
||||
/// A group which ensures at least one item is selected (if the group itself is selected).
|
||||
/// </summary>
|
||||
public class CarouselGroupEagerSelect : CarouselGroup
|
||||
public abstract class CarouselGroupEagerSelect : CarouselGroup
|
||||
{
|
||||
public CarouselGroupEagerSelect()
|
||||
protected CarouselGroupEagerSelect()
|
||||
{
|
||||
State.ValueChanged += state =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user