From adea08d5b936030de47d8d74359ed667fadd610e Mon Sep 17 00:00:00 2001 From: Vesa Date: Wed, 28 May 2014 03:38:59 +0300 Subject: [PATCH] PianoRoll: Note Quick Resize Basically, this works as such: - if you click shift *after* starting a note move OR after creating a new note, the note move action is switched into resize mode, so you can quickly resize the note you just created, or the note you just moved. This saves time and improves workflow - at least based on my own experience: I've always wished I could do this, this is a huge time saving when you want to quickly jot down notes of differing lengths. - if shift is already pressed when you click, the above will not happen, because that would mess with the note copy function. Copying notes with shift-dragging works the same as before. - note test playback is halted when you click shift while moving. This is purely because it was causing some crackling noise, probably because of the changing length of a note that is currently playing. Maybe that can be fixed later, although it's arguably better not to hear the note while resizing - it's consistent with the other resize. - works on group of notes as well, if you start moving a group of notes and then click shift, it will go into resize. Exception is notes copied with shift-drag... for obvious reasons. - that should be all. Testing appreciated. --- include/PianoRoll.h | 3 +++ src/gui/PianoRoll.cpp | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 20b17e2b8..ea6758214 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -347,6 +347,9 @@ private: void computeSelectedNotes( bool shift ); void clearSelectedNotes(); + // did we start a mouseclick with shift pressed + bool m_startedWithShift; + friend class engine; diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index 563738987..a4f3847a5 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -1494,6 +1494,8 @@ inline int PianoRoll::keyAreaBottom() const void PianoRoll::mousePressEvent( QMouseEvent * _me ) { + m_startedWithShift = _me->modifiers() & Qt::ShiftModifier; + if( validPattern() == false ) { return; @@ -2238,7 +2240,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) bool replay_note = key_num != m_lastKey && m_action == ActionMoveNote; - if( replay_note ) + if( replay_note || ( m_action == ActionMoveNote && ( _me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) { pauseTestNotes(); } @@ -2250,7 +2252,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) _me->modifiers() & Qt::ShiftModifier ); - if( replay_note && m_action == ActionMoveNote ) + if( replay_note && m_action == ActionMoveNote && ! ( ( _me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) { pauseTestNotes( false ); } @@ -2679,7 +2681,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift ) } // make sure notes won't go outside boundary conditions - if( m_action == ActionMoveNote ) + if( m_action == ActionMoveNote && ! ( shift && ! m_startedWithShift ) ) { if( m_moveBoundaryLeft + off_ticks < 0 ) { @@ -2720,7 +2722,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift ) if( ( *it )->selected() ) { - if( m_action == ActionMoveNote ) + if( m_action == ActionMoveNote && ! ( shift && ! m_startedWithShift ) ) { // moving note int pos_ticks = ( *it )->oldPos().getTicks() @@ -2767,6 +2769,17 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift ) m_lenOfNewNotes = ( *it )->length(); } + else if( m_action == ActionMoveNote && ( shift && ! m_startedWithShift ) ) + { + // quick resize, toggled by holding shift after starting a note move, but not before + int ticks_new = ( *it )->oldLength().getTicks() + off_ticks; + if( ticks_new <= 0 ) + { + ticks_new = 1; + } + ( *it )->setLength( MidiTime( ticks_new ) ); + m_lenOfNewNotes = ( *it )->length(); + } } ++it; }