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

46 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 osu.Game.Graphics;
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]
private void load(OsuColour colours)
{
2019-05-20 14:58:40 +08:00
IdleColour = colours.GreySeafoamLight;
HoverColour = colours.GreySeafoamLight.Darken(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;
}
}