2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-05-19 02:28:24 +00:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Containers
|
|
|
|
|
{
|
2019-05-19 02:28:24 +00:00
|
|
|
|
public class OsuClickableContainer : ClickableContainer, IHasTooltip
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly HoverSampleSet sampleSet;
|
|
|
|
|
|
|
|
|
|
private readonly Container content = new Container { RelativeSizeAxes = Axes.Both };
|
|
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
|
|
protected virtual HoverClickSounds CreateHoverClickSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet);
|
|
|
|
|
|
|
|
|
|
public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Normal)
|
|
|
|
|
{
|
|
|
|
|
this.sampleSet = sampleSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-19 02:28:24 +00:00
|
|
|
|
public virtual string TooltipText { get; set; }
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
if (AutoSizeAxes != Axes.None)
|
|
|
|
|
{
|
2019-06-03 04:53:24 +00:00
|
|
|
|
content.RelativeSizeAxes = (Axes.Both & ~AutoSizeAxes);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
content.AutoSizeAxes = AutoSizeAxes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
content,
|
|
|
|
|
CreateHoverClickSounds(sampleSet)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|