Skip to content

Commit

Permalink
Merge pull request ppy#18180 from frenzibyte/fix-toolbox-double-tap
Browse files Browse the repository at this point in the history
Fix `SettingsToolboxGroup` not clearing transforms before updating autosize
  • Loading branch information
smoogipoo authored May 10, 2022
2 parents 8a559ff + beb86a7 commit 886a481
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 57 deletions.
57 changes: 0 additions & 57 deletions osu.Game.Tests/Visual/Gameplay/TestSceneReplaySettingsOverlay.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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.Graphics;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays;
using osu.Game.Overlays.Settings;
using osuTK.Input;

namespace osu.Game.Tests.Visual.UserInterface
{
[TestFixture]
public class TestSceneSettingsToolboxGroup : OsuManualInputManagerTestScene
{
private SettingsToolboxGroup group;

[SetUp]
public void SetUp() => Schedule(() =>
{
Child = group = new SettingsToolboxGroup("example")
{
Children = new Drawable[]
{
new RoundedButton
{
RelativeSizeAxes = Axes.X,
Text = @"Button",
Enabled = { Value = true },
},
new OsuCheckbox
{
LabelText = @"Checkbox",
},
new OutlinedTextBox
{
RelativeSizeAxes = Axes.X,
Height = 30,
PlaceholderText = @"Textbox",
}
},
};
});

[Test]
public void TestClickExpandButtonMultipleTimes()
{
AddAssert("group expanded by default", () => group.Expanded.Value);
AddStep("click expand button multiple times", () =>
{
InputManager.MoveMouseTo(group.ChildrenOfType<IconButton>().Single());
Scheduler.AddDelayed(() => InputManager.Click(MouseButton.Left), 100);
Scheduler.AddDelayed(() => InputManager.Click(MouseButton.Left), 200);
Scheduler.AddDelayed(() => InputManager.Click(MouseButton.Left), 300);
});
AddAssert("group contracted", () => !group.Expanded.Value);
}
}
}
4 changes: 4 additions & 0 deletions osu.Game/Overlays/SettingsToolboxGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ protected override bool OnInvalidate(Invalidation invalidation, InvalidationSour

private void updateExpandedState(ValueChangedEvent<bool> expanded)
{
// clearing transforms is necessary to avoid a previous height transform
// potentially continuing to get processed while content has changed to autosize.
content.ClearTransforms();

if (expanded.NewValue)
content.AutoSizeAxes = Axes.Y;
else
Expand Down

0 comments on commit 886a481

Please sign in to comment.