1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:43:04 +08:00

Revert "Provide context menu items at BlueprintContainer for out-of-bounds support"

This reverts commit 85fc218edf.
This commit is contained in:
Salman Ahmed 2022-06-14 00:02:02 +03:00
parent 20e7f32fd9
commit 9fc04924eb
4 changed files with 28 additions and 34 deletions

View File

@ -11,14 +11,11 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Edit;
using osuTK;
using osuTK.Input;
@ -29,7 +26,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// A container which provides a "blueprint" display of items.
/// Includes selection and manipulation support via a <see cref="Components.SelectionHandler{T}"/>.
/// </summary>
public abstract class BlueprintContainer<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IHasContextMenu
public abstract class BlueprintContainer<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>
where T : class
{
protected DragBox DragBox { get; private set; }
@ -537,30 +534,5 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
#endregion
#region Context Menu
public MenuItem[] ContextMenuItems
{
get
{
var selectedBlueprints = SelectionHandler.SelectedBlueprints;
if (!selectedBlueprints.Any(b => b.IsHovered))
return Array.Empty<MenuItem>();
var items = new List<MenuItem>();
items.AddRange(SelectionHandler.GetContextMenuItemsForSelection(selectedBlueprints));
if (selectedBlueprints.Count == 1)
items.AddRange(selectedBlueprints[0].ContextMenuItems);
items.Add(new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, SelectionHandler.DeleteSelected));
return items.ToArray();
}
}
#endregion
}
}

View File

@ -165,7 +165,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary>
/// <param name="selection">The current selection.</param>
/// <returns>The relevant menu items.</returns>
protected internal override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<HitObject>> selection)
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<HitObject>> selection)
{
if (SelectedBlueprints.All(b => b.Item is IHasComboInformation))
{

View File

@ -8,6 +8,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
@ -16,6 +17,7 @@ using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Edit;
using osuTK;
using osuTK.Input;
@ -25,7 +27,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary>
/// A component which outlines items and handles movement of selections.
/// </summary>
public abstract class SelectionHandler<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IKeyBindingHandler<GlobalAction>
public abstract class SelectionHandler<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IKeyBindingHandler<GlobalAction>, IHasContextMenu
{
/// <summary>
/// The currently selected blueprints.
@ -290,7 +292,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
return true;
}
protected internal void DeleteSelected()
protected void DeleteSelected()
{
DeleteItems(selectedBlueprints.Select(b => b.Item));
}
@ -343,12 +345,32 @@ namespace osu.Game.Screens.Edit.Compose.Components
#region Context Menu
public MenuItem[] ContextMenuItems
{
get
{
if (!SelectedBlueprints.Any(b => b.IsHovered))
return Array.Empty<MenuItem>();
var items = new List<MenuItem>();
items.AddRange(GetContextMenuItemsForSelection(SelectedBlueprints));
if (SelectedBlueprints.Count == 1)
items.AddRange(SelectedBlueprints[0].ContextMenuItems);
items.Add(new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, DeleteSelected));
return items.ToArray();
}
}
/// <summary>
/// Provide context menu items relevant to current selection. Calling base is not required.
/// </summary>
/// <param name="selection">The current selection.</param>
/// <returns>The relevant menu items.</returns>
protected internal virtual IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<T>> selection)
protected virtual IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<T>> selection)
=> Enumerable.Empty<MenuItem>();
#endregion

View File

@ -180,7 +180,7 @@ namespace osu.Game.Skinning.Editor
protected override void DeleteItems(IEnumerable<ISkinnableDrawable> items) =>
skinEditor.DeleteItems(items.ToArray());
protected internal override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection)
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection)
{
var closestItem = new TernaryStateRadioMenuItem("Closest", MenuItemType.Standard, _ => applyClosestAnchors())
{