made method into property

This commit is contained in:
Jorolf 2017-04-17 17:43:44 +02:00
parent 773e6a2911
commit 25fd1d2b72
2 changed files with 22 additions and 15 deletions

View File

@ -44,7 +44,7 @@ namespace osu.Game.Graphics.Cursor
}
tooltip.Position = new Vector2(state.Mouse.Position.X,ActiveCursor.BoundingBox.Bottom);
tooltip.UpdateTooltip(state);
tooltip.MouseState = state.Mouse;
return base.OnMouseMove(state);
}

View File

@ -39,8 +39,28 @@ namespace osu.Game.Graphics.Cursor
}
}
public IMouseState MouseState
{
set
{
if (value.Position != value.LastPosition && overhang?.Overhanging != true)
{
show?.Cancel();
TooltipText = string.Empty;
IHasTooltip hasTooltip = input.HoveredDrawables.OfType<IHasTooltip>().FirstOrDefault();
if (hasTooltip != null)
{
IHasDelayedTooltip delayedTooltip = hasTooltip as IHasDelayedTooltip;
overhang = hasTooltip as IHasOverhangingTooltip;
show = Scheduler.AddDelayed(() => TooltipText = hasTooltip.Tooltip, delayedTooltip?.Delay ?? 250);
}
}
}
}
public Tooltip()
{
AlwaysPresent = true;
Children = new[]
{
new Container
@ -48,7 +68,6 @@ namespace osu.Game.Graphics.Cursor
AutoSizeAxes = Axes.Both,
CornerRadius = 5,
Masking = true,
AlwaysPresent = true,
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
@ -78,23 +97,11 @@ namespace osu.Game.Graphics.Cursor
tooltipBackground.Colour = colour.Gray3;
}
public void UpdateTooltip(InputState state)
protected override void Update()
{
Scheduler.Update();
if (overhang?.Overhanging ?? false)
TooltipText = overhang.Tooltip;
else if (state.Mouse.Position != state.Mouse.LastPosition)
{
show?.Cancel();
TooltipText = string.Empty;
IHasTooltip hasTooltip = input.HoveredDrawables.OfType<IHasTooltip>().FirstOrDefault();
if (hasTooltip != null)
{
IHasDelayedTooltip delayedTooltip = hasTooltip as IHasDelayedTooltip;
overhang = hasTooltip as IHasOverhangingTooltip;
show = Scheduler.AddDelayed(() => TooltipText = hasTooltip.Tooltip, delayedTooltip?.Delay ?? 250);
}
}
else if (overhang != null)
{
overhang = null;