From 92b3f56872350f25f80c11161bb237183df731a2 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 11 Sep 2022 13:46:42 +0800 Subject: [PATCH 1/2] Should focus to the first textbox after open the popover. Also, should be tabbable between textboxes. --- .../Components/UserInterfaceV2/NoteEditPopover.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs index 1bcbee588..11703786a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs @@ -37,24 +37,31 @@ public NoteEditPopover(Note note) { Label = "Text", Description = "The text display on the note.", - Current = note.TextBindable + Current = note.TextBindable, + TabbableContentContainer = this }, rubyText = new LabelledTextBox { Label = "Ruby text", Description = "Should place something like ruby, 拼音 or ふりがな.", - Current = note.RubyTextBindable + Current = note.RubyTextBindable, + TabbableContentContainer = this }, display = new LabelledSwitchButton { Label = "Display", Description = "This note will be hidden and not scorable if not display.", - Current = note.DisplayBindable + Current = note.DisplayBindable, } } } }; + ScheduleAfterChildren(() => + { + GetContainingInputManager().ChangeFocus(text); + }); + text.OnCommit += (sender, newText) => { if (!newText) From 731639e066fc37232eb4dceff340f1b66f47b308 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 11 Sep 2022 14:58:34 +0800 Subject: [PATCH 2/2] Should wrap into the section for the same style as edit detail popover in the singer editor. --- .../UserInterfaceV2/NoteEditPopover.cs | 141 ++++++++++-------- 1 file changed, 81 insertions(+), 60 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs index 11703786a..e135fd840 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/NoteEditPopover.cs @@ -3,98 +3,119 @@ #nullable disable +using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Localisation; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Notes; +using osu.Game.Rulesets.Karaoke.Edit.Components.Containers; using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Edit.Components.UserInterfaceV2 { public class NoteEditPopover : OsuPopover { - [Resolved(canBeNull: true)] - private INotePropertyChangeHandler notePropertyChangeHandler { get; set; } - public NoteEditPopover(Note note) { - LabelledTextBox text; - LabelledTextBox rubyText; - LabelledSwitchButton display; + if (note == null) + throw new ArgumentNullException(nameof(note)); - Children = new Drawable[] + Child = new OsuScrollContainer { - new FillFlowContainer + Height = 320, + Width = 300, + Child = new FillFlowContainer
{ - Width = 200, Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Children = new Drawable[] + Children = new Section[] { - text = new LabelledTextBox - { - Label = "Text", - Description = "The text display on the note.", - Current = note.TextBindable, - TabbableContentContainer = this - }, - rubyText = new LabelledTextBox - { - Label = "Ruby text", - Description = "Should place something like ruby, 拼音 or ふりがな.", - Current = note.RubyTextBindable, - TabbableContentContainer = this - }, - display = new LabelledSwitchButton - { - Label = "Display", - Description = "This note will be hidden and not scorable if not display.", - Current = note.DisplayBindable, - } + new NoteSection(note), } } }; + } - ScheduleAfterChildren(() => - { - GetContainingInputManager().ChangeFocus(text); - }); + private class NoteSection : Section + { + private INotePropertyChangeHandler notePropertyChangeHandler { get; set; } - text.OnCommit += (sender, newText) => + protected override LocalisableString Title => "Note property"; + + public NoteSection(Note note) { - if (!newText) - return; + LabelledTextBox text; + LabelledTextBox rubyText; + LabelledSwitchButton display; - string text = sender.Text.Trim(); - notePropertyChangeHandler?.ChangeText(text); - }; + Children = new Drawable[] + { + text = new LabelledTextBox + { + Label = "Text", + Description = "The text display on the note.", + Current = note.TextBindable, + TabbableContentContainer = this + }, + rubyText = new LabelledTextBox + { + Label = "Ruby text", + Description = "Should place something like ruby, 拼音 or ふりがな.", + Current = note.RubyTextBindable, + TabbableContentContainer = this + }, + display = new LabelledSwitchButton + { + Label = "Display", + Description = "This note will be hidden and not scorable if not display.", + Current = note.DisplayBindable, + } + }; - rubyText.OnCommit += (sender, newText) => - { - if (!newText) - return; + ScheduleAfterChildren(() => + { + GetContainingInputManager().ChangeFocus(text); + }); - string text = sender.Text.Trim(); - notePropertyChangeHandler?.ChangeRubyText(text); - }; + text.OnCommit += (sender, newText) => + { + if (!newText) + return; - display.Current.BindValueChanged(v => - { - notePropertyChangeHandler?.ChangeDisplayState(v.NewValue); - }); - } + string text = sender.Text.Trim(); + notePropertyChangeHandler?.ChangeText(text); + }; - [BackgroundDependencyLoader(true)] - private void load(HitObjectComposer composer) - { - if (notePropertyChangeHandler != null || composer == null) - return; + rubyText.OnCommit += (sender, newText) => + { + if (!newText) + return; + + string text = sender.Text.Trim(); + notePropertyChangeHandler?.ChangeRubyText(text); + }; + + display.Current.BindValueChanged(v => + { + notePropertyChangeHandler?.ChangeDisplayState(v.NewValue); + }); + } + + [BackgroundDependencyLoader(true)] + private void load(HitObjectComposer composer) + { + if (notePropertyChangeHandler != null || composer == null) + return; - // todo: not a good way to get change handler, might remove or found another way eventually. - // cannot get change handler directly in editor screen, so should trying to get from karaoke hit object composer. - notePropertyChangeHandler = composer.Dependencies.Get(); + // todo: not a good way to get change handler, might remove or found another way eventually. + // cannot get change handler directly in editor screen, so should trying to get from karaoke hit object composer. + notePropertyChangeHandler = composer.Dependencies.Get(); + } } } }