From f97c519451e0b17c95309f2d78bbddd30614e5c9 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 24 Apr 2024 00:19:10 -0700 Subject: [PATCH 1/3] Add chevron to distinguish all menus with submenus --- .../UserInterface/DrawableOsuMenuItem.cs | 23 +++++++++++++++++++ .../Edit/Components/Menus/EditorMenuBar.cs | 23 ------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs index 2f2cb7e5f8..06ef75cf58 100644 --- a/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs @@ -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() diff --git a/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs b/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs index 152bcee214..c410c2519b 100644 --- a/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs +++ b/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs @@ -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, - }); - } } } } From 5f463b81a8ecc883ed8040cacf70139e11b042dd Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 24 Apr 2024 00:22:20 -0700 Subject: [PATCH 2/3] Remove hardcoded chevrons in test --- osu.Game.Tests/Visual/UserInterface/TestSceneContextMenu.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneContextMenu.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneContextMenu.cs index 7b80549854..2a2f267fc8 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneContextMenu.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneContextMenu.cs @@ -77,21 +77,21 @@ namespace osu.Game.Tests.Visual.UserInterface new OsuMenuItem(@"Some option"), new OsuMenuItem(@"Highlighted option", MenuItemType.Highlighted), new OsuMenuItem(@"Another option"), - new OsuMenuItem(@"Nested option >") + new OsuMenuItem(@"Nested option") { Items = new MenuItem[] { new OsuMenuItem(@"Sub-One"), new OsuMenuItem(@"Sub-Two"), new OsuMenuItem(@"Sub-Three"), - new OsuMenuItem(@"Sub-Nested option >") + new OsuMenuItem(@"Sub-Nested option") { Items = new MenuItem[] { new OsuMenuItem(@"Double Sub-One"), new OsuMenuItem(@"Double Sub-Two"), new OsuMenuItem(@"Double Sub-Three"), - new OsuMenuItem(@"Sub-Sub-Nested option >") + new OsuMenuItem(@"Sub-Sub-Nested option") { Items = new MenuItem[] { From 4f7c9f297068b5ec27aaa3d34e8176d6e0e7fe1a Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 24 Apr 2024 01:00:03 -0700 Subject: [PATCH 3/3] Remove unused using --- osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs b/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs index c410c2519b..0e125d0ec0 100644 --- a/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs +++ b/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . 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;