From 1dda77388cf6cde7cc4e75aacf3b0f06c3b9e1c0 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 18 Aug 2024 19:26:23 +0800 Subject: [PATCH 1/4] Remove the editorConfigButton because it's a little bit over-design. --- .../Toolbar/LyricEditorConfigButton.cs | 29 ------------------- .../Panels/ToggleInvalidInfoPanelButton.cs | 14 +++++++-- .../Panels/TogglePropertyPanelButton.cs | 14 +++++++-- 3 files changed, 22 insertions(+), 35 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/LyricEditorConfigButton.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/LyricEditorConfigButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/LyricEditorConfigButton.cs deleted file mode 100644 index 6e89ec155..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/LyricEditorConfigButton.cs +++ /dev/null @@ -1,29 +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.Sprites; -using osu.Game.Rulesets.Karaoke.Configuration; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose.Toolbar; - -/// -/// Button that able to change the boolean config in the -/// -public abstract partial class LyricEditorConfigButton : ToggleButton -{ - protected LyricEditorConfigButton() - { - SetIcon(Icon); - } - - [BackgroundDependencyLoader] - private void load(KaraokeRulesetLyricEditorConfigManager lyricEditorConfigManager) - { - lyricEditorConfigManager.BindWith(Setting, Active); - } - - protected abstract KaraokeRulesetLyricEditorSetting Setting { get; } - - protected abstract IconUsage Icon { get; } -} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs index cfd65c993..12d65ec7b 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs @@ -1,14 +1,22 @@ // 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.Sprites; using osu.Game.Rulesets.Karaoke.Configuration; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose.Toolbar.Panels; -public partial class ToggleInvalidInfoPanelButton : LyricEditorConfigButton +public partial class ToggleInvalidInfoPanelButton : ToggleButton { - protected override KaraokeRulesetLyricEditorSetting Setting => KaraokeRulesetLyricEditorSetting.ShowInvalidInfoInComposer; + public ToggleInvalidInfoPanelButton() + { + SetIcon(FontAwesome.Solid.ExclamationTriangle); + } - protected override IconUsage Icon => FontAwesome.Solid.ExclamationTriangle; + [BackgroundDependencyLoader] + private void load(KaraokeRulesetLyricEditorConfigManager lyricEditorConfigManager) + { + lyricEditorConfigManager.BindWith(KaraokeRulesetLyricEditorSetting.ShowInvalidInfoInComposer, Active); + } } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs index 87b02352f..df3b13722 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs @@ -1,14 +1,22 @@ // 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.Sprites; using osu.Game.Rulesets.Karaoke.Configuration; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose.Toolbar.Panels; -public partial class TogglePropertyPanelButton : LyricEditorConfigButton +public partial class TogglePropertyPanelButton : ToggleButton { - protected override KaraokeRulesetLyricEditorSetting Setting => KaraokeRulesetLyricEditorSetting.ShowPropertyPanelInComposer; + public TogglePropertyPanelButton() + { + SetIcon(FontAwesome.Solid.FileImage); + } - protected override IconUsage Icon => FontAwesome.Solid.FileImage; + [BackgroundDependencyLoader] + private void load(KaraokeRulesetLyricEditorConfigManager lyricEditorConfigManager) + { + lyricEditorConfigManager.BindWith(KaraokeRulesetLyricEditorSetting.ShowPropertyPanelInComposer, Active); + } } From 03e182aeb797d54a7e977c028a406ca602296f68 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 18 Aug 2024 19:28:54 +0800 Subject: [PATCH 2/4] Rename the base button. --- .../Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs | 2 +- .../Compose/Toolbar/Panels/TogglePropertyPanelButton.cs | 2 +- .../Toolbar/{ToggleButton.cs => ToolbarToggleButton.cs} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/{ToggleButton.cs => ToolbarToggleButton.cs} (88%) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs index 12d65ec7b..1631c27c7 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/ToggleInvalidInfoPanelButton.cs @@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose.Toolbar.Panels; -public partial class ToggleInvalidInfoPanelButton : ToggleButton +public partial class ToggleInvalidInfoPanelButton : ToolbarToggleButton { public ToggleInvalidInfoPanelButton() { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs index df3b13722..e8d149a82 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Panels/TogglePropertyPanelButton.cs @@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose.Toolbar.Panels; -public partial class TogglePropertyPanelButton : ToggleButton +public partial class TogglePropertyPanelButton : ToolbarToggleButton { public TogglePropertyPanelButton() { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToggleButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarToggleButton.cs similarity index 88% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToggleButton.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarToggleButton.cs index 02bfaefe3..7b4ad0eb5 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToggleButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarToggleButton.cs @@ -8,11 +8,11 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose /// /// Button for toggle open and close. /// -public abstract partial class ToggleButton : ToolbarButton +public abstract partial class ToolbarToggleButton : ToolbarButton { protected readonly Bindable Active = new(); - protected ToggleButton() + protected ToolbarToggleButton() { Active.BindValueChanged(x => { From c8df918931bcc07282dbccd5e6cd450c4b824ab1 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 18 Aug 2024 19:46:13 +0800 Subject: [PATCH 3/4] Remove the action toolbar. --- .../Content/Compose/Toolbar/ActionButton.cs | 38 ------------ .../Compose/Toolbar/KeyActionButton.cs | 2 +- .../Content/Compose/Toolbar/ToolbarButton.cs | 62 ++++++++++++------- 3 files changed, 41 insertions(+), 61 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ActionButton.cs 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); + } } } From f1170199b5ea53e76f0077eea24cc5687d5787a1 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 18 Aug 2024 19:47:27 +0800 Subject: [PATCH 4/4] Rename the button. --- .../Content/Compose/Toolbar/Carets/MoveToCaretPositionButton.cs | 2 +- .../Toolbar/{KeyActionButton.cs => ToolbarEditActionButton.cs} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/{KeyActionButton.cs => ToolbarEditActionButton.cs} (85%) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Carets/MoveToCaretPositionButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Carets/MoveToCaretPositionButton.cs index dd7ca2fc7..3328eb22b 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Carets/MoveToCaretPositionButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/Carets/MoveToCaretPositionButton.cs @@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose.Toolbar.Carets; -public abstract partial class MoveToCaretPositionButton : KeyActionButton +public abstract partial class MoveToCaretPositionButton : ToolbarEditActionButton { protected abstract MovingCaretAction AcceptAction { get; } 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/ToolbarEditActionButton.cs similarity index 85% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/KeyActionButton.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarEditActionButton.cs index 3e03bb395..aec6037f2 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/ToolbarEditActionButton.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 : ToolbarButton, IKeyBindingHandler, IHasIKeyBindingHandlerOrder +public abstract partial class ToolbarEditActionButton : ToolbarButton, IKeyBindingHandler, IHasIKeyBindingHandlerOrder { protected abstract KaraokeEditAction EditAction { get; }