2023-06-09 08:11:17 +08:00
|
|
|
// 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;
|
2023-06-11 02:53:45 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2023-06-09 08:11:17 +08:00
|
|
|
using osu.Framework.Localisation;
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Sprites
|
|
|
|
{
|
2023-06-12 14:25:12 +08:00
|
|
|
/// <summary>
|
|
|
|
/// A derived version of <see cref="OsuSpriteText"/> which automatically shows non-truncated text in tooltip when required.
|
|
|
|
/// </summary>
|
2023-06-09 08:11:17 +08:00
|
|
|
public sealed partial class TruncatingSpriteText : OsuSpriteText, IHasTooltip
|
|
|
|
{
|
2023-06-12 14:25:12 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether a tooltip should be shown with non-truncated text on hover.
|
|
|
|
/// </summary>
|
2023-06-11 03:24:58 +08:00
|
|
|
public bool ShowTooltip { get; init; } = true;
|
|
|
|
|
2023-06-09 08:11:17 +08:00
|
|
|
public LocalisableString TooltipText => Text;
|
|
|
|
|
2023-06-11 03:24:58 +08:00
|
|
|
public override bool HandlePositionalInput => IsTruncated && ShowTooltip;
|
2023-06-09 08:11:17 +08:00
|
|
|
|
|
|
|
public TruncatingSpriteText()
|
|
|
|
{
|
2023-06-11 02:53:45 +08:00
|
|
|
((SpriteText)this).Truncate = true;
|
2023-06-09 08:11:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|