mirror of
https://github.com/ppy/osu.git
synced 2025-02-08 13:13:16 +08:00
Add expanded state to sample drawable representations
This commit is contained in:
parent
58560f8acf
commit
599b59cb14
@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestOpenCloseGroupWithNoSelection()
|
public void TestOpenCloseGroupWithNoSelectionMouse()
|
||||||
{
|
{
|
||||||
AddBeatmaps(10, 5);
|
AddBeatmaps(10, 5);
|
||||||
WaitForDrawablePanels();
|
WaitForDrawablePanels();
|
||||||
@ -41,6 +41,29 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
CheckNoSelection();
|
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]
|
[Test]
|
||||||
public void TestCarouselRemembersSelection()
|
public void TestCarouselRemembersSelection()
|
||||||
{
|
{
|
||||||
|
@ -100,6 +100,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
|
|
||||||
public CarouselItem? Item { get; set; }
|
public CarouselItem? Item { get; set; }
|
||||||
public BindableBool Selected { get; } = new BindableBool();
|
public BindableBool Selected { get; } = new BindableBool();
|
||||||
|
public BindableBool Expanded { get; } = new BindableBool();
|
||||||
public BindableBool KeyboardSelected { get; } = new BindableBool();
|
public BindableBool KeyboardSelected { get; } = new BindableBool();
|
||||||
|
|
||||||
public double DrawYPosition { get; set; }
|
public double DrawYPosition { get; set; }
|
||||||
|
@ -25,6 +25,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
private BeatmapCarousel carousel { get; set; } = null!;
|
private BeatmapCarousel carousel { get; set; } = null!;
|
||||||
|
|
||||||
private OsuSpriteText text = null!;
|
private OsuSpriteText text = null!;
|
||||||
|
private Box box = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -34,7 +35,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
box = new Box
|
||||||
{
|
{
|
||||||
Colour = Color4.Yellow.Darken(5),
|
Colour = Color4.Yellow.Darken(5),
|
||||||
Alpha = 0.8f,
|
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 =>
|
KeyboardSelected.BindValueChanged(value =>
|
||||||
{
|
{
|
||||||
if (value.NewValue)
|
if (value.NewValue)
|
||||||
@ -85,6 +91,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
|
|
||||||
public CarouselItem? Item { get; set; }
|
public CarouselItem? Item { get; set; }
|
||||||
public BindableBool Selected { get; } = new BindableBool();
|
public BindableBool Selected { get; } = new BindableBool();
|
||||||
|
public BindableBool Expanded { get; } = new BindableBool();
|
||||||
public BindableBool KeyboardSelected { get; } = new BindableBool();
|
public BindableBool KeyboardSelected { get; } = new BindableBool();
|
||||||
|
|
||||||
public double DrawYPosition { get; set; }
|
public double DrawYPosition { get; set; }
|
||||||
|
@ -571,6 +571,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
|
|
||||||
c.Selected.Value = c.Item == currentSelection?.CarouselItem;
|
c.Selected.Value = c.Item == currentSelection?.CarouselItem;
|
||||||
c.KeyboardSelected.Value = c.Item == currentKeyboardSelection?.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.Item = null;
|
||||||
carouselPanel.Selected.Value = false;
|
carouselPanel.Selected.Value = false;
|
||||||
carouselPanel.KeyboardSelected.Value = false;
|
carouselPanel.KeyboardSelected.Value = false;
|
||||||
|
carouselPanel.Expanded.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -26,6 +26,8 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
private Box activationFlash = null!;
|
private Box activationFlash = null!;
|
||||||
private OsuSpriteText text = null!;
|
private OsuSpriteText text = null!;
|
||||||
|
|
||||||
|
private Box box = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -34,7 +36,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
box = new Box
|
||||||
{
|
{
|
||||||
Colour = Color4.DarkBlue.Darken(5),
|
Colour = Color4.DarkBlue.Darken(5),
|
||||||
Alpha = 0.8f,
|
Alpha = 0.8f,
|
||||||
@ -60,6 +62,11 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
activationFlash.FadeTo(value.NewValue ? 0.2f : 0, 500, Easing.OutQuint);
|
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 =>
|
KeyboardSelected.BindValueChanged(value =>
|
||||||
{
|
{
|
||||||
if (value.NewValue)
|
if (value.NewValue)
|
||||||
@ -97,6 +104,7 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
|
|
||||||
public CarouselItem? Item { get; set; }
|
public CarouselItem? Item { get; set; }
|
||||||
public BindableBool Selected { get; } = new BindableBool();
|
public BindableBool Selected { get; } = new BindableBool();
|
||||||
|
public BindableBool Expanded { get; } = new BindableBool();
|
||||||
public BindableBool KeyboardSelected { get; } = new BindableBool();
|
public BindableBool KeyboardSelected { get; } = new BindableBool();
|
||||||
|
|
||||||
public double DrawYPosition { get; set; }
|
public double DrawYPosition { get; set; }
|
||||||
|
@ -14,10 +14,15 @@ namespace osu.Game.Screens.SelectV2
|
|||||||
public interface ICarouselPanel
|
public interface ICarouselPanel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
BindableBool Selected { get; }
|
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>
|
/// <summary>
|
||||||
/// Whether this item has keyboard selection. Should be read from to update the visual state.
|
/// Whether this item has keyboard selection. Should be read from to update the visual state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user