1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 22:02:56 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/Cards/Buttons/BeatmapCardIconButton.cs

71 lines
2.0 KiB
C#
Raw Normal View History

2021-10-18 03:34:31 +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 System.Collections.Generic;
2021-10-18 03:34:31 +08:00
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
2021-10-18 03:34:31 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2021-10-18 03:34:31 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{
public abstract class BeatmapCardIconButton : OsuHoverContainer
{
protected override IEnumerable<Drawable> EffectTargets => background.Yield();
private readonly Box background;
2021-10-18 03:34:31 +08:00
protected readonly SpriteIcon Icon;
private float iconSize;
2021-10-18 03:34:31 +08:00
public float IconSize
2021-10-18 03:34:31 +08:00
{
get => iconSize;
2021-10-18 03:34:31 +08:00
set
{
iconSize = value;
Icon.Size = new Vector2(iconSize);
2021-10-18 03:34:31 +08:00
}
}
protected BeatmapCardIconButton()
{
Child = new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both
},
Icon = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre
}
}
};
2021-10-18 03:34:31 +08:00
Size = new Vector2(24);
IconSize = 12;
2021-10-18 03:34:31 +08:00
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Anchor = Origin = Anchor.Centre;
IdleColour = colourProvider.Background4;
HoverColour = colourProvider.Background1;
Icon.Colour = colourProvider.Content2;
2021-10-18 03:34:31 +08:00
}
}
}