2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2017-06-27 20:05:49 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-11-26 03:59:55 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-27 20:05:49 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-05-19 10:28:24 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2021-06-26 01:10:04 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-11-26 01:41:18 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-06-27 20:05:49 +08:00
|
|
|
|
namespace osu.Game.Graphics.Containers
|
|
|
|
|
{
|
2019-05-19 10:28:24 +08:00
|
|
|
|
public partial class OsuClickableContainer : ClickableContainer, IHasTooltip
|
2017-06-27 20:05:49 +08:00
|
|
|
|
{
|
2017-11-26 01:41:18 +08:00
|
|
|
|
private readonly HoverSampleSet sampleSet;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-26 03:59:55 +08:00
|
|
|
|
private readonly Container content = new Container { RelativeSizeAxes = Axes.Both };
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-26 03:59:55 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-11-03 16:44:54 +08:00
|
|
|
|
protected virtual HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet) { Enabled = { BindTarget = Enabled } };
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-11 19:42:10 +08:00
|
|
|
|
public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Default)
|
2017-06-27 20:05:49 +08:00
|
|
|
|
{
|
2017-11-26 01:41:18 +08:00
|
|
|
|
this.sampleSet = sampleSet;
|
2017-06-27 20:05:49 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-26 01:10:04 +08:00
|
|
|
|
public virtual LocalisableString TooltipText { get; set; }
|
2019-05-19 10:28:24 +08:00
|
|
|
|
|
2017-11-26 01:41:18 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-06-27 20:05:49 +08:00
|
|
|
|
{
|
2017-11-26 03:59:55 +08:00
|
|
|
|
if (AutoSizeAxes != Axes.None)
|
|
|
|
|
{
|
2019-06-03 12:53:24 +08:00
|
|
|
|
content.RelativeSizeAxes = (Axes.Both & ~AutoSizeAxes);
|
2017-11-26 03:59:55 +08:00
|
|
|
|
content.AutoSizeAxes = AutoSizeAxes;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-26 03:59:55 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
content,
|
2021-07-09 10:16:47 +08:00
|
|
|
|
CreateHoverSounds(sampleSet)
|
2017-11-26 03:59:55 +08:00
|
|
|
|
};
|
2017-06-27 20:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|