Merge pull request #27974 from peppy/editor-menu-chev

Add a chevron to distinguish editor menus with submenus
This commit is contained in:
Bartłomiej Dach 2024-04-23 18:12:08 +02:00 committed by GitHub
commit a35bf77131
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 0 deletions

View File

@ -1,6 +1,7 @@
// 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.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -184,6 +185,17 @@ public EditorMenuItem(MenuItem item)
{
}
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]
private void load(OverlayColourProvider colourProvider)
{
@ -191,6 +203,18 @@ private void load(OverlayColourProvider colourProvider)
BackgroundColourHover = colourProvider.Background1;
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,
});
}
}
}
}