Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ protected slots:
volume_t m_lastNoteVolume;
panning_t m_lastNotePanning;

//When resizing several notes, we want to calculate a common minimum length
MidiTime m_minResizeLen;

int m_startKey; // first key when drawing
int m_lastKey;

Expand Down
24 changes: 19 additions & 5 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ PianoRoll::PianoRoll() :
m_lenOfNewNotes( MidiTime( 0, DefaultTicksPerBar/4 ) ),
m_lastNoteVolume( DefaultVolume ),
m_lastNotePanning( DefaultPanning ),
m_minResizeLen( 0 ),
m_startKey( INITIAL_START_KEY ),
m_lastKey( 0 ),
m_editMode( ModeDraw ),
Expand Down Expand Up @@ -1727,9 +1728,21 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
// then resize the note
m_action = ActionResizeNote;

//Calculate the minimum length we should allow when resizing
//each note, and let all notes use the smallest one found
m_minResizeLen = quantization();
for (Note *note : selectedNotes)
{
if (note->oldLength() <= 0) { note->setOldLength(4); }
//Notes from the BB editor can have a negative length, so
//change their length to the displayed one before resizing
if (note->oldLength() <= 0) { note->setOldLength(4); }
//Let the note be sized down by quantized increments, stopping
//when the next step down would result in a negative length
int thisMin = note->oldLength() % quantization();
//The initial value for m_minResizeLen is the minimum length of
//a note divisible by the current Q. Therefore we ignore notes
//where thisMin == 0 when checking for a new minimum
if (thisMin > 0 && thisMin < m_minResizeLen) { m_minResizeLen = thisMin; }
}

// set resize-cursor
Expand Down Expand Up @@ -2664,7 +2677,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
// If shift is pressed we resize and rearrange only the selected notes
// If shift + ctrl then we also rearrange all posterior notes (sticky)
// If shift is pressed but only one note is selected, apply sticky

auto selectedNotes = getSelectedNotes();

if (shift)
Expand Down Expand Up @@ -2750,11 +2763,12 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
else
{
// shift is not pressed; stretch length of selected notes but not their position
int minLength = alt ? 1 : m_minResizeLen.getTicks();

for (Note *note : selectedNotes)
{
int newLength = note->oldLength() + off_ticks;
newLength = qMax(1, newLength);
note->setLength( MidiTime(newLength) );
int newLength = qMax(minLength, note->oldLength() + off_ticks);
note->setLength(MidiTime(newLength));

m_lenOfNewNotes = note->length();
}
Expand Down