From 25fd1d2b72a5d77224b6a7f63bd4fac28200dd81 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 17 Apr 2017 17:43:44 +0200 Subject: [PATCH] made method into property --- osu.Game/Graphics/Cursor/MenuCursor.cs | 2 +- osu.Game/Graphics/Cursor/Tooltip.cs | 35 +++++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 6f208219ae..6e63ac97d3 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -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); } diff --git a/osu.Game/Graphics/Cursor/Tooltip.cs b/osu.Game/Graphics/Cursor/Tooltip.cs index 5960e83763..9e6a0695d6 100644 --- a/osu.Game/Graphics/Cursor/Tooltip.cs +++ b/osu.Game/Graphics/Cursor/Tooltip.cs @@ -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().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().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;