mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:02:55 +08:00
Allow SelectionHandler to provide custom context menu items without local hover check
This commit is contained in:
parent
0cc6d6d97c
commit
d041de63ce
@ -244,14 +244,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
#region Context Menu
|
#region Context Menu
|
||||||
|
|
||||||
public virtual MenuItem[] ContextMenuItems
|
public MenuItem[] ContextMenuItems
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!selectedBlueprints.Any(b => b.IsHovered))
|
if (!selectedBlueprints.Any(b => b.IsHovered))
|
||||||
return Array.Empty<MenuItem>();
|
return Array.Empty<MenuItem>();
|
||||||
|
|
||||||
var items = new List<MenuItem>
|
var items = new List<MenuItem>();
|
||||||
|
|
||||||
|
items.AddRange(GetContextMenuItemsForSelection(selectedBlueprints));
|
||||||
|
|
||||||
|
if (selectedBlueprints.Count == 1)
|
||||||
|
items.AddRange(selectedBlueprints[0].ContextMenuItems);
|
||||||
|
|
||||||
|
items.AddRange(new[]
|
||||||
{
|
{
|
||||||
new OsuMenuItem("Sound")
|
new OsuMenuItem("Sound")
|
||||||
{
|
{
|
||||||
@ -263,15 +270,20 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
new OsuMenuItem("Delete", MenuItemType.Destructive, deleteSelected),
|
new OsuMenuItem("Delete", MenuItemType.Destructive, deleteSelected),
|
||||||
};
|
});
|
||||||
|
|
||||||
if (selectedBlueprints.Count == 1)
|
|
||||||
items.AddRange(selectedBlueprints[0].ContextMenuItems);
|
|
||||||
|
|
||||||
return items.ToArray();
|
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 virtual IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint> selection)
|
||||||
|
=> Enumerable.Empty<MenuItem>();
|
||||||
|
|
||||||
private MenuItem createHitSampleMenuItem(string name, string sampleName)
|
private MenuItem createHitSampleMenuItem(string name, string sampleName)
|
||||||
{
|
{
|
||||||
return new TernaryStateMenuItem(name, MenuItemType.Standard, setHitSampleState)
|
return new TernaryStateMenuItem(name, MenuItemType.Standard, setHitSampleState)
|
||||||
|
Loading…
Reference in New Issue
Block a user