1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Add a chevron to distinguish editor menus with submenus

This commit is contained in:
Dean Herbert 2024-04-23 21:32:32 +08:00
parent 777081e941
commit 436203a8c1
No known key found for this signature in database

View File

@ -1,6 +1,7 @@
// 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.
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -184,6 +185,17 @@ namespace osu.Game.Screens.Edit.Components.Menus
{ {
} }
private bool hasSubmenu => Item.Items.Any();
protected override TextContainer CreateTextContainer() => base.CreateTextContainer().With(c =>
{
c.Padding = new MarginPadding
{
// Add some padding for the chevron below.
Right = hasSubmenu ? 5 : 0,
};
});
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
{ {
@ -191,6 +203,18 @@ namespace osu.Game.Screens.Edit.Components.Menus
BackgroundColourHover = colourProvider.Background1; BackgroundColourHover = colourProvider.Background1;
Foreground.Padding = new MarginPadding { Vertical = 2 }; Foreground.Padding = new MarginPadding { Vertical = 2 };
if (hasSubmenu)
{
AddInternal(new SpriteIcon
{
Margin = new MarginPadding(6),
Size = new Vector2(8),
Icon = FontAwesome.Solid.ChevronRight,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
});
}
} }
} }
} }