osu/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs

93 lines
2.8 KiB
C#
Raw Normal View History

2017-04-02 16:19:59 +00:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Configuration;
using OpenTK;
using osu.Game.Graphics;
2017-04-02 16:19:59 +00:00
namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseTooltip : TestCase
{
public override string Description => "tests tooltips on various elements";
public override void Reset()
{
base.Reset();
OsuSliderBar<int> slider;
OsuSliderBar<double> sliderDouble;
const float width = 400;
2017-04-02 16:19:59 +00:00
Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
Children = new Drawable[]
2017-04-02 16:19:59 +00:00
{
new TooltipTextContainer("text with a tooltip"),
new TooltipTextContainer("more text with another tooltip"),
new TooltipTextbox
2017-04-02 16:19:59 +00:00
{
Text = "a textbox with a tooltip",
Size = new Vector2(width,30),
2017-04-02 16:19:59 +00:00
},
slider = new OsuSliderBar<int>
2017-04-02 16:19:59 +00:00
{
Width = width,
},
sliderDouble = new OsuSliderBar<double>
{
Width = width,
2017-04-02 16:19:59 +00:00
},
},
},
};
2017-04-13 22:18:17 +00:00
slider.Current.BindTo(new BindableInt(5)
{
MaxValue = 10,
MinValue = 0
});
sliderDouble.Current.BindTo(new BindableDouble(0.5)
{
MaxValue = 1,
MinValue = 0
});
2017-04-02 16:19:59 +00:00
}
private class TooltipTextContainer : Container, IHasTooltip
{
private readonly OsuSpriteText text;
public string TooltipText => text.Text;
2017-04-19 13:01:05 +00:00
public TooltipTextContainer(string tooltipText)
{
AutoSizeAxes = Axes.Both;
Children = new[]
{
text = new OsuSpriteText
{
Text = tooltipText,
}
};
}
}
private class TooltipTextbox : OsuTextBox, IHasTooltip
2017-04-02 16:19:59 +00:00
{
public string TooltipText => Text;
2017-04-02 16:19:59 +00:00
}
}
}