Skip to content

Commit

Permalink
Merge pull request #25304 from peppy/fix-click-through-timeline
Browse files Browse the repository at this point in the history
Fix right clicks on timeline potentially not working as expected
  • Loading branch information
bdach committed Oct 30, 2023
2 parents fbba378 + b2d3aa9 commit 30ffb15
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
45 changes: 44 additions & 1 deletion osu.Game.Tests/Visual/Editing/TestSceneTimelineSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
Expand Down Expand Up @@ -44,6 +46,47 @@ private void moveMouseToObject(Func<HitObject> targetFunc)
});
}

[Test]
public void TestContextMenuWithObjectBehind()
{
TimelineHitObjectBlueprint blueprint;

AddStep("add object", () =>
{
EditorBeatmap.Add(new HitCircle { StartTime = 3000 });
});

AddStep("enter slider placement", () =>
{
InputManager.Key(Key.Number3);
InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre);
});

AddStep("start conflicting slider", () =>
{
InputManager.Click(MouseButton.Left);
blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().First();
InputManager.MoveMouseTo(blueprint.ScreenSpaceDrawQuad.TopLeft - new Vector2(10, 0));
});

AddStep("end conflicting slider", () =>
{
InputManager.Click(MouseButton.Right);
});

AddStep("click object", () =>
{
InputManager.Key(Key.Number1);
blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().First();
InputManager.MoveMouseTo(blueprint);
InputManager.Click(MouseButton.Left);
});

AddStep("right click", () => InputManager.Click(MouseButton.Right));
AddAssert("context menu open", () => this.ChildrenOfType<OsuContextMenu>().SingleOrDefault()?.State == MenuState.Open);
}

[Test]
public void TestNudgeSelection()
{
Expand Down Expand Up @@ -139,7 +182,7 @@ public void TestBasicDeselect()

AddStep("click away", () =>
{
InputManager.MoveMouseTo(Editor.ChildrenOfType<TimelineArea>().Single().ScreenSpaceDrawQuad.TopLeft + Vector2.One);
InputManager.MoveMouseTo(Editor.ChildrenOfType<Timeline>().First().ScreenSpaceDrawQuad.TopLeft + new Vector2(5));
InputManager.Click(MouseButton.Left);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ public partial class ComposeBlueprintContainer : EditorBlueprintContainer

public PlacementBlueprint CurrentPlacement { get; private set; }

[Resolved(canBeNull: true)]
private EditorScreenWithTimeline editorScreen { get; set; }

/// <remarks>
/// Positional input must be received outside the container's bounds,
/// in order to handle composer blueprints which are partially offscreen.
/// </remarks>
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => editorScreen?.MainContent.ReceivePositionalInputAt(screenSpacePos) ?? base.ReceivePositionalInputAt(screenSpacePos);

public ComposeBlueprintContainer(HitObjectComposer composer)
: base(composer)
Expand Down
13 changes: 7 additions & 6 deletions osu.Game/Screens/Edit/EditorScreenWithTimeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

namespace osu.Game.Screens.Edit
{
[Cached]
public abstract partial class EditorScreenWithTimeline : EditorScreen
{
public const float PADDING = 10;

private Container timelineContainer = null!;
public Container TimelineContent { get; private set; } = null!;

private Container mainContent = null!;
public Container MainContent { get; private set; } = null!;

private LoadingSpinner spinner = null!;

Expand Down Expand Up @@ -70,7 +71,7 @@ private void load(OverlayColourProvider colourProvider)
{
new Drawable[]
{
timelineContainer = new Container
TimelineContent = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Expand All @@ -93,7 +94,7 @@ private void load(OverlayColourProvider colourProvider)
},
new Drawable[]
{
mainContent = new Container
MainContent = new Container
{
Name = "Main content",
RelativeSizeAxes = Axes.Both,
Expand All @@ -116,10 +117,10 @@ protected override void LoadComplete()
{
spinner.State.Value = Visibility.Hidden;
mainContent.Add(content);
MainContent.Add(content);
content.FadeInFromZero(300, Easing.OutQuint);
LoadComponentAsync(new TimelineArea(CreateTimelineContent()), timelineContainer.Add);
LoadComponentAsync(new TimelineArea(CreateTimelineContent()), TimelineContent.Add);
});
}

Expand Down

0 comments on commit 30ffb15

Please sign in to comment.