mirror of
https://github.com/ppy/osu.git
synced 2025-01-09 02:24:10 +08:00
Merge pull request #29279 from normalid-awa/bugfix/editor/delete-operation-wont-close-the-menu
Close context menus when deselecting items in editor
This commit is contained in:
commit
437812eebe
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
});
|
});
|
||||||
|
|
||||||
moveMouseToHitObject(1);
|
moveMouseToHitObject(1);
|
||||||
AddAssert("merge option available", () => selectionHandler.ContextMenuItems?.Any(o => o.Text.Value == "Merge selection") == true);
|
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
|
||||||
|
|
||||||
mergeSelection();
|
mergeSelection();
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
});
|
});
|
||||||
|
|
||||||
moveMouseToHitObject(1);
|
moveMouseToHitObject(1);
|
||||||
AddAssert("merge option not available", () => selectionHandler.ContextMenuItems?.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection"));
|
AddAssert("merge option not available", () => selectionHandler.ContextMenuItems.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection"));
|
||||||
mergeSelection();
|
mergeSelection();
|
||||||
AddAssert("circles not merged", () => circle1 is not null && circle2 is not null
|
AddAssert("circles not merged", () => circle1 is not null && circle2 is not null
|
||||||
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
|
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
|
||||||
@ -222,7 +222,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
});
|
});
|
||||||
|
|
||||||
moveMouseToHitObject(1);
|
moveMouseToHitObject(1);
|
||||||
AddAssert("merge option available", () => selectionHandler.ContextMenuItems?.Any(o => o.Text.Value == "Merge selection") == true);
|
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
|
||||||
|
|
||||||
mergeSelection();
|
mergeSelection();
|
||||||
|
|
||||||
|
@ -52,10 +52,7 @@ namespace osu.Game.Tests.Editing
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Child = composer = new TestHitObjectComposer();
|
||||||
{
|
|
||||||
composer = new TestHitObjectComposer()
|
|
||||||
};
|
|
||||||
|
|
||||||
BeatDivisor.Value = 1;
|
BeatDivisor.Value = 1;
|
||||||
|
|
||||||
|
@ -8,16 +8,24 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.Cursor
|
namespace osu.Game.Graphics.Cursor
|
||||||
{
|
{
|
||||||
|
[Cached(typeof(OsuContextMenuContainer))]
|
||||||
public partial class OsuContextMenuContainer : ContextMenuContainer
|
public partial class OsuContextMenuContainer : ContextMenuContainer
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
private OsuContextMenuSamples samples = new OsuContextMenuSamples();
|
private OsuContextMenuSamples samples = new OsuContextMenuSamples();
|
||||||
|
|
||||||
|
private OsuContextMenu menu = null!;
|
||||||
|
|
||||||
public OsuContextMenuContainer()
|
public OsuContextMenuContainer()
|
||||||
{
|
{
|
||||||
AddInternal(samples);
|
AddInternal(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Menu CreateMenu() => new OsuContextMenu(true);
|
protected override Menu CreateMenu() => menu = new OsuContextMenu(true);
|
||||||
|
|
||||||
|
public void CloseMenu()
|
||||||
|
{
|
||||||
|
menu.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -16,6 +14,7 @@ using osu.Framework.Graphics.UserInterface;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
@ -50,14 +49,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private readonly List<SelectionBlueprint<T>> selectedBlueprints;
|
private readonly List<SelectionBlueprint<T>> selectedBlueprints;
|
||||||
|
|
||||||
protected SelectionBox SelectionBox { get; private set; }
|
protected SelectionBox SelectionBox { get; private set; } = null!;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
protected IEditorChangeHandler ChangeHandler { get; private set; }
|
protected IEditorChangeHandler? ChangeHandler { get; private set; }
|
||||||
|
|
||||||
public SelectionRotationHandler RotationHandler { get; private set; }
|
public SelectionRotationHandler RotationHandler { get; private set; } = null!;
|
||||||
|
|
||||||
public SelectionScaleHandler ScaleHandler { get; private set; }
|
public SelectionScaleHandler ScaleHandler { get; private set; } = null!;
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
protected OsuContextMenuContainer? ContextMenuContainer { get; private set; }
|
||||||
|
|
||||||
protected SelectionHandler()
|
protected SelectionHandler()
|
||||||
{
|
{
|
||||||
@ -230,7 +232,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deselect all selected items.
|
/// Deselect all selected items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void DeselectAll() => SelectedItems.Clear();
|
protected void DeselectAll()
|
||||||
|
{
|
||||||
|
SelectedItems.Clear();
|
||||||
|
ContextMenuContainer?.CloseMenu();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle a blueprint becoming selected.
|
/// Handle a blueprint becoming selected.
|
||||||
@ -243,6 +249,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
SelectedItems.Add(blueprint.Item);
|
SelectedItems.Add(blueprint.Item);
|
||||||
|
|
||||||
selectedBlueprints.Add(blueprint);
|
selectedBlueprints.Add(blueprint);
|
||||||
|
|
||||||
|
ContextMenuContainer?.CloseMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
@ -159,7 +160,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private string lastSavedHash;
|
private string lastSavedHash;
|
||||||
|
|
||||||
private Container<EditorScreen> screenContainer;
|
private ScreenContainer screenContainer;
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private readonly EditorLoader loader;
|
private readonly EditorLoader loader;
|
||||||
@ -329,7 +330,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
Name = "Screen container",
|
Name = "Screen container",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Top = 40, Bottom = 50 },
|
Padding = new MarginPadding { Top = 40, Bottom = 50 },
|
||||||
Child = screenContainer = new Container<EditorScreen>
|
Child = screenContainer = new ScreenContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
}
|
}
|
||||||
@ -422,6 +423,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
MutationTracker,
|
MutationTracker,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
|
|
||||||
@ -1007,7 +1009,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode");
|
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentAsync(currentScreen, newScreen =>
|
screenContainer.LoadComponentAsync(currentScreen, newScreen =>
|
||||||
{
|
{
|
||||||
if (newScreen == currentScreen)
|
if (newScreen == currentScreen)
|
||||||
{
|
{
|
||||||
@ -1385,5 +1387,12 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private partial class ScreenContainer : Container<EditorScreen>
|
||||||
|
{
|
||||||
|
public new Task LoadComponentAsync<TLoadable>([NotNull] TLoadable component, Action<TLoadable> onLoaded = null, CancellationToken cancellation = default, Scheduler scheduler = null)
|
||||||
|
where TLoadable : Drawable
|
||||||
|
=> base.LoadComponentAsync(component, onLoaded, cancellation, scheduler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user