From 401bd91dc4aefee2582055b798a471d240e17650 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 14 Feb 2024 22:57:38 -0800 Subject: [PATCH 1/2] Add visual test showing overflow on dropdown menu items --- .../Visual/UserInterface/TestSceneOsuDropdown.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs index 1678890b73..63f7a2f2cc 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Framework.Input.States; using osu.Framework.Testing; -using osu.Game.Beatmaps; using osu.Game.Graphics.UserInterface; using osu.Game.Input.Bindings; @@ -18,13 +17,22 @@ namespace osu.Game.Tests.Visual.UserInterface public partial class TestSceneOsuDropdown : ThemeComparisonTestScene { protected override Drawable CreateContent() => - new OsuEnumDropdown + new OsuEnumDropdown { Anchor = Anchor.Centre, Origin = Anchor.TopCentre, Width = 150 }; + private enum TestEnum + { + [System.ComponentModel.Description("Option")] + Option, + + [System.ComponentModel.Description("Really lonnnnnnng option")] + ReallyLongOption, + } + [Test] // todo: this can be written much better if ThemeComparisonTestScene has a manual input manager public void TestBackAction() @@ -43,7 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("press back", () => dropdown().OnPressed(new KeyBindingPressEvent(new InputState(), GlobalAction.Back))); AddAssert("closed", () => dropdown().ChildrenOfType().Single().State == MenuState.Closed); - OsuEnumDropdown dropdown() => this.ChildrenOfType>().First(); + OsuEnumDropdown dropdown() => this.ChildrenOfType>().First(); } } } From 3d08bc5605242c097531eae2945a89abe7f80955 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 14 Feb 2024 23:00:30 -0800 Subject: [PATCH 2/2] Truncate long dropdown menu item text and show tooltip --- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 2dc701dc9d..38e90bf4ea 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -186,6 +186,8 @@ namespace osu.Game.Graphics.UserInterface : base(item) { Foreground.Padding = new MarginPadding(2); + Foreground.AutoSizeAxes = Axes.Y; + Foreground.RelativeSizeAxes = Axes.X; Masking = true; CornerRadius = corner_radius; @@ -247,11 +249,12 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, }, - Label = new OsuSpriteText + Label = new TruncatingSpriteText { - X = 15, + Padding = new MarginPadding { Left = 15 }, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, + RelativeSizeAxes = Axes.X, }, }; }