From 847da204973c27a831ab82a2f76846a9ccb8c2d0 Mon Sep 17 00:00:00 2001 From: Maiko Date: Wed, 13 Mar 2024 00:18:55 +0900 Subject: [PATCH 1/2] Lock editing of unselected notes --- OpenUtau.Core/Util/Preferences.cs | 3 ++ OpenUtau/Strings/Strings.axaml | 4 +++ OpenUtau/Strings/Strings.ja-JP.axaml | 6 +++- OpenUtau/ViewModels/PianoRollViewModel.cs | 3 ++ OpenUtau/Views/NoteEditStates.cs | 4 +-- OpenUtau/Views/PianoRollWindow.axaml | 36 ++++++++++++++++++++--- OpenUtau/Views/PianoRollWindow.axaml.cs | 32 ++++++++++++++++---- 7 files changed, 76 insertions(+), 12 deletions(-) diff --git a/OpenUtau.Core/Util/Preferences.cs b/OpenUtau.Core/Util/Preferences.cs index 0fabcc1fb..392352069 100644 --- a/OpenUtau.Core/Util/Preferences.cs +++ b/OpenUtau.Core/Util/Preferences.cs @@ -186,6 +186,9 @@ public class SerializablePreferences { public string PhoneticAssistant = string.Empty; public string RecentOpenSingerDirectory = string.Empty; public string RecentOpenProjectDirectory = string.Empty; + public bool LockUnselectedNotesPitch = true; + public bool LockUnselectedNotesVibrato = true; + public bool LockUnselectedNotesExpressions = true; public bool VoicebankPublishUseIgnore = true; public string VoicebankPublishIgnores = "#Adobe Audition\n*.pkf\n\n#UTAU Engines\n*.ctspec\n*.d4c\n*.dio\n*.frc\n*.frt\n*.frq\n*.harvest\n*.lessaudio\n*.llsm\n*.mrq\n*.pitchtier\n*.pkf\n*.platinum\n*.pmk\n*.star\n*.uspec\n*.vs4ufrq\n\n#UTAU related tools\n$read\n*.setParam-Scache\n*.lbp\n*.lbp.caches/*\n\n#OpenUtau\nerrors.txt"; diff --git a/OpenUtau/Strings/Strings.axaml b/OpenUtau/Strings/Strings.axaml index 2b51b8f0f..c366354b2 100644 --- a/OpenUtau/Strings/Strings.axaml +++ b/OpenUtau/Strings/Strings.axaml @@ -118,6 +118,10 @@ Copy Cut Delete + Lock editing of unselected notes + Pitch Points + Vibrato + Expressions Paste Redo Select All diff --git a/OpenUtau/Strings/Strings.ja-JP.axaml b/OpenUtau/Strings/Strings.ja-JP.axaml index 770d112e0..717d949e3 100644 --- a/OpenUtau/Strings/Strings.ja-JP.axaml +++ b/OpenUtau/Strings/Strings.ja-JP.axaml @@ -118,10 +118,14 @@ コピー 切り取り 削除 + 選択されていないノートの編集をロック + ピッチ点 + ビブラート + 表情 貼り付け やり直す 全て選択 - 元に戻る + 元に戻す ファイル OpenUTAUを終了 音声をエクスポート diff --git a/OpenUtau/ViewModels/PianoRollViewModel.cs b/OpenUtau/ViewModels/PianoRollViewModel.cs index e91af1704..752d4c8e5 100644 --- a/OpenUtau/ViewModels/PianoRollViewModel.cs +++ b/OpenUtau/ViewModels/PianoRollViewModel.cs @@ -48,6 +48,9 @@ public class PianoRollViewModel : ViewModelBase, ICmdSubscriber { [Reactive] public NotesViewModel NotesViewModel { get; set; } [Reactive] public PlaybackViewModel? PlaybackViewModel { get; set; } + public bool LockPitchPoints { get => Preferences.Default.LockUnselectedNotesPitch; } + public bool LockVibrato { get => Preferences.Default.LockUnselectedNotesVibrato; } + public bool LockExpressions { get => Preferences.Default.LockUnselectedNotesExpressions; } public bool ShowPortrait { get => Preferences.Default.ShowPortrait; } public bool ShowIcon { get => Preferences.Default.ShowIcon; } public bool ShowGhostNotes { get => Preferences.Default.ShowGhostNotes; } diff --git a/OpenUtau/Views/NoteEditStates.cs b/OpenUtau/Views/NoteEditStates.cs index 29608b587..561ef3fa8 100644 --- a/OpenUtau/Views/NoteEditStates.cs +++ b/OpenUtau/Views/NoteEditStates.cs @@ -680,7 +680,7 @@ private void UpdatePhonemeExp(IPointer pointer, Point point, bool shiftHeld) { startValue = Math.Max(descriptor.min, Math.Min(descriptor.max, startValue)); } foreach (var hit in hits) { - if (notesVm.Selection.Count > 0 && !notesVm.Selection.Contains(hit.phoneme.Parent)) { + if (Preferences.Default.LockUnselectedNotesExpressions && notesVm.Selection.Count > 0 && !notesVm.Selection.Contains(hit.phoneme.Parent)) { continue; } var valuePoint = notesVm.TickToneToPoint(hit.note.position + hit.phoneme.position, 0); @@ -758,7 +758,7 @@ private void ResetPhonemeExp(IPointer pointer, Point point) { return; } foreach (var hit in hits) { - if (notesVm.Selection.Count > 0 && !notesVm.Selection.Contains(hit.phoneme.Parent)) { + if (Preferences.Default.LockUnselectedNotesExpressions && notesVm.Selection.Count > 0 && !notesVm.Selection.Contains(hit.phoneme.Parent)) { continue; } if (!hit.phoneme.GetExpression(notesVm.Project, track, key).Item2) { diff --git a/OpenUtau/Views/PianoRollWindow.axaml b/OpenUtau/Views/PianoRollWindow.axaml index 7f9484a8d..7e1a78785 100644 --- a/OpenUtau/Views/PianoRollWindow.axaml +++ b/OpenUtau/Views/PianoRollWindow.axaml @@ -195,6 +195,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -264,10 +296,6 @@ - - - - diff --git a/OpenUtau/Views/PianoRollWindow.axaml.cs b/OpenUtau/Views/PianoRollWindow.axaml.cs index 5dec3e092..f76f5788f 100644 --- a/OpenUtau/Views/PianoRollWindow.axaml.cs +++ b/OpenUtau/Views/PianoRollWindow.axaml.cs @@ -7,6 +7,7 @@ using Avalonia.Controls.Primitives; using Avalonia.Input; using Avalonia.Interactivity; +using Melanchall.DryWetMidi.Multimedia; using OpenUtau.App.Controls; using OpenUtau.App.ViewModels; using OpenUtau.Core; @@ -86,6 +87,23 @@ void OnMenuPointerLeave(object sender, PointerEventArgs args) { Focus(); // Force unfocus menu for key down events. } + // Edit menu + void OnMenuLockPitchPoints(object sender, RoutedEventArgs args) { + Preferences.Default.LockUnselectedNotesPitch = !Preferences.Default.LockUnselectedNotesPitch; + Preferences.Save(); + ViewModel.RaisePropertyChanged(nameof(ViewModel.LockPitchPoints)); + } + void OnMenuLockVibrato(object sender, RoutedEventArgs args) { + Preferences.Default.LockUnselectedNotesVibrato = !Preferences.Default.LockUnselectedNotesVibrato; + Preferences.Save(); + ViewModel.RaisePropertyChanged(nameof(ViewModel.LockVibrato)); + } + void OnMenuLockExpressions(object sender, RoutedEventArgs args) { + Preferences.Default.LockUnselectedNotesExpressions = !Preferences.Default.LockUnselectedNotesExpressions; + Preferences.Save(); + ViewModel.RaisePropertyChanged(nameof(ViewModel.LockExpressions)); + } + // View menu void OnMenuShowPortrait(object sender, RoutedEventArgs args) { Preferences.Default.ShowPortrait = !Preferences.Default.ShowPortrait; @@ -396,13 +414,13 @@ private void NotesCanvasLeftPointerPressed(Control control, PointerPoint point, return; } var pitHitInfo = ViewModel.NotesViewModel.HitTest.HitTestPitchPoint(point.Position); - if (pitHitInfo.Note != null) { + if (pitHitInfo.Note != null && !IsLockedEdit(ViewModel.LockPitchPoints, pitHitInfo.Note)) { editState = new PitchPointEditState(control, ViewModel, this, pitHitInfo.Note, pitHitInfo.Index, pitHitInfo.OnPoint, pitHitInfo.X, pitHitInfo.Y); return; } var vbrHitInfo = ViewModel.NotesViewModel.HitTest.HitTestVibrato(point.Position); - if (vbrHitInfo.hit) { + if (vbrHitInfo.hit && !IsLockedEdit(ViewModel.LockVibrato, vbrHitInfo.note)) { if (vbrHitInfo.hitToggle) { ViewModel.NotesViewModel.ToggleVibrato(vbrHitInfo.note); return; @@ -491,7 +509,7 @@ private void NotesCanvasRightPointerPressed(Control control, PointerPoint point, } if (ViewModel.NotesViewModel.ShowPitch) { var pitHitInfo = ViewModel.NotesViewModel.HitTest.HitTestPitchPoint(point.Position); - if (pitHitInfo.Note != null) { + if (pitHitInfo.Note != null && !IsLockedEdit(ViewModel.LockPitchPoints, pitHitInfo.Note)) { ViewModel.NotesContextMenuItems.Add(new MenuItemViewModel() { Header = ThemeManager.GetString("context.pitch.easeinout"), Command = ViewModel.PitEaseInOutCommand, @@ -608,12 +626,12 @@ public void NotesCanvasPointerMoved(object sender, PointerEventArgs args) { return; } var pitHitInfo = ViewModel.NotesViewModel.HitTest.HitTestPitchPoint(point.Position); - if (pitHitInfo.Note != null) { + if (pitHitInfo.Note != null && !IsLockedEdit(ViewModel.LockPitchPoints, pitHitInfo.Note)) { Cursor = ViewConstants.cursorHand; return; } var vbrHitInfo = ViewModel.NotesViewModel.HitTest.HitTestVibrato(point.Position); - if (vbrHitInfo.hit) { + if (vbrHitInfo.hit && !IsLockedEdit(ViewModel.LockVibrato, vbrHitInfo.note)) { if (vbrHitInfo.hitDepth) { Cursor = ViewConstants.cursorSizeNS; } else if (vbrHitInfo.hitPeriod) { @@ -872,6 +890,10 @@ public void PhonemeCanvasPointerReleased(object sender, PointerReleasedEventArgs Cursor = null; } + private bool IsLockedEdit(bool locked, UNote note) { + return locked && ViewModel.NotesViewModel.Selection.Count > 0 && !ViewModel.NotesViewModel.Selection.Contains(note); + } + public void OnSnapDivMenuButton(object sender, RoutedEventArgs args) { SnapDivMenu.PlacementTarget = sender as Button; SnapDivMenu.Open(); From 06d17d2ec7e004798339f591ca6fb1d7a1095491 Mon Sep 17 00:00:00 2001 From: Maiko Date: Wed, 13 Mar 2024 00:21:39 +0900 Subject: [PATCH 2/2] delete using --- OpenUtau/Views/PianoRollWindow.axaml.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenUtau/Views/PianoRollWindow.axaml.cs b/OpenUtau/Views/PianoRollWindow.axaml.cs index f76f5788f..fd67ed5b1 100644 --- a/OpenUtau/Views/PianoRollWindow.axaml.cs +++ b/OpenUtau/Views/PianoRollWindow.axaml.cs @@ -7,7 +7,6 @@ using Avalonia.Controls.Primitives; using Avalonia.Input; using Avalonia.Interactivity; -using Melanchall.DryWetMidi.Multimedia; using OpenUtau.App.Controls; using OpenUtau.App.ViewModels; using OpenUtau.Core;