1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 09:07:25 +08:00
osu-lazer/osu.Game/Overlays/Profile/Header/Components/ExpandDetailsButton.cs

45 lines
1.4 KiB
C#
Raw Normal View History

2019-04-26 12:29:58 +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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
2019-04-26 12:49:44 +08:00
namespace osu.Game.Overlays.Profile.Header.Components
2019-04-26 12:29:58 +08:00
{
public class ExpandDetailsButton : ProfileHeaderButton
{
public readonly BindableBool DetailsVisible = new BindableBool();
public override string TooltipText => DetailsVisible.Value ? "collapse" : "expand";
private SpriteIcon icon;
public ExpandDetailsButton()
{
Action = () => DetailsVisible.Toggle();
}
[BackgroundDependencyLoader]
2020-01-30 05:25:28 +08:00
private void load(OverlayColourProvider colourProvider)
2019-04-26 12:29:58 +08:00
{
2020-01-30 05:25:28 +08:00
IdleColour = colourProvider.Background2;
HoverColour = colourProvider.Background2.Lighten(0.2f);
2019-04-26 12:29:58 +08:00
Child = icon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(20, 12)
};
DetailsVisible.BindValueChanged(visible => updateState(visible.NewValue), true);
}
private void updateState(bool detailsVisible) => icon.Icon = detailsVisible ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
}
}