mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Merge pull request #27178 from Joehuu/truncate-osu-dropdown-items
Truncate long dropdown menu item text and show tooltip
This commit is contained in:
commit
409dfd33e7
@ -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<BeatmapOnlineStatus>
|
||||
new OsuEnumDropdown<TestEnum>
|
||||
{
|
||||
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<GlobalAction>(new InputState(), GlobalAction.Back)));
|
||||
AddAssert("closed", () => dropdown().ChildrenOfType<Menu>().Single().State == MenuState.Closed);
|
||||
|
||||
OsuEnumDropdown<BeatmapOnlineStatus> dropdown() => this.ChildrenOfType<OsuEnumDropdown<BeatmapOnlineStatus>>().First();
|
||||
OsuEnumDropdown<TestEnum> dropdown() => this.ChildrenOfType<OsuEnumDropdown<TestEnum>>().First();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user