2020-07-28 05:29:17 +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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Comments.Buttons
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class ChevronButton : OsuHoverContainer
|
2020-07-28 05:29:17 +08:00
|
|
|
|
{
|
|
|
|
|
public readonly BindableBool Expanded = new BindableBool(true);
|
|
|
|
|
|
|
|
|
|
private readonly SpriteIcon icon;
|
|
|
|
|
|
|
|
|
|
public ChevronButton()
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(40, 22);
|
|
|
|
|
Child = icon = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(12),
|
2024-07-08 13:48:07 +08:00
|
|
|
|
Icon = FontAwesome.Solid.ChevronDown
|
2020-07-28 05:29:17 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
IdleColour = HoverColour = colourProvider.Foreground1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
Action = Expanded.Toggle;
|
|
|
|
|
Expanded.BindValueChanged(onExpandedChanged, true);
|
2024-07-08 13:48:07 +08:00
|
|
|
|
FinishTransforms(true);
|
2020-07-28 05:29:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onExpandedChanged(ValueChangedEvent<bool> expanded)
|
|
|
|
|
{
|
2024-07-08 13:48:07 +08:00
|
|
|
|
icon.ScaleTo(expanded.NewValue ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
2020-07-28 05:29:17 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|