diff --git a/OpenUtau.Core/Util/Preferences.cs b/OpenUtau.Core/Util/Preferences.cs index f14fe185d..bdd0377dc 100644 --- a/OpenUtau.Core/Util/Preferences.cs +++ b/OpenUtau.Core/Util/Preferences.cs @@ -252,7 +252,7 @@ public class SerializablePreferences { errors.txt "; public string RecoveryPath = string.Empty; - public bool DetachPianoRoll = false; + public bool DetachPianoRoll = true; // ----- Mix FX (post-processing) ----- // Per-track FX state lives in UTrack.MixFx and the project ustx. diff --git a/OpenUtau/Controls/PianoRoll.axaml b/OpenUtau/Controls/PianoRoll.axaml index 647d22145..4b50ca0a4 100644 --- a/OpenUtau/Controls/PianoRoll.axaml +++ b/OpenUtau/Controls/PianoRoll.axaml @@ -296,6 +296,11 @@ + + + + + @@ -353,14 +358,6 @@ - - - - - - - - @@ -538,6 +535,7 @@ + + + + + @@ -626,6 +628,18 @@ + + @@ -678,4 +692,4 @@ - + \ No newline at end of file diff --git a/OpenUtau/Controls/PianoRoll.axaml.cs b/OpenUtau/Controls/PianoRoll.axaml.cs index 2fd05db2d..9d696a92e 100644 --- a/OpenUtau/Controls/PianoRoll.axaml.cs +++ b/OpenUtau/Controls/PianoRoll.axaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -11,6 +11,7 @@ using Avalonia.Controls.Primitives; using Avalonia.Input; using Avalonia.Interactivity; +using Avalonia.Threading; using OpenUtau.App.ViewModels; using OpenUtau.App.Views; using OpenUtau.Core; @@ -236,6 +237,14 @@ await MessageBox.ShowProcessing(RootWindow, $"{name} - ? / ?", } }); + MessageBus.Current.Listen() + .Subscribe(e => { + if(e.refreshItem == "Attachment") { + MainWindow?.SetPianoRollAttachment(); + ViewModel.RaisePropertyChanged(nameof(ViewModel.PianoRollDetached)); + } + }); + DocManager.Inst.AddSubscriber(this); } @@ -347,19 +356,22 @@ void OnMenuSearchNote(object sender, RoutedEventArgs args) { } void OnMenuDetachPianoRoll(object sender, RoutedEventArgs args) { - MainWindow?.SetPianoRollAttachment(); - ViewModel.RaisePropertyChanged(nameof(ViewModel.PianoRollDetached)); + Preferences.Default.DetachPianoRoll ^= true; + Preferences.Save(); + MessageBus.Current.SendMessage(new PianorollRefreshEvent("Attachment")); + Dispatcher.UIThread.Post(() => { + ViewModel.RaisePropertyChanged(nameof(ViewModel.HideMenuItemVisible)); + }); } - void OnMenuHidePianoRoll(object sender, RoutedEventArgs args) { + void OnHidePianoRoll(object sender, RoutedEventArgs args) { if (RootWindow.DataContext is MainWindowViewModel mwvm) { mwvm.ShowPianoRoll = false; - } else { - RootWindow.Hide(); } } // Edit Tools + private CancellationTokenSource? _longPressCts; private async void OnToolButtonPointerPressed(object? sender, PointerPressedEventArgs args) { if (!args.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return; @@ -2017,4 +2029,4 @@ public void OnNext(UCommand cmd, bool isUndo) { } } } -} +} \ No newline at end of file diff --git a/OpenUtau/Strings/Strings.axaml b/OpenUtau/Strings/Strings.axaml index bfc779b45..4ad32d1d3 100644 --- a/OpenUtau/Strings/Strings.axaml +++ b/OpenUtau/Strings/Strings.axaml @@ -439,9 +439,6 @@ Warning: this option removes custom presets. Copy Key (for scale degree display) - Piano Roll - Detach - Hide Batch Edits Running batch edit Lyrics @@ -516,6 +513,7 @@ Warning: this option removes custom presets. View Vibrato (U) View Waveform (W) View Expressions (L) + Hide Piano Roll Draw Pitch Tool (Shift + 1) Left click to draw Right click to reset @@ -573,6 +571,7 @@ Warning: this option removes custom presets. Show other tracks' notes on piano roll Show icon on piano roll Show portrait on piano roll + Show piano roll in separate window Singer name display language Theme Dark diff --git a/OpenUtau/ViewModels/MainWindowViewModel.cs b/OpenUtau/ViewModels/MainWindowViewModel.cs index d3090673f..aa656625c 100644 --- a/OpenUtau/ViewModels/MainWindowViewModel.cs +++ b/OpenUtau/ViewModels/MainWindowViewModel.cs @@ -133,8 +133,8 @@ public MainWindowViewModel() { this.WhenAnyValue(vm => vm.ShowPianoRoll) .Subscribe(x => { - PianoRollMaxHeight = x ? double.PositiveInfinity : 0; - PianoRollMinHeight = x ? ViewConstants.PianoRollMinHeight : 0; + PianoRollMaxHeight = x ? double.PositiveInfinity : 0.01; + PianoRollMinHeight = x ? ViewConstants.PianoRollMinHeight : 0.01; }); } diff --git a/OpenUtau/ViewModels/PianoRollViewModel.cs b/OpenUtau/ViewModels/PianoRollViewModel.cs index f4f1bfbcb..14120b084 100644 --- a/OpenUtau/ViewModels/PianoRollViewModel.cs +++ b/OpenUtau/ViewModels/PianoRollViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reactive; @@ -68,6 +68,7 @@ public class PianoRollViewModel : ViewModelBase, ICmdSubscriber { public bool PlaybackAutoScroll1 { get => Preferences.Default.PlaybackAutoScroll == 1 ? true : false; } public bool PlaybackAutoScroll2 { get => Preferences.Default.PlaybackAutoScroll == 2 ? true : false; } public bool PianoRollDetached { get => Preferences.Default.DetachPianoRoll; } + public bool HideMenuItemVisible => !Preferences.Default.DetachPianoRoll; public bool ShowPhonemizerTags { get => Preferences.Default.ShowPhonemizerTags; set { @@ -319,4 +320,4 @@ public void OnNext(UCommand cmd, bool isUndo) { #endregion } -} +} \ No newline at end of file diff --git a/OpenUtau/ViewModels/PreferencesViewModel.cs b/OpenUtau/ViewModels/PreferencesViewModel.cs index 0683b822e..d1b4dc766 100644 --- a/OpenUtau/ViewModels/PreferencesViewModel.cs +++ b/OpenUtau/ViewModels/PreferencesViewModel.cs @@ -100,6 +100,7 @@ public int SafeMaxThreadCount { [Reactive] public bool ShowPortrait { get; set; } [Reactive] public bool ShowIcon { get; set; } [Reactive] public bool ShowGhostNotes { get; set; } + [Reactive] public bool DetachPianoRoll { get; set; } [Reactive] public bool ThemeEditable { get; set; } public List ThemeItems => ThemeManager.GetAvailableThemes(); public bool IsThemeEditorOpen => Views.ThemeEditorWindow.IsOpen; @@ -182,6 +183,7 @@ public PreferencesViewModel() { ShowPortrait = Preferences.Default.ShowPortrait; ShowIcon = Preferences.Default.ShowIcon; ShowGhostNotes = Preferences.Default.ShowGhostNotes; + DetachPianoRoll = Preferences.Default.DetachPianoRoll; Beta = Preferences.Default.Beta; LyricsHelper = LyricsHelpers.FirstOrDefault(option => option.klass.Equals(ActiveLyricsHelper.Inst.GetPreferred())); LyricsHelperBrackets = Preferences.Default.LyricsHelperBrackets; @@ -299,6 +301,12 @@ public PreferencesViewModel() { Preferences.Save(); MessageBus.Current.SendMessage(new PianorollRefreshEvent("Part")); }); + this.WhenAnyValue(vm => vm.DetachPianoRoll) + .Subscribe(detachPianoRoll => { + Preferences.Default.DetachPianoRoll = detachPianoRoll; + Preferences.Save(); + MessageBus.Current.SendMessage(new PianorollRefreshEvent("Attachment")); + }); this.WhenAnyValue(vm => vm.Beta) .Subscribe(beta => { Preferences.Default.Beta = beta; diff --git a/OpenUtau/Views/MainWindow.axaml.cs b/OpenUtau/Views/MainWindow.axaml.cs index 4dcb7e32b..48f790941 100644 --- a/OpenUtau/Views/MainWindow.axaml.cs +++ b/OpenUtau/Views/MainWindow.axaml.cs @@ -1262,21 +1262,18 @@ public void SetPianoRollAttachment() { return; } if (Preferences.Default.DetachPianoRoll) { - pianoRollWindow?.ForceClose(); - pianoRollWindow = null; - PianoRollContainer.Content = pianoRoll; - viewModel.ShowPianoRoll = true; - Preferences.Default.DetachPianoRoll = false; - } else { PianoRollContainer.Content = null; viewModel.ShowPianoRoll = false; if (pianoRollWindow == null) { pianoRollWindow = new(pianoRoll); pianoRollWindow.Show(); } - Preferences.Default.DetachPianoRoll = true; + } else { + pianoRollWindow?.ForceClose(); + pianoRollWindow = null; + PianoRollContainer.Content = pianoRoll; + viewModel.ShowPianoRoll = true; } - Preferences.Save(); } public void MainPagePointerWheelChanged(object sender, PointerWheelEventArgs args) { diff --git a/OpenUtau/Views/PreferencesDialog.axaml b/OpenUtau/Views/PreferencesDialog.axaml index 290323724..cd6eb05d7 100644 --- a/OpenUtau/Views/PreferencesDialog.axaml +++ b/OpenUtau/Views/PreferencesDialog.axaml @@ -265,6 +265,10 @@ + + + +