Add chevron to distinguish all menus with submenus

This commit is contained in:
Joseph Madamba 2024-04-24 00:19:10 -07:00
parent 669b92a8e4
commit f97c519451
2 changed files with 23 additions and 23 deletions

View File

@ -3,6 +3,7 @@
#nullable disable
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -12,6 +13,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Graphics.UserInterface
@ -40,6 +42,27 @@ namespace osu.Game.Graphics.UserInterface
AddInternal(hoverClickSounds = new HoverClickSounds());
updateTextColour();
bool hasSubmenu = Item.Items.Any();
// Only add right chevron if direction of menu items is vertical (i.e. width is relative size, see `DrawableMenuItem.SetFlowDirection()`).
if (hasSubmenu && RelativeSizeAxes == Axes.X)
{
AddInternal(new SpriteIcon
{
Margin = new MarginPadding(6),
Size = new Vector2(8),
Icon = FontAwesome.Solid.ChevronRight,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
});
text.Padding = new MarginPadding
{
// Add some padding for the chevron above.
Right = 5,
};
}
}
protected override void LoadComplete()

View File

@ -185,17 +185,6 @@ 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]
private void load(OverlayColourProvider colourProvider)
{
@ -203,18 +192,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
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,
});
}
}
}
}