mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 09:37:23 +08:00
Remove weird Expanded
/ ExpandedState
duality
This commit is contained in:
parent
f7b45a26de
commit
518c1aa5a0
@ -61,7 +61,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddStep("select difficulty adjust", () => freeModSelectOverlay.SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
AddStep("select difficulty adjust", () => freeModSelectOverlay.SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
||||||
AddWaitStep("wait some", 3);
|
AddWaitStep("wait some", 3);
|
||||||
AddAssert("customisation area not expanded", () => !this.ChildrenOfType<ModCustomisationPanel>().Single().Expanded);
|
AddAssert("customisation area not expanded",
|
||||||
|
() => this.ChildrenOfType<ModCustomisationPanel>().Single().ExpandedState.Value,
|
||||||
|
() => Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -55,22 +55,26 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("set DT", () =>
|
AddStep("set DT", () =>
|
||||||
{
|
{
|
||||||
SelectedMods.Value = new[] { new OsuModDoubleTime() };
|
SelectedMods.Value = new[] { new OsuModDoubleTime() };
|
||||||
panel.Enabled.Value = panel.Expanded = true;
|
panel.Enabled.Value = true;
|
||||||
|
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
|
||||||
});
|
});
|
||||||
AddStep("set DA", () =>
|
AddStep("set DA", () =>
|
||||||
{
|
{
|
||||||
SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() };
|
SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() };
|
||||||
panel.Enabled.Value = panel.Expanded = true;
|
panel.Enabled.Value = true;
|
||||||
|
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
|
||||||
});
|
});
|
||||||
AddStep("set FL+WU+DA+AD", () =>
|
AddStep("set FL+WU+DA+AD", () =>
|
||||||
{
|
{
|
||||||
SelectedMods.Value = new Mod[] { new OsuModFlashlight(), new ModWindUp(), new OsuModDifficultyAdjust(), new OsuModApproachDifferent() };
|
SelectedMods.Value = new Mod[] { new OsuModFlashlight(), new ModWindUp(), new OsuModDifficultyAdjust(), new OsuModApproachDifferent() };
|
||||||
panel.Enabled.Value = panel.Expanded = true;
|
panel.Enabled.Value = true;
|
||||||
|
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
|
||||||
});
|
});
|
||||||
AddStep("set empty", () =>
|
AddStep("set empty", () =>
|
||||||
{
|
{
|
||||||
SelectedMods.Value = Array.Empty<Mod>();
|
SelectedMods.Value = Array.Empty<Mod>();
|
||||||
panel.Enabled.Value = panel.Expanded = false;
|
panel.Enabled.Value = false;
|
||||||
|
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Collapsed;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +159,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private void checkExpanded(bool expanded)
|
private void checkExpanded(bool expanded)
|
||||||
{
|
{
|
||||||
AddUntilStep(expanded ? "is expanded" : "not expanded", () => panel.Expanded, () => Is.EqualTo(expanded));
|
AddUntilStep(expanded ? "is expanded" : "not expanded", () => panel.ExpandedState.Value,
|
||||||
|
() => expanded ? Is.Not.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed) : Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -999,7 +999,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("press mouse", () => InputManager.PressButton(MouseButton.Left));
|
AddStep("press mouse", () => InputManager.PressButton(MouseButton.Left));
|
||||||
AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
||||||
AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left));
|
AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
AddAssert("customisation panel closed by click", () => !this.ChildrenOfType<ModCustomisationPanel>().Single().Expanded);
|
AddAssert("customisation panel closed by click",
|
||||||
|
() => this.ChildrenOfType<ModCustomisationPanel>().Single().ExpandedState.Value,
|
||||||
|
() => Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
|
||||||
|
|
||||||
if (textSearchStartsActive)
|
if (textSearchStartsActive)
|
||||||
AddAssert("search focused", () => this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
AddAssert("search focused", () => this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
||||||
@ -1022,7 +1024,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
private void assertCustomisationToggleState(bool disabled, bool active)
|
private void assertCustomisationToggleState(bool disabled, bool active)
|
||||||
{
|
{
|
||||||
AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Enabled.Value == !disabled);
|
AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Enabled.Value == !disabled);
|
||||||
AddAssert($"customisation panel is {(active ? "" : "not ")}active", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Expanded == active);
|
AddAssert($"customisation panel is {(active ? "" : "not ")}active",
|
||||||
|
() => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().ExpandedState.Value,
|
||||||
|
() => active ? Is.Not.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed) : Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
private T getSelectedMod<T>() where T : Mod => SelectedMods.Value.OfType<T>().Single();
|
private T getSelectedMod<T>() where T : Mod => SelectedMods.Value.OfType<T>().Single();
|
||||||
|
@ -143,8 +143,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
if (Enabled.Value)
|
if (Enabled.Value)
|
||||||
{
|
{
|
||||||
if (!touchedThisFrame)
|
if (!touchedThisFrame && panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed)
|
||||||
panel.UpdateHoverExpansion(ModCustomisationPanelState.ExpandedByHover);
|
panel.ExpandedState.Value = ModCustomisationPanelState.ExpandedByHover;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
|
@ -38,13 +38,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public readonly BindableBool Enabled = new BindableBool();
|
public readonly BindableBool Enabled = new BindableBool();
|
||||||
|
|
||||||
public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>(ModCustomisationPanelState.Collapsed);
|
public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>();
|
||||||
|
|
||||||
public bool Expanded
|
|
||||||
{
|
|
||||||
get => ExpandedState.Value > ModCustomisationPanelState.Collapsed;
|
|
||||||
set => ExpandedState.Value = value ? ModCustomisationPanelState.Expanded : ModCustomisationPanelState.Collapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
@ -52,9 +46,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
// Handle{Non}PositionalInput controls whether the panel should act as a blocking layer on the screen. only block when the panel is expanded.
|
// Handle{Non}PositionalInput controls whether the panel should act as a blocking layer on the screen. only block when the panel is expanded.
|
||||||
// These properties are used because they correctly handle blocking/unblocking hover when mouse is pointing at a drawable outside
|
// These properties are used because they correctly handle blocking/unblocking hover when mouse is pointing at a drawable outside
|
||||||
// (returning Expanded.Value to OnHover or overriding Block{Non}PositionalInput doesn't work).
|
// (handling OnHover or overriding Block{Non}PositionalInput doesn't work).
|
||||||
public override bool HandlePositionalInput => Expanded;
|
public override bool HandlePositionalInput => ExpandedState.Value != ModCustomisationPanelState.Collapsed;
|
||||||
public override bool HandleNonPositionalInput => Expanded;
|
public override bool HandleNonPositionalInput => ExpandedState.Value != ModCustomisationPanelState.Collapsed;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -140,7 +134,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
Expanded = false;
|
ExpandedState.Value = ModCustomisationPanelState.Collapsed;
|
||||||
return base.OnClick(e);
|
return base.OnClick(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +147,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
case GlobalAction.Back:
|
case GlobalAction.Back:
|
||||||
Expanded = false;
|
ExpandedState.Value = ModCustomisationPanelState.Collapsed;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +162,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
content.ClearTransforms();
|
content.ClearTransforms();
|
||||||
|
|
||||||
if (Expanded)
|
if (ExpandedState.Value != ModCustomisationPanelState.Collapsed)
|
||||||
{
|
{
|
||||||
content.AutoSizeDuration = 400;
|
content.AutoSizeDuration = 400;
|
||||||
content.AutoSizeEasing = Easing.OutQuint;
|
content.AutoSizeEasing = Easing.OutQuint;
|
||||||
@ -193,7 +187,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void updateMods()
|
private void updateMods()
|
||||||
{
|
{
|
||||||
Expanded = false;
|
ExpandedState.Value = ModCustomisationPanelState.Collapsed;
|
||||||
sectionsFlow.Clear();
|
sectionsFlow.Clear();
|
||||||
|
|
||||||
// Importantly, the selected mods bindable is already ordered by the mod select overlay (following the order of mod columns and panels).
|
// Importantly, the selected mods bindable is already ordered by the mod select overlay (following the order of mod columns and panels).
|
||||||
@ -216,10 +210,10 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private partial class FocusGrabbingContainer : InputBlockingContainer
|
private partial class FocusGrabbingContainer : InputBlockingContainer
|
||||||
{
|
{
|
||||||
public readonly IBindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>(ModCustomisationPanelState.Collapsed);
|
public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>();
|
||||||
|
|
||||||
public override bool RequestsFocus => panel.Expanded;
|
public override bool RequestsFocus => panel.ExpandedState.Value != ModCustomisationPanelState.Collapsed;
|
||||||
public override bool AcceptsFocus => panel.Expanded;
|
public override bool AcceptsFocus => panel.ExpandedState.Value != ModCustomisationPanelState.Collapsed;
|
||||||
|
|
||||||
private readonly ModCustomisationPanel panel;
|
private readonly ModCustomisationPanel panel;
|
||||||
|
|
||||||
@ -233,7 +227,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
if (ExpandedState.Value is ModCustomisationPanelState.ExpandedByHover
|
if (ExpandedState.Value is ModCustomisationPanelState.ExpandedByHover
|
||||||
&& !ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
|
&& !ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
|
||||||
{
|
{
|
||||||
panel.UpdateHoverExpansion(ModCustomisationPanelState.Collapsed);
|
ExpandedState.Value = ModCustomisationPanelState.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
|
@ -368,18 +368,18 @@ namespace osu.Game.Overlays.Mods
|
|||||||
customisationPanel.Enabled.Value = true;
|
customisationPanel.Enabled.Value = true;
|
||||||
|
|
||||||
if (anyModPendingConfiguration)
|
if (anyModPendingConfiguration)
|
||||||
customisationPanel.Expanded = true;
|
customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
customisationPanel.Expanded = false;
|
customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Collapsed;
|
||||||
customisationPanel.Enabled.Value = false;
|
customisationPanel.Enabled.Value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCustomisationVisualState()
|
private void updateCustomisationVisualState()
|
||||||
{
|
{
|
||||||
if (customisationPanel.Expanded)
|
if (customisationPanel.ExpandedState.Value != ModCustomisationPanel.ModCustomisationPanelState.Collapsed)
|
||||||
{
|
{
|
||||||
columnScroll.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
|
columnScroll.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
|
||||||
SearchTextBox.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
|
SearchTextBox.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
|
||||||
@ -544,7 +544,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
nonFilteredColumnCount += 1;
|
nonFilteredColumnCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
customisationPanel.Expanded = false;
|
customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -571,7 +571,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
// wherein activating the binding will both change the contents of the search text box and deselect all mods.
|
// wherein activating the binding will both change the contents of the search text box and deselect all mods.
|
||||||
case GlobalAction.DeselectAllMods:
|
case GlobalAction.DeselectAllMods:
|
||||||
{
|
{
|
||||||
if (!SearchTextBox.HasFocus && !customisationPanel.Expanded)
|
if (!SearchTextBox.HasFocus && customisationPanel.ExpandedState.Value == ModCustomisationPanel.ModCustomisationPanelState.Collapsed)
|
||||||
{
|
{
|
||||||
DisplayedFooterContent?.DeselectAllModsButton?.TriggerClick();
|
DisplayedFooterContent?.DeselectAllModsButton?.TriggerClick();
|
||||||
return true;
|
return true;
|
||||||
@ -637,7 +637,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
if (e.Repeat || e.Key != Key.Tab)
|
if (e.Repeat || e.Key != Key.Tab)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (customisationPanel.Expanded)
|
if (customisationPanel.ExpandedState.Value != ModCustomisationPanel.ModCustomisationPanelState.Collapsed)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`)
|
// TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user