1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-08 06:22:55 +08:00

Add expanded state to sample drawable representations

This commit is contained in:
Dean Herbert 2025-02-04 17:16:36 +09:00
parent 58560f8acf
commit 599b59cb14
No known key found for this signature in database
6 changed files with 50 additions and 4 deletions

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}
[Test]
public void TestOpenCloseGroupWithNoSelection()
public void TestOpenCloseGroupWithNoSelectionMouse()
{
AddBeatmaps(10, 5);
WaitForDrawablePanels();
@ -41,6 +41,29 @@ namespace osu.Game.Tests.Visual.SongSelect
CheckNoSelection();
}
[Test]
public void TestOpenCloseGroupWithNoSelectionKeyboard()
{
AddBeatmaps(10, 5);
WaitForDrawablePanels();
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
CheckNoSelection();
SelectNextPanel();
Select();
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
AddAssert("keyboard selected is expanded", () => getKeyboardSelectedPanel()?.Expanded.Value, () => Is.True);
CheckNoSelection();
Select();
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
AddAssert("keyboard selected is collapsed", () => getKeyboardSelectedPanel()?.Expanded.Value, () => Is.False);
CheckNoSelection();
GroupPanel? getKeyboardSelectedPanel() => Carousel.ChildrenOfType<GroupPanel>().SingleOrDefault(p => p.KeyboardSelected.Value);
}
[Test]
public void TestCarouselRemembersSelection()
{

View File

@ -100,6 +100,7 @@ namespace osu.Game.Screens.SelectV2
public CarouselItem? Item { get; set; }
public BindableBool Selected { get; } = new BindableBool();
public BindableBool Expanded { get; } = new BindableBool();
public BindableBool KeyboardSelected { get; } = new BindableBool();
public double DrawYPosition { get; set; }

View File

@ -25,6 +25,7 @@ namespace osu.Game.Screens.SelectV2
private BeatmapCarousel carousel { get; set; } = null!;
private OsuSpriteText text = null!;
private Box box = null!;
[BackgroundDependencyLoader]
private void load()
@ -34,7 +35,7 @@ namespace osu.Game.Screens.SelectV2
InternalChildren = new Drawable[]
{
new Box
box = new Box
{
Colour = Color4.Yellow.Darken(5),
Alpha = 0.8f,
@ -48,6 +49,11 @@ namespace osu.Game.Screens.SelectV2
}
};
Expanded.BindValueChanged(value =>
{
box.FadeColour(value.NewValue ? Color4.Yellow.Darken(2) : Color4.Yellow.Darken(5), 500, Easing.OutQuint);
});
KeyboardSelected.BindValueChanged(value =>
{
if (value.NewValue)
@ -85,6 +91,7 @@ namespace osu.Game.Screens.SelectV2
public CarouselItem? Item { get; set; }
public BindableBool Selected { get; } = new BindableBool();
public BindableBool Expanded { get; } = new BindableBool();
public BindableBool KeyboardSelected { get; } = new BindableBool();
public double DrawYPosition { get; set; }

View File

@ -571,6 +571,7 @@ namespace osu.Game.Screens.SelectV2
c.Selected.Value = c.Item == currentSelection?.CarouselItem;
c.KeyboardSelected.Value = c.Item == currentKeyboardSelection?.CarouselItem;
c.Expanded.Value = c.Item.IsExpanded;
}
}
@ -674,6 +675,7 @@ namespace osu.Game.Screens.SelectV2
carouselPanel.Item = null;
carouselPanel.Selected.Value = false;
carouselPanel.KeyboardSelected.Value = false;
carouselPanel.Expanded.Value = false;
}
#endregion

View File

@ -26,6 +26,8 @@ namespace osu.Game.Screens.SelectV2
private Box activationFlash = null!;
private OsuSpriteText text = null!;
private Box box = null!;
[BackgroundDependencyLoader]
private void load()
{
@ -34,7 +36,7 @@ namespace osu.Game.Screens.SelectV2
InternalChildren = new Drawable[]
{
new Box
box = new Box
{
Colour = Color4.DarkBlue.Darken(5),
Alpha = 0.8f,
@ -60,6 +62,11 @@ namespace osu.Game.Screens.SelectV2
activationFlash.FadeTo(value.NewValue ? 0.2f : 0, 500, Easing.OutQuint);
});
Expanded.BindValueChanged(value =>
{
box.FadeColour(value.NewValue ? Color4.SkyBlue : Color4.DarkBlue.Darken(5), 500, Easing.OutQuint);
});
KeyboardSelected.BindValueChanged(value =>
{
if (value.NewValue)
@ -97,6 +104,7 @@ namespace osu.Game.Screens.SelectV2
public CarouselItem? Item { get; set; }
public BindableBool Selected { get; } = new BindableBool();
public BindableBool Expanded { get; } = new BindableBool();
public BindableBool KeyboardSelected { get; } = new BindableBool();
public double DrawYPosition { get; set; }

View File

@ -14,10 +14,15 @@ namespace osu.Game.Screens.SelectV2
public interface ICarouselPanel
{
/// <summary>
/// Whether this item has selection. Should be read from to update the visual state.
/// Whether this item has selection (see <see cref="Carousel{T}.CurrentSelection"/>). Should be read from to update the visual state.
/// </summary>
BindableBool Selected { get; }
/// <summary>
/// Whether this item is expanded (see <see cref="CarouselItem.IsExpanded"/>). Should be read from to update the visual state.
/// </summary>
BindableBool Expanded { get; }
/// <summary>
/// Whether this item has keyboard selection. Should be read from to update the visual state.
/// </summary>