-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
FormSliderBar.Instantaneous
with TransferValueOnCommit
Rather than control the propagation of the value between the slider and the textbox, add a property that controls the propagation of the value between the bindables inside the form control to external bindables. This will help alleviate issues where the external bindable update incurs overheads due to having heavy change callbacks attached.
- Loading branch information
Showing
3 changed files
with
116 additions
and
44 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
osu.Game.Tests/Visual/UserInterface/TestSceneFormSliderBar.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,63 @@ | ||
// 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 NUnit.Framework; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Extensions.ObjectExtensions; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Graphics.UserInterfaceV2; | ||
using osu.Game.Overlays; | ||
using osuTK; | ||
|
||
namespace osu.Game.Tests.Visual.UserInterface | ||
{ | ||
public partial class TestSceneFormSliderBar : OsuTestScene | ||
{ | ||
[Cached] | ||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine); | ||
|
||
[Test] | ||
public void TestTransferValueOnCommit() | ||
{ | ||
OsuSpriteText text; | ||
FormSliderBar<float> slider = null!; | ||
|
||
AddStep("create content", () => | ||
{ | ||
Child = new FillFlowContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Width = 0.5f, | ||
Direction = FillDirection.Vertical, | ||
Spacing = new Vector2(10), | ||
Children = new Drawable[] | ||
{ | ||
text = new OsuSpriteText(), | ||
slider = new FormSliderBar<float> | ||
{ | ||
Caption = "Slider", | ||
Current = new BindableFloat | ||
{ | ||
MinValue = 0, | ||
MaxValue = 10, | ||
Precision = 0.1f, | ||
Default = 5f, | ||
} | ||
}, | ||
} | ||
}; | ||
slider.Current.BindValueChanged(_ => text.Text = $"Current value is: {slider.Current.Value}", true); | ||
}); | ||
AddToggleStep("toggle transfer value on commit", b => | ||
{ | ||
if (slider.IsNotNull()) | ||
slider.TransferValueOnCommit = b; | ||
}); | ||
} | ||
} | ||
} |
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