From 5373c3066ffc070476c1402b7032aa3e8f3846c6 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 19 Mar 2022 17:23:59 +0000 Subject: [PATCH] Use `OsuAnimatedButton` as base for `ControlItemClose` --- .../Chat/ChannelControl/ControlItemClose.cs | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs index c0f419f619..6064e3790d 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs @@ -6,56 +6,28 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; using osuTK; namespace osu.Game.Overlays.Chat.ChannelControl { - public class ControlItemClose : OsuClickableContainer + public class ControlItemClose : OsuAnimatedButton { - private readonly SpriteIcon icon; - - [Resolved] - private OsuColour osuColour { get; set; } = null!; - - public ControlItemClose() + [BackgroundDependencyLoader] + private void load(OsuColour osuColour) { Alpha = 0f; Size = new Vector2(20); - Child = icon = new SpriteIcon + Add(new SpriteIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, Scale = new Vector2(0.75f), Icon = FontAwesome.Solid.TimesCircle, RelativeSizeAxes = Axes.Both, - }; - } - - protected override bool OnMouseDown(MouseDownEvent e) - { - icon.ScaleTo(0.5f, 1000, Easing.OutQuint); - return base.OnMouseDown(e); - } - - protected override void OnMouseUp(MouseUpEvent e) - { - icon.ScaleTo(0.75f, 1000, Easing.OutElastic); - base.OnMouseUp(e); - } - - protected override bool OnHover(HoverEvent e) - { - icon.FadeColour(osuColour.Red1, 200, Easing.OutQuint); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - icon.FadeColour(Colour4.White, 200, Easing.OutQuint); - base.OnHoverLost(e); + Colour = osuColour.Red1, + }); } } }