From 9e3956af89f8e53e09e55a6d52b2058de534cf6e Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Sat, 23 May 2020 18:05:32 +0200 Subject: [PATCH 1/4] Compensate beat note length when stretching We allow stretching beat notes to normal notes but the length starts from -192 so there is a lag for one whole note before any change is seen. Compensate by setting the oldNote value to 1 when stretching if the note is 0 or below in length. --- src/gui/editors/PianoRoll.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 807696775a0..5c58f9a6628 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -2609,6 +2609,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) { if (note->selected()) { + if (note->oldLength() <= 0){note->setOldLength(1);} int newLength = note->oldLength() + off_ticks; newLength = qMax(1, newLength); note->setLength( MidiTime(newLength) ); From 0ff31c06e0c568ded797c5fc20faf6e6e2c4fbbb Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Sun, 24 May 2020 15:01:47 +0200 Subject: [PATCH 2/4] Set old length to beat note length Co-authored-by: Spekular --- src/gui/editors/PianoRoll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 5c58f9a6628..3c26f234af3 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -2609,7 +2609,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) { if (note->selected()) { - if (note->oldLength() <= 0){note->setOldLength(1);} + if (note->oldLength() <= 0){note->setOldLength(4);} int newLength = note->oldLength() + off_ticks; newLength = qMax(1, newLength); note->setLength( MidiTime(newLength) ); From 3cbd313f15758f606b9ef57434c3782f0dea413e Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Sun, 24 May 2020 18:45:47 +0200 Subject: [PATCH 3/4] Fix 'shift + stretch' --- src/gui/editors/PianoRoll.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 3c26f234af3..570a0322aad 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -2521,6 +2521,13 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) if (shift) { + for (Note *note : notes) + { + if (note->selected()) + { + if (note->oldLength() <= 0){note->setOldLength(4);} + } + } // Algorithm: // Relative to the starting point of the left-most selected note, // all selected note start-points and *endpoints* (not length) should be scaled by a calculated factor. From 66ae08aff12613d0631fa64c2f777d1b7c28cc2a Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Sun, 24 May 2020 19:08:08 +0200 Subject: [PATCH 4/4] Move changes to mousePressEvent --- src/gui/editors/PianoRoll.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 570a0322aad..3c88b4c43d9 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -1606,6 +1606,11 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) // then resize the note m_action = ActionResizeNote; + for (Note *note : getSelectedNotes()) + { + if (note->oldLength() <= 0) { note->setOldLength(4); } + } + // set resize-cursor QCursor c( Qt::SizeHorCursor ); QApplication::setOverrideCursor( c ); @@ -2521,13 +2526,6 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) if (shift) { - for (Note *note : notes) - { - if (note->selected()) - { - if (note->oldLength() <= 0){note->setOldLength(4);} - } - } // Algorithm: // Relative to the starting point of the left-most selected note, // all selected note start-points and *endpoints* (not length) should be scaled by a calculated factor. @@ -2616,7 +2614,6 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) { if (note->selected()) { - if (note->oldLength() <= 0){note->setOldLength(4);} int newLength = note->oldLength() + off_ticks; newLength = qMax(1, newLength); note->setLength( MidiTime(newLength) );