Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make editor sidebar panel expand when clicked #31082

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Edit;
using osuTK.Input;

namespace osu.Game.Tests.Visual.Editing
{
[TestFixture]
public partial class TestSceneExpandingToolboxContainer : OsuManualInputManagerTestScene
{
private ExpandingToolboxContainer toolbox = null!;

[SetUpSteps]
public void SetUpSteps()
{
AddStep("create toolbox", () =>
{
toolbox = new ExpandingToolboxContainer(50, 200)
{
Child = new Box
{
RelativeSizeAxes = Axes.X,
Height = 1000,
Colour = Colour4.Red,
}
};
Child = toolbox;
});
}

[Test]
public void TestExpandingToolbox()
{
AddStep("collapse toolbox", () => toolbox.Expanded.Value = false);
AddStep("click on toolbox", () =>
{
InputManager.MoveMouseTo(toolbox.ScreenSpaceDrawQuad.Centre);
InputManager.Click(MouseButton.Left);
});
AddUntilStep("toolbox expanded", () => toolbox.Expanded.Value);

AddStep("collapse toolbox", () => toolbox.Expanded.Value = false);
AddStep("drag cursor inside", () =>
{
InputManager.MoveMouseTo(toolbox.ScreenSpaceDrawQuad.TopLeft);
InputManager.PressButton(MouseButton.Left);
InputManager.MoveMouseTo(toolbox.ScreenSpaceDrawQuad.BottomRight);
InputManager.ReleaseButton(MouseButton.Left);
});
AddAssert("toolbox remains collapsed", () => !toolbox.Expanded.Value);
}
}
}
10 changes: 10 additions & 0 deletions osu.Game/Graphics/Containers/ExpandingContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ protected override bool OnHover(HoverEvent e)
return true;
}

protected override bool OnClick(ClickEvent e)
{
base.OnClick(e);

if (!Expanded.Value)
Expanded.Value = true;

return true;
}

protected override bool OnMouseMove(MouseMoveEvent e)
{
updateHoverExpansion();
Expand Down
2 changes: 0 additions & 2 deletions osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,5 @@ protected override void Update()
private bool anyToolboxHovered(Vector2 screenSpacePos) => FillFlow.ScreenSpaceDrawQuad.Contains(screenSpacePos);

protected override bool OnMouseDown(MouseDownEvent e) => true;

protected override bool OnClick(ClickEvent e) => true;
}
}
Loading