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 6 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,64 @@
// 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.Bindables;
using osu.Game.Configuration;
using osu.Game.Rulesets.Edit;
using osuTK;
using osuTK.Input;

namespace osu.Game.Tests.Visual.Editing
{
[TestFixture]
public partial class TestSceneExpandingToolboxContainer : EditorClockTestScene
{
private ExpandingToolboxContainer toolbox = null!;
private Bindable<bool> contractSidebars = null!;

[SetUpSteps]
public void SetUpSteps()
{
AddStep("create toolbox", () =>
{
toolbox = new ExpandingToolboxContainer(50, 200)
{
RelativeSizeAxes = Axes.Y,
Size = new Vector2(200, 500),
};
Child = toolbox;
});
AddStep("load contractSidebars configuration", () =>
{
var config = new OsuConfigManager(LocalStorage);
contractSidebars = config.GetBindable<bool>(OsuSetting.EditorContractSidebars);
contractSidebars.Value = true;
});
}

[Test]
public void TestExpandingToolbox()
{
AddStep("state - sidebar collapsed", () => toolbox.Expanded.Value = false);
AddStep("click on toolbox", () =>
{
InputManager.MoveMouseTo(toolbox.ScreenSpaceDrawQuad.Centre);
InputManager.Click(MouseButton.Left);
AddAssert("sidebar expands after click", () => toolbox.Expanded.Value);

Check failure on line 49 in osu.Game.Tests/Visual/Editing/TestSceneExpandingToolboxContainer.cs

View workflow job for this annotation

GitHub Actions / Results

osu.Game.Tests.Visual.Editing.TestSceneExpandingToolboxContainer ► TestExpandingToolbox

Failed test found in: TestResults-Linux-MultiThreaded.trx TestResults-Linux-MultiThreaded.trx Error: sidebar expands after click
Raw output
sidebar expands after click
   at osu.Game.Tests.Visual.Editing.TestSceneExpandingToolboxContainer.<TestExpandingToolbox>b__3_1() in /home/runner/work/osu/osu/osu.Game.Tests/Visual/Editing/TestSceneExpandingToolboxContainer.cs:line 49
   at osu.Framework.Testing.Drawables.Steps.SingleStepButton.clickAction()
   at osu.Framework.Testing.Drawables.Steps.StepButton.PerformStep(Boolean userTriggered)
   at osu.Framework.Testing.TestScene.runNextStep(Action onCompletion, Action`2 onError, Func`2 stopCondition)
   at osu.Framework.Threading.ScheduledDelegate.RunTaskInternal()
   at osu.Framework.Threading.Scheduler.Update()
   at osu.Framework.Graphics.Drawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Platform.GameHost.UpdateFrame()
   at osu.Framework.Threading.GameThread.processFrame()
   at osu.Framework.Threading.GameThread.<createThread>g__runWork|70_0()

Check failure on line 49 in osu.Game.Tests/Visual/Editing/TestSceneExpandingToolboxContainer.cs

View workflow job for this annotation

GitHub Actions / Results

osu.Game.Tests.Visual.Editing.TestSceneExpandingToolboxContainer ► TestExpandingToolbox

Failed test found in: TestResults-Linux-SingleThread.trx TestResults-Linux-SingleThread.trx Error: sidebar expands after click
Raw output
sidebar expands after click
   at osu.Game.Tests.Visual.Editing.TestSceneExpandingToolboxContainer.<TestExpandingToolbox>b__3_1() in /home/runner/work/osu/osu/osu.Game.Tests/Visual/Editing/TestSceneExpandingToolboxContainer.cs:line 49
   at osu.Framework.Testing.Drawables.Steps.SingleStepButton.clickAction()
   at osu.Framework.Testing.Drawables.Steps.StepButton.PerformStep(Boolean userTriggered)
   at osu.Framework.Testing.TestScene.runNextStep(Action onCompletion, Action`2 onError, Func`2 stopCondition)
   at osu.Framework.Threading.ScheduledDelegate.RunTaskInternal()
   at osu.Framework.Threading.Scheduler.Update()
   at osu.Framework.Graphics.Drawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
   at osu.Framework.Platform.GameHost.UpdateFrame()
   at osu.Framework.Threading.GameThread.processFrame()
   at osu.Framework.Platform.ThreadRunner.RunMainLoop()
   at osu.Framework.Platform.GameHost.windowUpdate()
   at osu.Framework.Platform.GameHost.Run(Game game)

HenintsoaSky marked this conversation as resolved.
Show resolved Hide resolved
});

AddStep("state - sidebar collapsed", () => toolbox.Expanded.Value = false);

AddStep("hold and move cursor inside", () =>
{
InputManager.MoveMouseTo(toolbox.ScreenSpaceDrawQuad.TopLeft);
InputManager.PressButton(MouseButton.Left);
InputManager.MoveMouseTo(toolbox.ScreenSpaceDrawQuad.BottomRight);
InputManager.ReleaseButton(MouseButton.Left);
AddAssert("sidebar remains collapsed", () => !toolbox.Expanded.Value);
});
}
}
}
14 changes: 13 additions & 1 deletion osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ protected override void Update()

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

protected override bool OnClick(ClickEvent e) => true;
protected override bool OnClick(ClickEvent e)
{
if (!ReceivePositionalInputAt(e.ScreenSpaceMousePosition)) return false;
HenintsoaSky marked this conversation as resolved.
Show resolved Hide resolved

base.OnClick(e);

if (contractSidebars.Value && !Expanded.Value)
{
Expanded.Value = true;
}

return true;
}
}
}
Loading