From b91e22737d6e568c894175e4d5dc048e733fb649 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 10 Sep 2022 21:20:52 +0800 Subject: [PATCH 1/7] Should just clear all the blueprint selection if lyric property is not editable. --- .../Modes/ModeStateWithBlueprintContainer.cs | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs new file mode 100644 index 000000000..d1a5c4f49 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs @@ -0,0 +1,66 @@ +// 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.Bindables; +using osu.Framework.Graphics; +using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition; +using osu.Game.Rulesets.Karaoke.Objects; + +namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes +{ + public abstract class ModeStateWithBlueprintContainer : Component, IHasBlueprintSelection where TObject : class + { + private readonly IBindable bindableMode = new Bindable(); + private readonly IBindable bindableCaretPosition = new Bindable(); + private readonly IBindable bindableLyricPropertyWritableVersion = new Bindable(); + + public BindableList SelectedItems { get; } = new(); + + protected ModeStateWithBlueprintContainer() + { + bindableMode.BindValueChanged(e => + { + triggerDisableStateChanged(); + }); + + bindableCaretPosition.BindValueChanged(e => + { + bindableLyricPropertyWritableVersion.UnbindBindings(); + + var lyric = e.NewValue?.Lyric; + + if (lyric == null) + return; + + bindableLyricPropertyWritableVersion.BindTo(lyric.LyricPropertyWritableVersion); + triggerDisableStateChanged(); + }); + + bindableLyricPropertyWritableVersion.BindValueChanged(_ => + { + triggerDisableStateChanged(); + }); + } + + private void triggerDisableStateChanged() + { + var lyric = bindableCaretPosition.Value?.Lyric; + if (lyric == null) + return; + + bool locked = IsWriteLyricPropertyLocked(lyric); + if (locked) + SelectedItems.Clear(); + } + + protected abstract bool IsWriteLyricPropertyLocked(Lyric lyric); + + [BackgroundDependencyLoader] + private void load(ILyricEditorState state, ILyricCaretState lyricCaretState) + { + bindableMode.BindTo(state.BindableMode); + bindableCaretPosition.BindTo(lyricCaretState.BindableCaretPosition); + } + } +} From 2fe16a192c6aafba95b9f9377d5ac7add1853c8e Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 10 Sep 2022 21:28:08 +0800 Subject: [PATCH 2/7] Apply to the base class. --- .../Edit/Lyrics/States/Modes/EditNoteModeState.cs | 9 +++++---- .../Edit/Lyrics/States/Modes/EditRomajiModeState.cs | 7 ++++--- .../Edit/Lyrics/States/Modes/EditRubyModeState.cs | 7 ++++--- .../Edit/Lyrics/States/Modes/TimeTagModeState.cs | 8 ++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs index a22ecc379..c04ae150f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs @@ -3,8 +3,8 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Notes; +using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Utils; using osu.Game.Rulesets.Objects; @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { - public class EditNoteModeState : Component, IEditNoteModeState + public class EditNoteModeState : ModeStateWithBlueprintContainer, IEditNoteModeState { private readonly Bindable bindableEditMode = new(); private readonly BindableList selectedHitObjects = new(); @@ -22,8 +22,6 @@ public class EditNoteModeState : Component, IEditNoteModeState public void ChangeEditMode(NoteEditMode mode) => bindableEditMode.Value = mode; - public BindableList SelectedItems { get; } = new(); - public Bindable BindableSpecialAction { get; } = new(); public Bindable NoteEditPropertyMode { get; } = new(); @@ -34,5 +32,8 @@ private void load(EditorBeatmap editorBeatmap) BindablesUtils.Sync(SelectedItems, selectedHitObjects); selectedHitObjects.BindTo(editorBeatmap.SelectedHitObjects); } + + protected override bool IsWriteLyricPropertyLocked(Lyric lyric) + => HitObjectWritableUtils.IsCreateOrRemoveNoteLocked(lyric); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs index 9edf45583..a01ed0d08 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs @@ -2,12 +2,12 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; -using osu.Framework.Graphics; +using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { - public class EditRomajiModeState : Component, IEditRomajiModeState + public class EditRomajiModeState : ModeStateWithBlueprintContainer, IEditRomajiModeState { private readonly Bindable bindableEditMode = new(); @@ -16,6 +16,7 @@ public class EditRomajiModeState : Component, IEditRomajiModeState public void ChangeEditMode(TextTagEditMode mode) => bindableEditMode.Value = mode; - public BindableList SelectedItems { get; } = new(); + protected override bool IsWriteLyricPropertyLocked(Lyric lyric) + => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.RomajiTags)); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs index 2764e1865..860bddba7 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs @@ -2,12 +2,12 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; -using osu.Framework.Graphics; +using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { - public class EditRubyModeState : Component, IEditRubyModeState + public class EditRubyModeState : ModeStateWithBlueprintContainer, IEditRubyModeState { private readonly Bindable bindableEditMode = new(); @@ -16,6 +16,7 @@ public class EditRubyModeState : Component, IEditRubyModeState public void ChangeEditMode(TextTagEditMode mode) => bindableEditMode.Value = mode; - public BindableList SelectedItems { get; } = new(); + protected override bool IsWriteLyricPropertyLocked(Lyric lyric) + => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.RubyTags)); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs index 702daa9a6..06b5832a5 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs @@ -3,21 +3,18 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Screens.Edit; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { - public class TimeTagModeState : Component, ITimeTagModeState + public class TimeTagModeState : ModeStateWithBlueprintContainer, ITimeTagModeState { private readonly Bindable bindableEditMode = new(); public IBindable BindableEditMode => bindableEditMode; - public BindableList SelectedItems { get; } = new(); - public BindableFloat BindableRecordZoom { get; } = new(); public BindableFloat BindableAdjustZoom { get; } = new(); @@ -36,5 +33,8 @@ private void load(EditorClock editorClock) public void ChangeEditMode(TimeTagEditMode mode) => bindableEditMode.Value = mode; + + protected override bool IsWriteLyricPropertyLocked(Lyric lyric) + => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.TimeTags)); } } From 6403ea9eede23ca9ba04e0447d30b0190b013b7d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 11 Sep 2022 11:17:39 +0800 Subject: [PATCH 3/7] Move the select first blueprint event into the state. --- .../Lyrics/States/Modes/EditNoteModeState.cs | 13 ++++++- .../States/Modes/EditRomajiModeState.cs | 7 ++++ .../Lyrics/States/Modes/EditRubyModeState.cs | 7 ++++ .../Modes/ModeStateWithBlueprintContainer.cs | 39 +++++++++++++++---- .../Lyrics/States/Modes/TimeTagModeState.cs | 8 ++++ 5 files changed, 66 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs index c04ae150f..927c433e5 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs @@ -1,6 +1,8 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Notes; @@ -17,6 +19,9 @@ public class EditNoteModeState : ModeStateWithBlueprintContainer, IEditNot private readonly Bindable bindableEditMode = new(); private readonly BindableList selectedHitObjects = new(); + [Resolved, AllowNull] + private EditorBeatmap editorBeatmap { get; set; } + public IBindable BindableEditMode => bindableEditMode; public void ChangeEditMode(NoteEditMode mode) @@ -27,7 +32,7 @@ public void ChangeEditMode(NoteEditMode mode) public Bindable NoteEditPropertyMode { get; } = new(); [BackgroundDependencyLoader] - private void load(EditorBeatmap editorBeatmap) + private void load() { BindablesUtils.Sync(SelectedItems, selectedHitObjects); selectedHitObjects.BindTo(editorBeatmap.SelectedHitObjects); @@ -35,5 +40,11 @@ private void load(EditorBeatmap editorBeatmap) protected override bool IsWriteLyricPropertyLocked(Lyric lyric) => HitObjectWritableUtils.IsCreateOrRemoveNoteLocked(lyric); + + protected override bool SelectFirstProperty(Lyric lyric) + => BindableEditMode.Value == NoteEditMode.Edit; + + protected override IEnumerable SelectableProperties(Lyric lyric) + => EditorBeatmapUtils.GetNotesByLyric(editorBeatmap, lyric); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs index a01ed0d08..87a7b209d 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs @@ -1,6 +1,7 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; @@ -18,5 +19,11 @@ public void ChangeEditMode(TextTagEditMode mode) protected override bool IsWriteLyricPropertyLocked(Lyric lyric) => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.RomajiTags)); + + protected override bool SelectFirstProperty(Lyric lyric) + => BindableEditMode.Value == TextTagEditMode.Edit; + + protected override IEnumerable SelectableProperties(Lyric lyric) + => lyric.RomajiTags; } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs index 860bddba7..7c4a6a03f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs @@ -1,6 +1,7 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; @@ -18,5 +19,11 @@ public void ChangeEditMode(TextTagEditMode mode) protected override bool IsWriteLyricPropertyLocked(Lyric lyric) => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.RubyTags)); + + protected override bool SelectFirstProperty(Lyric lyric) + => BindableEditMode.Value == TextTagEditMode.Edit; + + protected override IEnumerable SelectableProperties(Lyric lyric) + => lyric.RubyTags; } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs index d1a5c4f49..c79316c12 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ModeStateWithBlueprintContainer.cs @@ -1,6 +1,9 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -21,7 +24,7 @@ protected ModeStateWithBlueprintContainer() { bindableMode.BindValueChanged(e => { - triggerDisableStateChanged(); + TriggerDisableStateChanged(); }); bindableCaretPosition.BindValueChanged(e => @@ -34,28 +37,50 @@ protected ModeStateWithBlueprintContainer() return; bindableLyricPropertyWritableVersion.BindTo(lyric.LyricPropertyWritableVersion); - triggerDisableStateChanged(); + TriggerDisableStateChanged(); }); bindableLyricPropertyWritableVersion.BindValueChanged(_ => { - triggerDisableStateChanged(); + TriggerDisableStateChanged(); }); } - private void triggerDisableStateChanged() + protected virtual void TriggerDisableStateChanged() { - var lyric = bindableCaretPosition.Value?.Lyric; - if (lyric == null) + var caret = bindableCaretPosition.Value; + if (caret == null) return; + var lyric = caret.Lyric; + var generateType = caret.GenerateType; + + SelectedItems.Clear(); bool locked = IsWriteLyricPropertyLocked(lyric); if (locked) - SelectedItems.Clear(); + return; + + switch (generateType) + { + case CaretGenerateType.Action: + if (SelectFirstProperty(lyric)) + SelectedItems.Add(SelectableProperties(lyric).FirstOrDefault()); + break; + + case CaretGenerateType.TargetLyric: + break; + + default: + throw new ArgumentOutOfRangeException(); + } } protected abstract bool IsWriteLyricPropertyLocked(Lyric lyric); + protected abstract bool SelectFirstProperty(Lyric lyric); + + protected abstract IEnumerable SelectableProperties(Lyric lyric); + [BackgroundDependencyLoader] private void load(ILyricEditorState state, ILyricCaretState lyricCaretState) { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs index 06b5832a5..f79691a79 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs @@ -1,6 +1,8 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Utils; @@ -36,5 +38,11 @@ public void ChangeEditMode(TimeTagEditMode mode) protected override bool IsWriteLyricPropertyLocked(Lyric lyric) => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.TimeTags)); + + protected override bool SelectFirstProperty(Lyric lyric) + => false; + + protected override IEnumerable SelectableProperties(Lyric lyric) + => Array.Empty(); } } From b1fb995ccba0970bc015b2f6ecc2025a9a0e18f2 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 11 Sep 2022 11:21:23 +0800 Subject: [PATCH 4/7] Remove the disable state in here. Because all the events has been moved into the state. --- .../Lyrics/Extends/Notes/NoteEditPropertySection.cs | 10 ---------- .../Lyrics/Extends/RubyRomaji/TextTagEditSection.cs | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Notes/NoteEditPropertySection.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Notes/NoteEditPropertySection.cs index 05f451b01..33f75ba3f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Notes/NoteEditPropertySection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Notes/NoteEditPropertySection.cs @@ -74,16 +74,6 @@ void reCreateEditComponents() } } - protected override void UpdateDisabledState(bool disabled) - { - if (disabled) - return; - - // should auto-focus to the first note property if change the lyric. - var firstTextTagTextBox = Children.OfType>().FirstOrDefault(); - firstTextTagTextBox?.Focus(); - } - [BackgroundDependencyLoader] private void load(IEditNoteModeState editNoteModeState) { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/TextTagEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/TextTagEditSection.cs index 7e2cf6241..3937386fa 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/TextTagEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/TextTagEditSection.cs @@ -57,16 +57,6 @@ protected override void OnLyricChanged(Lyric lyric) TextTags.BindTo(GetBindableTextTags(lyric)); } - protected override void UpdateDisabledState(bool disabled) - { - if (disabled) - return; - - // should auto-focus to the first time-tag if change the lyric. - var firstTextTagTextBox = Children.OfType>().FirstOrDefault(); - firstTextTagTextBox?.Focus(); - } - private void addCreateButton() { var fillFlowContainer = Content as FillFlowContainer; From 3d180dccea569cbc336e3db5fc2c6714d08add28 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 11 Sep 2022 11:26:51 +0800 Subject: [PATCH 5/7] change the behavior. before: trigger the focus, then add the focused item into the seleccted items. after: focus the item if only has one selected item. --- .../Extends/Components/LabelledObjectFieldTextBox.cs | 12 +++++++++++- .../RubyRomaji/Components/LabelledTextTagTextBox.cs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs index 215e6c1b5..35fc5f81f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs @@ -45,6 +45,9 @@ protected LabelledObjectFieldTextBox(T item) { bool highLight = SelectedItems.Contains(item); Component.HighLight = highLight; + + if (SelectedItems.Contains(item) && SelectedItems.Count == 1) + focus(); }); if (InternalChildren[1] is not FillFlowContainer fillFlowContainer) @@ -99,14 +102,21 @@ protected void TriggerUnselect() } }; - public void Focus() + private void focus() { Schedule(() => { + var focusedDrawable = GetContainingInputManager().FocusedDrawable; + if (focusedDrawable != null && IsFocused(focusedDrawable)) + return; + GetContainingInputManager().ChangeFocus(Component); }); } + protected virtual bool IsFocused(Drawable focusedDrawable) + => focusedDrawable == Component; + protected class ObjectFieldTextBox : OsuTextBox { [Resolved] diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs index 9273abdd4..bf614cc72 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs @@ -153,6 +153,9 @@ protected sealed override string GetFieldValue(T item) protected abstract void RemoveTextTag(T item); + protected override bool IsFocused(Drawable focusedDrawable) + => base.IsFocused(focusedDrawable) || focusedDrawable == indexShiftingPart; + public new CompositeDrawable TabbableContentContainer { set From 3b6feb1d9181ff6a2831c800ec9b3af2d952bf54 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 11 Sep 2022 15:40:08 +0800 Subject: [PATCH 6/7] Should not change the border size because still need to highlight the textarea without focus. --- .../Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs index 35fc5f81f..f9ebcab25 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs @@ -134,6 +134,9 @@ protected override void OnFocusLost(FocusLostEvent e) { base.OnFocusLost(e); + // should not change the border size because still need to highlight the textarea without focus. + BorderThickness = 3f; + // note: should trigger commit event first in the base class. Selected?.Invoke(false); } From 9c0d30c10572aeff10535c74001c8f42b0de10e6 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 11 Sep 2022 15:42:25 +0800 Subject: [PATCH 7/7] Should not deselect the item from the selections after focus out. Because click the item in the row might cause the focus-out event in the object field textbox. --- .../Components/LabelledObjectFieldSwitchButton.cs | 11 ----------- .../Components/LabelledObjectFieldTextBox.cs | 11 ----------- .../Components/LabelledTextTagTextBox.cs | 14 -------------- 3 files changed, 36 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldSwitchButton.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldSwitchButton.cs index 5dd57cef6..6cb5c7014 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldSwitchButton.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldSwitchButton.cs @@ -59,11 +59,6 @@ protected void TriggerSelect() SelectedItems.Add(item); } - protected void TriggerUnselect() - { - SelectedItems.Remove(item); - } - protected abstract bool GetFieldValue(T item); protected abstract void ApplyValue(T item, bool value); @@ -73,13 +68,7 @@ protected void TriggerUnselect() Selected = selected => { if (selected) - { TriggerSelect(); - } - else - { - TriggerUnselect(); - } } }; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs index f9ebcab25..de829ef12 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Components/LabelledObjectFieldTextBox.cs @@ -73,11 +73,6 @@ protected void TriggerSelect() SelectedItems.Add(item); } - protected void TriggerUnselect() - { - SelectedItems.Remove(item); - } - protected abstract string GetFieldValue(T item); protected abstract void ApplyValue(T item, string value); @@ -92,13 +87,7 @@ protected void TriggerUnselect() Selected = selected => { if (selected) - { TriggerSelect(); - } - else - { - TriggerUnselect(); - } } }; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs index bf614cc72..12e05607b 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/RubyRomaji/Components/LabelledTextTagTextBox.cs @@ -65,14 +65,6 @@ protected LabelledTextTagTextBox(Lyric lyric, T textTag) // trigger selected if hover on delete button. TriggerSelect(); } - else - { - // do not clear current selected if typing. - if (Component.HasFocus) - return; - - TriggerUnselect(); - } } } }); @@ -95,13 +87,7 @@ protected LabelledTextTagTextBox(Lyric lyric, T textTag) Selected = selected => { if (selected) - { TriggerSelect(); - } - else - { - TriggerUnselect(); - } }, Action = (indexType, action) => {