-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25163 from Joehuu/double-click-slider-nub-default
Add ability to revert slider settings to default when double-clicking nub
- Loading branch information
Showing
5 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
osu.Game.Tests/Visual/UserInterface/TestSceneRoundedSliderBar.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 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.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Testing; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Overlays; | ||
using osuTK.Input; | ||
|
||
namespace osu.Game.Tests.Visual.UserInterface | ||
{ | ||
public partial class TestSceneRoundedSliderBar : OsuManualInputManagerTestScene | ||
{ | ||
[Cached] | ||
private OverlayColourProvider colourProvider { get; set; } = new OverlayColourProvider(OverlayColourScheme.Purple); | ||
|
||
private readonly BindableDouble current = new BindableDouble(5) | ||
{ | ||
Precision = 0.1f, | ||
MinValue = 0, | ||
MaxValue = 15 | ||
}; | ||
|
||
private RoundedSliderBar<double> slider = null!; | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
Child = slider = new RoundedSliderBar<double> | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Current = current, | ||
RelativeSizeAxes = Axes.X, | ||
Width = 0.4f | ||
}; | ||
} | ||
|
||
[Test] | ||
public void TestNubDoubleClickRevertToDefault() | ||
{ | ||
AddStep("set slider to 1", () => slider.Current.Value = 1); | ||
|
||
AddStep("move mouse to nub", () => InputManager.MoveMouseTo(slider.ChildrenOfType<Nub>().Single())); | ||
|
||
AddStep("double click nub", () => | ||
{ | ||
InputManager.Click(MouseButton.Left); | ||
InputManager.Click(MouseButton.Left); | ||
}); | ||
|
||
AddAssert("slider is default", () => slider.Current.IsDefault); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters