Skip to content

Commit

Permalink
Merge pull request #27974 from peppy/editor-menu-chev
Browse files Browse the repository at this point in the history
Add a chevron to distinguish editor menus with submenus
  • Loading branch information
bdach authored Apr 23, 2024
2 parents c454dd2 + 436203a commit a35bf77
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -184,13 +185,36 @@ 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)
{
BackgroundColour = colourProvider.Background2;
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,
});
}
}
}
}
Expand Down

0 comments on commit a35bf77

Please sign in to comment.