mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 11:27:24 +08:00
Merge pull request #11952 from bdach/fix-restore-default-hidden
This commit is contained in:
commit
8a660b2bf5
43
osu.Game.Tests/Visual/Settings/TestSceneSettingsItem.cs
Normal file
43
osu.Game.Tests/Visual/Settings/TestSceneSettingsItem.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Settings
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneSettingsItem : OsuTestScene
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestRestoreDefaultValueButtonVisibility()
|
||||||
|
{
|
||||||
|
TestSettingsTextBox textBox = null;
|
||||||
|
|
||||||
|
AddStep("create settings item", () => Child = textBox = new TestSettingsTextBox
|
||||||
|
{
|
||||||
|
Current = new Bindable<string>
|
||||||
|
{
|
||||||
|
Default = "test",
|
||||||
|
Value = "test"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AddAssert("restore button hidden", () => textBox.RestoreDefaultValueButton.Alpha == 0);
|
||||||
|
|
||||||
|
AddStep("change value from default", () => textBox.Current.Value = "non-default");
|
||||||
|
AddUntilStep("restore button shown", () => textBox.RestoreDefaultValueButton.Alpha > 0);
|
||||||
|
|
||||||
|
AddStep("restore default", () => textBox.Current.SetDefault());
|
||||||
|
AddUntilStep("restore button hidden", () => textBox.RestoreDefaultValueButton.Alpha == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestSettingsTextBox : SettingsTextBox
|
||||||
|
{
|
||||||
|
public new Drawable RestoreDefaultValueButton => this.ChildrenOfType<RestoreDefaultValueButton>().Single();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -121,7 +121,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
labelText.Alpha = controlWithCurrent.Current.Disabled ? 0.3f : 1;
|
labelText.Alpha = controlWithCurrent.Current.Disabled ? 0.3f : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RestoreDefaultValueButton : Container, IHasTooltip
|
protected internal class RestoreDefaultValueButton : Container, IHasTooltip
|
||||||
{
|
{
|
||||||
private Bindable<T> bindable;
|
private Bindable<T> bindable;
|
||||||
|
|
||||||
@ -147,6 +147,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = SettingsPanel.CONTENT_MARGINS;
|
Width = SettingsPanel.CONTENT_MARGINS;
|
||||||
Alpha = 0f;
|
Alpha = 0f;
|
||||||
|
AlwaysPresent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
Loading…
Reference in New Issue
Block a user