Enable distance snapping when DS value is changed via user interaction

This commit is contained in:
Dean Herbert 2022-10-26 13:37:01 +09:00
parent 7d59bc6e2f
commit 6b53ea3400
1 changed files with 12 additions and 1 deletions

View File

@ -89,8 +89,9 @@ private void load(OverlayColourProvider colourProvider)
{
distanceSpacingSlider = new ExpandableSlider<double, SizeSlider<double>>
{
Current = { BindTarget = DistanceSpacingMultiplier },
KeyboardStep = adjust_step,
// Manual binding in LoadComplete to handle one-way event flow.
Current = DistanceSpacingMultiplier.GetUnboundCopy(),
},
currentDistanceSpacingButton = new ExpandableButton
{
@ -101,6 +102,7 @@ private void load(OverlayColourProvider colourProvider)
Debug.Assert(objects != null);
DistanceSpacingMultiplier.Value = ReadCurrentDistanceSnap(objects.Value.before, objects.Value.after);
DistanceSnapToggle.Value = TernaryState.True;
},
RelativeSizeAxes = Axes.X,
}
@ -173,6 +175,14 @@ protected override void LoadComplete()
EditorBeatmap.BeatmapInfo.DistanceSpacing = multiplier.NewValue;
}, true);
// Manual binding to handle enabling distance spacing when the slider is interacted with.
distanceSpacingSlider.Current.BindValueChanged(spacing =>
{
DistanceSpacingMultiplier.Value = spacing.NewValue;
DistanceSnapToggle.Value = TernaryState.True;
});
DistanceSpacingMultiplier.BindValueChanged(spacing => distanceSpacingSlider.Current.Value = spacing.NewValue);
}
}
@ -245,6 +255,7 @@ protected virtual bool AdjustDistanceSpacing(GlobalAction action, float amount)
else if (action == GlobalAction.EditorDecreaseDistanceSpacing)
DistanceSpacingMultiplier.Value -= amount;
DistanceSnapToggle.Value = TernaryState.True;
return true;
}