Skip to content

Commit

Permalink
Merge pull request #1197 from oxygen-dioxide/splitnote
Browse files Browse the repository at this point in the history
Fix very long note produced by knife tool
  • Loading branch information
stakira authored Jul 22, 2024
2 parents 93a3953 + 7dd766e commit 3b943c9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions OpenUtau/Views/NoteEditStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,20 @@ public NoteSplitEditState(
public override void Begin(IPointer pointer, Point point) {
var notesVm = vm.NotesViewModel;
base.Begin(pointer, point);
var project = DocManager.Inst.Project;
var part = notesVm.Part;
if (project == null || part == null || note == null) {
return;
}
int snapUnit = project.resolution * 4 / notesVm.SnapDiv;
if (note.duration <= snapUnit) {
return;
}
newNote = notesVm.MaybeAddNote(point, false);
if (part == null || newNote == null) {
if (newNote == null) {
return;
}

DocManager.Inst.ExecuteCmd(new ChangeNoteLyricCommand(part, newNote, "+"));
}

Expand All @@ -426,7 +435,13 @@ public override void Update(IPointer pointer, Point point) {
if (notesVm.IsSnapOn && snapUnit > 0) {
maxNegDelta = (int)Math.Floor((double)maxNegDelta / snapUnit) * snapUnit;
}
deltaDuration = Math.Max(deltaDuration, -maxNegDelta);

int maxNoteTicks = (notesVm.IsSnapOn && snapUnit > 0)
? (oldDur-1) / snapUnit * snapUnit
: oldDur - 15;
int maxDelta = maxNoteTicks - note.duration;

deltaDuration = Math.Clamp(deltaDuration, -maxNegDelta, maxDelta);

if (deltaDuration == 0) {
valueTip.UpdateValueTip(note.duration.ToString());
Expand Down

0 comments on commit 3b943c9

Please sign in to comment.