diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ActionButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ActionButton.cs deleted file mode 100644 index 8f37c10d9..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ActionButton.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Input.Events; -using osu.Game.Graphics; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose.Toolbar; - -/// -/// Button with click effect. -/// -public abstract partial class ActionButton : ToolbarButton -{ - [Resolved] - private OsuColour colours { get; set; } = null!; - - protected void ToggleClickEffect() - { - if (Enabled.Value) - { - IconContainer.FadeOut(100).Then().FadeIn(); - } - else - { - IconContainer.FadeColour(colours.Red, 100).Then().FadeColour(Colour4.White); - } - } - - protected override bool OnClick(ClickEvent e) - { - if (Enabled.Value) - ToggleClickEffect(); - - return base.OnClick(e); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/KeyActionButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/KeyActionButton.cs index 5c45b81d3..3e03bb395 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/KeyActionButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/KeyActionButton.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose /// /// Button that able to receive the event. /// -public abstract partial class KeyActionButton : ActionButton, IKeyBindingHandler, IHasIKeyBindingHandlerOrder +public abstract partial class KeyActionButton : ToolbarButton, IKeyBindingHandler, IHasIKeyBindingHandlerOrder { protected abstract KaraokeEditAction EditAction { get; } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs index 5755e217f..673fa3d1c 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs @@ -5,6 +5,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osuTK; @@ -15,21 +17,27 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose /// public abstract partial class ToolbarButton : OsuClickableContainer { - public void SetIcon(Drawable icon) - { - Size = new Vector2(SpecialActionToolbar.HEIGHT); - IconContainer.Icon = icon; - IconContainer.Show(); - } - [Resolved] private TextureStore textures { get; set; } = null!; - public void SetIcon(string texture) => - SetIcon(new Sprite + [Resolved] + private OsuColour colours { get; set; } = null!; + + protected ConstrainedIconContainer IconContainer; + + protected ToolbarButton() + { + Children = new Drawable[] { - Texture = textures.Get(texture), - }); + IconContainer = new ConstrainedIconContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(SpecialActionToolbar.ICON_SIZE), + Alpha = 0, + }, + }; + } public void SetIcon(IconUsage iconUsage) => SetIcon(new SpriteIcon @@ -37,25 +45,35 @@ public void SetIcon(IconUsage iconUsage) => Icon = iconUsage, }); + public void SetIcon(Drawable icon) + { + Size = new Vector2(SpecialActionToolbar.HEIGHT); + IconContainer.Icon = icon; + IconContainer.Show(); + } + protected void SetState(bool enabled) { IconContainer.Icon.Alpha = enabled ? 1f : 0.5f; Enabled.Value = enabled; } - protected ConstrainedIconContainer IconContainer; + protected override bool OnClick(ClickEvent e) + { + ToggleClickEffect(); - protected ToolbarButton() + return base.OnClick(e); + } + + public void ToggleClickEffect() { - Children = new Drawable[] + if (Enabled.Value) { - IconContainer = new ConstrainedIconContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(SpecialActionToolbar.ICON_SIZE), - Alpha = 0, - }, - }; + IconContainer.FadeOut(100).Then().FadeIn(); + } + else + { + IconContainer.FadeColour(colours.Red, 100).Then().FadeColour(Colour4.White); + } } }