1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Add tooltips to truncated text

This commit is contained in:
Joseph Madamba 2023-06-08 17:11:17 -07:00
parent 519923e843
commit 85fedbd025
No known key found for this signature in database
GPG Key ID: 8B746C7BDDF0BD76
11 changed files with 38 additions and 36 deletions

View File

@ -106,12 +106,11 @@ namespace osu.Game.Beatmaps.Drawables.Cards
{ {
new Drawable[] new Drawable[]
{ {
new OsuSpriteText new TruncatingSpriteText
{ {
Text = new RomanisableString(BeatmapSet.TitleUnicode, BeatmapSet.Title), Text = new RomanisableString(BeatmapSet.TitleUnicode, BeatmapSet.Title),
Font = OsuFont.Default.With(size: 22.5f, weight: FontWeight.SemiBold), Font = OsuFont.Default.With(size: 22.5f, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true
}, },
titleBadgeArea = new FillFlowContainer titleBadgeArea = new FillFlowContainer
{ {
@ -140,21 +139,19 @@ namespace osu.Game.Beatmaps.Drawables.Cards
{ {
new[] new[]
{ {
new OsuSpriteText new TruncatingSpriteText
{ {
Text = createArtistText(), Text = createArtistText(),
Font = OsuFont.Default.With(size: 17.5f, weight: FontWeight.SemiBold), Font = OsuFont.Default.With(size: 17.5f, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true
}, },
Empty() Empty()
}, },
} }
}, },
new OsuSpriteText new TruncatingSpriteText
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
Text = BeatmapSet.Source, Text = BeatmapSet.Source,
Shadow = false, Shadow = false,
Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold), Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold),

View File

@ -107,12 +107,11 @@ namespace osu.Game.Beatmaps.Drawables.Cards
{ {
new Drawable[] new Drawable[]
{ {
new OsuSpriteText new TruncatingSpriteText
{ {
Text = new RomanisableString(BeatmapSet.TitleUnicode, BeatmapSet.Title), Text = new RomanisableString(BeatmapSet.TitleUnicode, BeatmapSet.Title),
Font = OsuFont.Default.With(size: 22.5f, weight: FontWeight.SemiBold), Font = OsuFont.Default.With(size: 22.5f, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true
}, },
titleBadgeArea = new FillFlowContainer titleBadgeArea = new FillFlowContainer
{ {
@ -141,12 +140,11 @@ namespace osu.Game.Beatmaps.Drawables.Cards
{ {
new[] new[]
{ {
new OsuSpriteText new TruncatingSpriteText
{ {
Text = createArtistText(), Text = createArtistText(),
Font = OsuFont.Default.With(size: 17.5f, weight: FontWeight.SemiBold), Font = OsuFont.Default.With(size: 17.5f, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true
}, },
Empty() Empty()
}, },

View File

@ -0,0 +1,20 @@
// 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 osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
namespace osu.Game.Graphics.Sprites
{
public sealed partial class TruncatingSpriteText : OsuSpriteText, IHasTooltip
{
public LocalisableString TooltipText => Text;
public override bool HandlePositionalInput => IsTruncated;
public TruncatingSpriteText()
{
Truncate = true;
}
}
}

View File

@ -335,12 +335,11 @@ namespace osu.Game.Graphics.UserInterface
{ {
new Drawable[] new Drawable[]
{ {
Text = new OsuSpriteText Text = new TruncatingSpriteText
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
}, },
Icon = new SpriteIcon Icon = new SpriteIcon
{ {

View File

@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
new Drawable?[] new Drawable?[]
{ {
createIcon(), createIcon(),
text = new OsuSpriteText text = new TruncatingSpriteText
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
@ -94,7 +94,6 @@ namespace osu.Game.Overlays.Chat.ChannelList
Colour = colourProvider.Light3, Colour = colourProvider.Light3,
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
}, },
createMentionPill(), createMentionPill(),
close = createCloseButton(), close = createCloseButton(),

View File

@ -73,14 +73,13 @@ namespace osu.Game.Overlays.Chat
Width = chatting_text_width, Width = chatting_text_width,
Masking = true, Masking = true,
Padding = new MarginPadding { Horizontal = padding }, Padding = new MarginPadding { Horizontal = padding },
Child = chattingText = new OsuSpriteText Child = chattingText = new TruncatingSpriteText
{ {
MaxWidth = chatting_text_width - padding * 2, MaxWidth = chatting_text_width - padding * 2,
Font = OsuFont.Torus.With(size: 20), Font = OsuFont.Torus.With(size: 20),
Colour = colourProvider.Background1, Colour = colourProvider.Background1,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Truncate = true,
}, },
}, },
searchIconContainer = new Container searchIconContainer = new Container

View File

@ -83,10 +83,9 @@ namespace osu.Game.Overlays.Chat
Action = openUserProfile; Action = openUserProfile;
drawableText = new OsuSpriteText drawableText = new TruncatingSpriteText
{ {
Shadow = false, Shadow = false,
Truncate = true,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}; };

View File

@ -100,17 +100,15 @@ namespace osu.Game.Overlays.Dashboard.Home
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new TruncatingSpriteText
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
Font = OsuFont.GetFont(weight: FontWeight.Regular), Font = OsuFont.GetFont(weight: FontWeight.Regular),
Text = BeatmapSet.Title Text = BeatmapSet.Title
}, },
new OsuSpriteText new TruncatingSpriteText
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular), Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
Text = BeatmapSet.Artist Text = BeatmapSet.Artist
}, },

View File

@ -235,7 +235,7 @@ namespace osu.Game.Screens.Play.HUD
} }
} }
}, },
usernameText = new OsuSpriteText usernameText = new TruncatingSpriteText
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Width = 0.6f, Width = 0.6f,
@ -244,7 +244,6 @@ namespace osu.Game.Screens.Play.HUD
Colour = Color4.White, Colour = Color4.White,
Font = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold), Font = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold),
Text = User?.Username ?? string.Empty, Text = User?.Username ?? string.Empty,
Truncate = true,
Shadow = false, Shadow = false,
} }
} }

