Skip to content

Commit

Permalink
Merge pull request #26585 from frenzibyte/fix-editor-ux
Browse files Browse the repository at this point in the history
Fix timing point changes not applying after selecting another one
  • Loading branch information
peppy authored Jan 17, 2024
2 parents 5cb17bc + 1af5d14 commit 6a8a45b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
39 changes: 39 additions & 0 deletions osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#nullable disable

using System;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
Expand Down Expand Up @@ -177,6 +179,43 @@ public void TestScrollControlGroupIntoView()
AddUntilStep("Scrolled to end", () => timingScreen.ChildrenOfType<OsuScrollContainer>().First().IsScrolledToEnd());
}

[Test]
public void TestEditThenClickAwayAppliesChanges()
{
AddStep("Add two control points", () =>
{
editorBeatmap.ControlPointInfo.Clear();
editorBeatmap.ControlPointInfo.Add(1000, new TimingControlPoint());
editorBeatmap.ControlPointInfo.Add(2000, new TimingControlPoint());
});

AddStep("Select second timing point", () =>
{
InputManager.MoveMouseTo(Child.ChildrenOfType<TimingRowAttribute>().Last());
InputManager.Click(MouseButton.Left);
});

AddStep("Scroll to end", () => timingScreen.ChildrenOfType<ControlPointSettings>().Single().ChildrenOfType<OsuScrollContainer>().Single().ScrollToEnd(false));
AddStep("Modify time signature", () =>
{
var timeSignatureTextBox = Child.ChildrenOfType<LabelledTimeSignature.TimeSignatureBox>().Single().ChildrenOfType<TextBox>().Single();
InputManager.MoveMouseTo(timeSignatureTextBox);
InputManager.Click(MouseButton.Left);

Debug.Assert(!timeSignatureTextBox.Current.Value.Equals("1", StringComparison.Ordinal));
timeSignatureTextBox.Current.Value = "1";
});

AddStep("Select first timing point", () =>
{
InputManager.MoveMouseTo(Child.ChildrenOfType<TimingRowAttribute>().First());
InputManager.Click(MouseButton.Left);
});

AddAssert("Second timing point changed time signature", () => editorBeatmap.ControlPointInfo.TimingPoints.Last().TimeSignature.Numerator == 1);
AddAssert("First timing point preserved time signature", () => editorBeatmap.ControlPointInfo.TimingPoints.First().TimeSignature.Numerator == 4);
}

protected override void Dispose(bool isDisposing)
{
Beatmap.Disabled = false;
Expand Down
5 changes: 3 additions & 2 deletions osu.Game/Screens/Edit/Timing/ControlPointTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ public IEnumerable<ControlPointGroup> ControlGroups
{
BackgroundFlow.Add(new RowBackground(group)
{
Action = () =>
// schedule to give time for any modified focused text box to lose focus and commit changes (e.g. BPM / time signature textboxes) before switching to new point.
Action = () => Schedule(() =>
{
SetSelectedRow(group);
clock.SeekSmoothlyTo(group.Time);
}
})
});
}

Expand Down

0 comments on commit 6a8a45b

Please sign in to comment.