mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 11:52:54 +08:00
Add hover box to beatmap card icon button
This commit is contained in:
parent
ebc1088457
commit
aa8040d696
@ -4,13 +4,16 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||||
{
|
{
|
||||||
@ -59,6 +62,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
private readonly Box hover;
|
||||||
|
|
||||||
protected BeatmapCardIconButton()
|
protected BeatmapCardIconButton()
|
||||||
{
|
{
|
||||||
@ -69,6 +73,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
|
CornerRadius = BeatmapCard.CORNER_RADIUS,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -76,8 +81,14 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
Icon = new SpriteIcon
|
Icon = new SpriteIcon
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre
|
Anchor = Anchor.Centre,
|
||||||
}
|
},
|
||||||
|
hover = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.White.Opacity(0.1f),
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -116,8 +127,9 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
{
|
{
|
||||||
bool isHovered = IsHovered && Enabled.Value;
|
bool isHovered = IsHovered && Enabled.Value;
|
||||||
|
|
||||||
content.ScaleTo(isHovered ? 1.2f : 1, 500, Easing.OutQuint);
|
hover.FadeTo(isHovered ? 1f : 0f, 500, Easing.OutQuint);
|
||||||
content.FadeColour(isHovered ? HoverColour : IdleColour, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
Icon.ScaleTo(isHovered ? 1.2f : 1, 500, Easing.OutQuint);
|
||||||
|
Icon.FadeColour(isHovered ? HoverColour : IdleColour, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user