View File

@ -101,23 +101,21 @@ namespace osu.Game.Screens.Ranking.Expanded
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new TruncatingSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Text = new RomanisableString(metadata.TitleUnicode, metadata.Title), Text = new RomanisableString(metadata.TitleUnicode, metadata.Title),
Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold), Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold),
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2, MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
Truncate = true,
}, },
new OsuSpriteText new TruncatingSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist), Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist),
Font = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold), Font = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold),
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2, MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
Truncate = true,
}, },
new Container new Container
{ {
@ -156,14 +154,13 @@ namespace osu.Game.Screens.Ranking.Expanded
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new TruncatingSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Text = beatmap.DifficultyName, Text = beatmap.DifficultyName,
Font = OsuFont.Torus.With(size: 16, weight: FontWeight.SemiBold), Font = OsuFont.Torus.With(size: 16, weight: FontWeight.SemiBold),
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2, MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
Truncate = true,
}, },
new OsuTextFlowContainer(s => s.Font = OsuFont.Torus.With(size: 12)) new OsuTextFlowContainer(s => s.Font = OsuFont.Torus.With(size: 12))
{ {

View File

@ -233,12 +233,11 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Children = new Drawable[] Children = new Drawable[]
{ {
VersionLabel = new OsuSpriteText VersionLabel = new TruncatingSpriteText
{ {
Text = beatmapInfo.DifficultyName, Text = beatmapInfo.DifficultyName,
Font = OsuFont.GetFont(size: 24, italics: true), Font = OsuFont.GetFont(size: 24, italics: true),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
}, },
} }
}, },
@ -286,19 +285,17 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Children = new Drawable[] Children = new Drawable[]
{ {
TitleLabel = new OsuSpriteText TitleLabel = new TruncatingSpriteText
{ {
Current = { BindTarget = titleBinding }, Current = { BindTarget = titleBinding },
Font = OsuFont.GetFont(size: 28, italics: true), Font = OsuFont.GetFont(size: 28, italics: true),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
}, },
ArtistLabel = new OsuSpriteText ArtistLabel = new TruncatingSpriteText
{ {
Current = { BindTarget = artistBinding }, Current = { BindTarget = artistBinding },
Font = OsuFont.GetFont(size: 17, italics: true), Font = OsuFont.GetFont(size: 17, italics: true),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true,
}, },
MapperContainer = new FillFlowContainer MapperContainer = new FillFlowContainer
{ {