From c87657707fac7ddc8b4317d28334648635364d06 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Apr 2017 17:33:07 +0900 Subject: [PATCH] Add tooltip to sliderbars. Move interface. --- osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs | 9 ++------- osu.Game/Graphics/{Cursor => }/IHasTooltip.cs | 2 +- osu.Game/Graphics/UserInterface/OsuSliderBar.cs | 5 ++++- osu.Game/osu.Game.csproj | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) rename osu.Game/Graphics/{Cursor => }/IHasTooltip.cs (88%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs b/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs index 02893d0628..f12b9d71e2 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs @@ -19,7 +19,7 @@ namespace osu.Desktop.VisualTests.Tests public override void Reset() { base.Reset(); - TooltipSlider slider; + OsuSliderBar slider; Children = new Drawable[] { @@ -37,7 +37,7 @@ namespace osu.Desktop.VisualTests.Tests Text = "a box with a tooltip", Size = new Vector2(300,30), }, - slider = new TooltipSlider + slider = new OsuSliderBar { Width = 300, }, @@ -75,10 +75,5 @@ namespace osu.Desktop.VisualTests.Tests { public string TooltipText => Text; } - - private class TooltipSlider : OsuSliderBar, IHasTooltip - { - public string TooltipText => Current.Value.ToString(); - } } } diff --git a/osu.Game/Graphics/Cursor/IHasTooltip.cs b/osu.Game/Graphics/IHasTooltip.cs similarity index 88% rename from osu.Game/Graphics/Cursor/IHasTooltip.cs rename to osu.Game/Graphics/IHasTooltip.cs index 2d166ca9dc..dd51d68c41 100644 --- a/osu.Game/Graphics/Cursor/IHasTooltip.cs +++ b/osu.Game/Graphics/IHasTooltip.cs @@ -3,7 +3,7 @@ using osu.Framework.Graphics; -namespace osu.Game.Graphics.Cursor +namespace osu.Game.Graphics { public interface IHasTooltip : IDrawable { diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index 180cb88707..12d5d2126c 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -12,7 +13,7 @@ using osu.Framework.Input; namespace osu.Game.Graphics.UserInterface { - public class OsuSliderBar : SliderBar where U : struct + public class OsuSliderBar : SliderBar, IHasTooltip where U : struct { private SampleChannel sample; private double lastSampleTime; @@ -21,6 +22,8 @@ namespace osu.Game.Graphics.UserInterface private readonly Box leftBox; private readonly Box rightBox; + public string TooltipText => Current.Value.ToString(); + public OsuSliderBar() { Height = 12; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fb772cb5c4..6d7a905eed 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -88,12 +88,12 @@ + -