-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tooltips to truncated text #23829
Conversation
I'm just wondering if we don't want to add this implementation to |
We've been over this in the framework pull: ppy/osu-framework#5636 (comment) |
I was also hoping this could be done in In my opinion, rather than overthinking this further, I would be totally fine with this approach as long as the diff --git a/osu.Game/Graphics/Sprites/OsuSpriteText.cs b/osu.Game/Graphics/Sprites/OsuSpriteText.cs
index e149e0abfb..afbec0eab4 100644
--- a/osu.Game/Graphics/Sprites/OsuSpriteText.cs
+++ b/osu.Game/Graphics/Sprites/OsuSpriteText.cs
@@ -3,12 +3,19 @@
#nullable disable
+using System;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.Sprites
{
public partial class OsuSpriteText : SpriteText
{
+ [Obsolete("Use TruncatingSpriteText instead.")]
+ public new bool Truncate
+ {
+ set => throw new InvalidOperationException($"Use {nameof(TruncatingSpriteText)} instead.");
+ }
+
public OsuSpriteText()
{
Shadow = true;
diff --git a/osu.Game/Graphics/Sprites/TruncatingSpriteText.cs b/osu.Game/Graphics/Sprites/TruncatingSpriteText.cs
index da0dbd49d2..229fad29f9 100644
--- a/osu.Game/Graphics/Sprites/TruncatingSpriteText.cs
+++ b/osu.Game/Graphics/Sprites/TruncatingSpriteText.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Cursor;
+using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
namespace osu.Game.Graphics.Sprites
@@ -14,7 +15,7 @@ public sealed partial class TruncatingSpriteText : OsuSpriteText, IHasTooltip
public TruncatingSpriteText()
{
- Truncate = true;
+ ((SpriteText)this).Truncate = true;
}
}
}
diff --git a/osu.Game/Overlays/Mods/ModSelectPanel.cs b/osu.Game/Overlays/Mods/ModSelectPanel.cs
index 81285833bd..6179f31637 100644
--- a/osu.Game/Overlays/Mods/ModSelectPanel.cs
+++ b/osu.Game/Overlays/Mods/ModSelectPanel.cs
@@ -118,22 +118,20 @@ protected ModSelectPanel()
Direction = FillDirection.Vertical,
Children = new[]
{
- titleText = new OsuSpriteText
+ titleText = new TruncatingSpriteText
{
Font = OsuFont.TorusAlternate.With(size: 18, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X,
- Truncate = true,
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Margin = new MarginPadding
{
Left = -18 * ShearedOverlayContainer.SHEAR
}
},
- descriptionText = new OsuSpriteText
+ descriptionText = new TruncatingSpriteText
{
Font = OsuFont.Default.With(size: 12),
RelativeSizeAxes = Axes.X,
- Truncate = true,
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0)
}
} |
That should definitely be handled very explicitly. Either as...a truncating sprite text that doesn't show a tooltip...or move the tooltip provider to a drawable that would take hover away from the sprite text. |
Co-Authored-By: Salman Ahmed <frenzibyte@gmail.com>
Going simple with a bool instead of making `TooltipText` init-able, as the current cases will just init `string.Empty`. And not sure if we want custom tooltip text in the future.
This is probably fine, but requesting one more approval. |
I'll abstain from approval here since part of the changes in this PR were proposed by me above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. On first glance I thought TruncatingSpriteText
was a framework class as it doesn't have Osu
in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have a weird feeling that this is overly constrained and is going to backfire on us but there's enough approvals that let's give it a go i guess
Made the changes said in ppy/osu-framework#5636 (comment) + simplifying the tooltip
IsTruncated ? Text : string.Empty
to justText
as it wasn't needed (i.e. theHandlePositionalInput
override already disables tooltip showing).Looking again,
TruncatingSpriteText
may be better suited for framework.OsuSpriteText
is already a simple class with just two lines, so inheritance isn't a problem and could beTruncatingSpriteText : SpriteText
for framework andOsuTruncatingSpriteText : TruncatingSpriteText
for osu!-side.I also tried centralising the
MaxWidth
andRelativeSizeAxes = Axes.X
assigning toTruncatingSpriteText
(Joehuu@dd8e1ba), but not sure about the solution as I'm working around a framework limitation and probably should be done more directly inSpriteText
.