Skip to content

Commit

Permalink
Merge pull request #1223 from oxygen-dioxide/reset-all
Browse files Browse the repository at this point in the history
Add a 'reset all' editing macro
  • Loading branch information
stakira authored Aug 3, 2024
2 parents a5b4d3e + 2e01dba commit 693302d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
45 changes: 45 additions & 0 deletions OpenUtau.Core/Editing/ResetBatchEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,49 @@ public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, Do
docManager.EndUndoGroup();
}
}

public class ResetAll : BatchEdit {
public virtual string Name => name;

private string name;

public ResetAll() {
name = "pianoroll.menu.notes.reset.all";
}

public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, DocManager docManager) {
var notes = selectedNotes.Count > 0 ? selectedNotes : part.notes.ToList();
docManager.StartUndoGroup(true);
foreach (var note in notes) {
// pitch points
docManager.ExecuteCmd(new ResetPitchPointsCommand(part, note));
// expressions
if (note.phonemeExpressions.Count > 0) {
docManager.ExecuteCmd(new ResetExpressionsCommand(part, note));
}
// vibrato
if (note.vibrato.length > 0) {
docManager.ExecuteCmd(new VibratoLengthCommand(part, note, 0));
}
// timings
bool shouldClear = false;
foreach (var o in note.phonemeOverrides) {
if (o.offset != null || o.preutterDelta != null || o.overlapDelta != null) {
shouldClear = true;
break;
}
}
if (shouldClear) {
docManager.ExecuteCmd(new ClearPhonemeTimingCommand(part, note));
}
// aliases
foreach (var o in note.phonemeOverrides) {
if (o.phoneme != null) {
docManager.ExecuteCmd(new ChangePhonemeAliasCommand(part, note, o.index, null));
}
}
}
docManager.EndUndoGroup();
}
}
}
1 change: 1 addition & 0 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ Warning: this option removes custom presets.</system:String>
<system:String x:Key="pianoroll.menu.notes.removetaildash">Remove tail "-"</system:String>
<system:String x:Key="pianoroll.menu.notes.removetailrest">Remove tail "R"</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.aliases">Reset phoneme aliases</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.all">Reset notes to default</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.allparameters">Reset all parameters</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.exps">Reset all expressions</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.phonemetimings">Reset phoneme timings</system:String>
Expand Down
1 change: 1 addition & 0 deletions OpenUtau/Views/PianoRollWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ await MessageBox.ShowProcessing(this, $"{name} - ? / ?",
new ResetVibratos(),
new ClearTimings(),
new ResetAliases(),
new ResetAll(),
}.Select(edit => new MenuItemViewModel() {
Header = ThemeManager.GetString(edit.Name),
Command = noteBatchEditCommand,
Expand Down

0 comments on commit 693302d

Please sign in to comment.