mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
add IHasOverhangingTooltip
This commit is contained in:
@ -12,7 +12,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface of <see cref="IHasTooltip"/> with custom appear time
|
||||
/// Tooltip with custom appear time
|
||||
/// </summary>
|
||||
public interface IHasDelayedTooltip : IHasTooltip
|
||||
{
|
||||
@ -21,4 +21,15 @@ namespace osu.Game.Graphics.Cursor
|
||||
/// </summary>
|
||||
int Delay { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tooltip which can show after hovering over the object
|
||||
/// </summary>
|
||||
public interface IHasOverhangingTooltip : IHasTooltip
|
||||
{
|
||||
/// <summary>
|
||||
/// Should the tooltip still show?
|
||||
/// </summary>
|
||||
bool Overhanging { get; }
|
||||
}
|
||||
}
|
||||
|
@ -31,24 +31,33 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
private ScheduledDelegate show;
|
||||
private OsuGameBase game;
|
||||
private IHasOverhangingTooltip overhang;
|
||||
|
||||
protected override bool OnMouseMove(InputState state)
|
||||
{
|
||||
if (state.Mouse.Position != state.Mouse.LastPosition)
|
||||
Tooltip tooltip = ((Cursor)ActiveCursor).Tooltip;
|
||||
if (overhang?.Overhanging ?? false)
|
||||
tooltip.TooltipText = overhang.Tooltip;
|
||||
else if (state.Mouse.Position != state.Mouse.LastPosition)
|
||||
{
|
||||
Tooltip tooltip = ((Cursor)ActiveCursor).Tooltip;
|
||||
show?.Cancel();
|
||||
tooltip.TooltipText = string.Empty;
|
||||
IHasTooltip hasTooltip = null;
|
||||
if (game.InternalChildren.OfType<IContainer>().Any(child => (hasTooltip = searchTooltip(child as IContainerEnumerable<Drawable>)) != null))
|
||||
{
|
||||
IHasDelayedTooltip delayedTooltip = hasTooltip as IHasDelayedTooltip;
|
||||
overhang = hasTooltip as IHasOverhangingTooltip;
|
||||
show = Scheduler.AddDelayed(delegate
|
||||
{
|
||||
tooltip.TooltipText = hasTooltip.Tooltip;
|
||||
}, delayedTooltip?.Delay ?? 250);
|
||||
}
|
||||
}
|
||||
else if(overhang != null)
|
||||
{
|
||||
overhang = null;
|
||||
tooltip.TooltipText = string.Empty;
|
||||
}
|
||||
|
||||
if (dragging)
|
||||
{
|
||||
|
@ -34,8 +34,6 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
public Tooltip()
|
||||
{
|
||||
Depth = float.MinValue;
|
||||
AlwaysReceiveInput = true;
|
||||
Children = new[]
|
||||
{
|
||||
new Container
|
||||
|
Reference in New Issue
Block a user