Merge pull request #904 from Tom94/smoothly-moving-tooltips

Make osu tooltips move smoothly
This commit is contained in:
Dean Herbert 2017-06-05 21:44:45 +09:00 committed by GitHub
commit cbd0e8e375
1 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -24,6 +25,7 @@ public class OsuTooltip : Tooltip
{ {
private readonly Box background; private readonly Box background;
private readonly OsuSpriteText text; private readonly OsuSpriteText text;
private bool instantMovement = true;
public override string TooltipText public override string TooltipText
{ {
@ -32,7 +34,7 @@ public override string TooltipText
if (value == text.Text) return; if (value == text.Text) return;
text.Text = value; text.Text = value;
if (Alpha > 0) if (IsPresent)
{ {
AutoSizeDuration = 250; AutoSizeDuration = 250;
background.FlashColour(OsuColour.Gray(0.4f), 1000, EasingTypes.OutQuint); background.FlashColour(OsuColour.Gray(0.4f), 1000, EasingTypes.OutQuint);
@ -80,6 +82,7 @@ private void load(OsuColour colour)
protected override void PopIn() protected override void PopIn()
{ {
instantMovement |= !IsPresent;
FadeIn(500, EasingTypes.OutQuint); FadeIn(500, EasingTypes.OutQuint);
} }
@ -88,6 +91,19 @@ protected override void PopOut()
using (BeginDelayedSequence(150)) using (BeginDelayedSequence(150))
FadeOut(500, EasingTypes.OutQuint); FadeOut(500, EasingTypes.OutQuint);
} }
public override void Move(Vector2 pos)
{
if (instantMovement)
{
Position = pos;
instantMovement = false;
}
else
{
MoveTo(pos, 200, EasingTypes.OutQuint);
}
}
} }
} }
} }