mirror of
https://github.com/ppy/osu
synced 2024-12-27 17:32:56 +00:00
Allow context menus to have visible spacers
This commit is contained in:
parent
3d569850b1
commit
405ab499e9
@ -34,51 +34,51 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
new MenuItem("File")
|
||||
{
|
||||
Items = new[]
|
||||
Items = new OsuMenuItem[]
|
||||
{
|
||||
new EditorMenuItem("Clear All Notes"),
|
||||
new EditorMenuItem("Open Difficulty..."),
|
||||
new EditorMenuItem("Save"),
|
||||
new EditorMenuItem("Create a new Difficulty..."),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Revert to Saved"),
|
||||
new EditorMenuItem("Revert to Saved (Full)"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Test Beatmap"),
|
||||
new EditorMenuItem("Open AiMod"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Upload Beatmap..."),
|
||||
new EditorMenuItem("Export Package"),
|
||||
new EditorMenuItem("Export Map Package"),
|
||||
new EditorMenuItem("Import from..."),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Open Song Folder"),
|
||||
new EditorMenuItem("Open .osu in Notepad"),
|
||||
new EditorMenuItem("Open .osb in Notepad"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Exit"),
|
||||
}
|
||||
},
|
||||
new MenuItem("Timing")
|
||||
{
|
||||
Items = new[]
|
||||
Items = new OsuMenuItem[]
|
||||
{
|
||||
new EditorMenuItem("Time Signature"),
|
||||
new EditorMenuItem("Metronome Clicks"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Add Timing Section"),
|
||||
new EditorMenuItem("Add Inheriting Section"),
|
||||
new EditorMenuItem("Reset Current Section"),
|
||||
new EditorMenuItem("Delete Timing Section"),
|
||||
new EditorMenuItem("Resnap Current Section"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Timing Setup"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Resnap All Notes", MenuItemType.Destructive),
|
||||
new EditorMenuItem("Move all notes in time...", MenuItemType.Destructive),
|
||||
new EditorMenuItem("Recalculate Slider Lengths", MenuItemType.Destructive),
|
||||
new EditorMenuItem("Delete All Timing Sections", MenuItemType.Destructive),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Set Current Position as Preview Point"),
|
||||
}
|
||||
},
|
||||
|
@ -6,13 +6,15 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -78,6 +80,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
case StatefulMenuItem stateful:
|
||||
return new DrawableStatefulMenuItem(stateful);
|
||||
|
||||
case OsuMenuItemSpacer spacer:
|
||||
return new DrawableSpacer(spacer);
|
||||
}
|
||||
|
||||
return new DrawableOsuMenuItem(item);
|
||||
@ -89,5 +94,28 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Anchor = Direction == Direction.Horizontal ? Anchor.BottomLeft : Anchor.TopRight
|
||||
};
|
||||
|
||||
protected partial class DrawableSpacer : DrawableOsuMenuItem
|
||||
{
|
||||
public DrawableSpacer(MenuItem item)
|
||||
: base(item)
|
||||
{
|
||||
Scale = new Vector2(1, 0.6f);
|
||||
|
||||
AddInternal(new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = BackgroundColourHover,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 2f,
|
||||
Width = 0.8f,
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e) => true;
|
||||
|
||||
protected override bool OnClick(ClickEvent e) => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
osu.Game/Graphics/UserInterface/OsuMenuItemSpacer.cs
Normal file
13
osu.Game/Graphics/UserInterface/OsuMenuItemSpacer.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuMenuItemSpacer : OsuMenuItem
|
||||
{
|
||||
public OsuMenuItemSpacer()
|
||||
: base(" ")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -151,23 +151,23 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
{
|
||||
new MenuItem(CommonStrings.MenuBarFile)
|
||||
{
|
||||
Items = new[]
|
||||
Items = new OsuMenuItem[]
|
||||
{
|
||||
new EditorMenuItem(Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()),
|
||||
new EditorMenuItem(CommonStrings.Export, MenuItemType.Standard, () => skins.ExportCurrentSkin()) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new RevertConfirmDialog(revert))),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()),
|
||||
},
|
||||
},
|
||||
new MenuItem(CommonStrings.MenuBarEdit)
|
||||
{
|
||||
Items = new[]
|
||||
Items = new OsuMenuItem[]
|
||||
{
|
||||
undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo),
|
||||
redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
cutMenuItem = new EditorMenuItem(CommonStrings.Cut, MenuItemType.Standard, Cut),
|
||||
copyMenuItem = new EditorMenuItem(CommonStrings.Copy, MenuItemType.Standard, Copy),
|
||||
pasteMenuItem = new EditorMenuItem(CommonStrings.Paste, MenuItemType.Standard, Paste),
|
||||
|
@ -14,7 +14,6 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit.Components.Menus;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Utils;
|
||||
@ -249,7 +248,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
Items = createAnchorItems((d, o) => ((Drawable)d).Origin == o, applyOrigins).ToArray()
|
||||
};
|
||||
|
||||
yield return new EditorMenuItemSpacer();
|
||||
yield return new OsuMenuItemSpacer();
|
||||
|
||||
yield return new OsuMenuItem("Reset position", MenuItemType.Standard, () =>
|
||||
{
|
||||
@ -277,13 +276,13 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
}
|
||||
});
|
||||
|
||||
yield return new EditorMenuItemSpacer();
|
||||
yield return new OsuMenuItemSpacer();
|
||||
|
||||
yield return new OsuMenuItem("Bring to front", MenuItemType.Standard, () => skinEditor.BringSelectionToFront());
|
||||
|
||||
yield return new OsuMenuItem("Send to back", MenuItemType.Standard, () => skinEditor.SendSelectionToBack());
|
||||
|
||||
yield return new EditorMenuItemSpacer();
|
||||
yield return new OsuMenuItemSpacer();
|
||||
|
||||
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
||||
yield return item;
|
||||
|
@ -4,11 +4,9 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
@ -151,7 +149,7 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
||||
{
|
||||
switch (item)
|
||||
{
|
||||
case EditorMenuItemSpacer spacer:
|
||||
case OsuMenuItemSpacer spacer:
|
||||
return new DrawableSpacer(spacer);
|
||||
|
||||
case StatefulMenuItem stateful:
|
||||
@ -195,29 +193,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
||||
Foreground.Padding = new MarginPadding { Vertical = 2 };
|
||||
}
|
||||
}
|
||||
|
||||
private partial class DrawableSpacer : DrawableOsuMenuItem
|
||||
{
|
||||
public DrawableSpacer(MenuItem item)
|
||||
: base(item)
|
||||
{
|
||||
Scale = new Vector2(1, 0.6f);
|
||||
|
||||
AddInternal(new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = BackgroundColourHover,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 2f,
|
||||
Width = 0.8f,
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e) => true;
|
||||
|
||||
protected override bool OnClick(ClickEvent e) => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Menus
|
||||
{
|
||||
public class EditorMenuItemSpacer : EditorMenuItem
|
||||
{
|
||||
public EditorMenuItemSpacer()
|
||||
: base(" ")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -321,7 +321,7 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo),
|
||||
redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
cutMenuItem = new EditorMenuItem(CommonStrings.Cut, MenuItemType.Standard, Cut),
|
||||
copyMenuItem = new EditorMenuItem(CommonStrings.Copy, MenuItemType.Standard, Copy),
|
||||
pasteMenuItem = new EditorMenuItem(CommonStrings.Paste, MenuItemType.Standard, Paste),
|
||||
@ -1005,12 +1005,12 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
createDifficultyCreationMenu(),
|
||||
createDifficultySwitchMenu(),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem(EditorStrings.DeleteDifficulty, MenuItemType.Standard, deleteDifficulty) { Action = { Disabled = Beatmap.Value.BeatmapSetInfo.Beatmaps.Count < 2 } },
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem(WebCommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()),
|
||||
createExportMenu(),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, this.Exit)
|
||||
};
|
||||
|
||||
@ -1130,7 +1130,7 @@ namespace osu.Game.Screens.Edit
|
||||
foreach (var rulesetBeatmaps in groupedOrderedBeatmaps)
|
||||
{
|
||||
if (difficultyItems.Count > 0)
|
||||
difficultyItems.Add(new EditorMenuItemSpacer());
|
||||
difficultyItems.Add(new OsuMenuItemSpacer());
|
||||
|
||||
foreach (var beatmap in rulesetBeatmaps)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user