Merge pull request #1716 from badosu/change-resizing-notes-on-piano-roll

Change Shift+Resize selected notes on Piano Roll
This commit is contained in:
Tres Finocchiaro
2015-01-28 22:11:05 -05:00
2 changed files with 25 additions and 16 deletions

View File

@@ -231,7 +231,7 @@ private:
inline int noteEditRight() const;
inline int noteEditLeft() const;
void dragNotes( int x, int y, bool alt, bool shift );
void dragNotes( int x, int y, bool alt, bool shift, bool ctrl );
static const int cm_scrollAmtHoriz = 10;
static const int cm_scrollAmtVert = 1;

View File

@@ -949,7 +949,8 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
{
dragNotes( m_lastMouseX, m_lastMouseY,
ke->modifiers() & Qt::AltModifier,
ke->modifiers() & Qt::ShiftModifier );
ke->modifiers() & Qt::ShiftModifier,
ke->modifiers() & Qt::ControlModifier );
}
}
ke->accept();
@@ -981,7 +982,8 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
{
dragNotes( m_lastMouseX, m_lastMouseY,
ke->modifiers() & Qt::AltModifier,
ke->modifiers() & Qt::ShiftModifier );
ke->modifiers() & Qt::ShiftModifier,
ke->modifiers() & Qt::ControlModifier );
}
}
ke->accept();
@@ -1022,7 +1024,8 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
{
dragNotes( m_lastMouseX, m_lastMouseY,
ke->modifiers() & Qt::AltModifier,
ke->modifiers() & Qt::ShiftModifier );
ke->modifiers() & Qt::ShiftModifier,
ke->modifiers() & Qt::ControlModifier );
}
}
@@ -1063,7 +1066,8 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
{
dragNotes( m_lastMouseX, m_lastMouseY,
ke->modifiers() & Qt::AltModifier,
ke->modifiers() & Qt::ShiftModifier );
ke->modifiers() & Qt::ShiftModifier,
ke->modifiers() & Qt::ControlModifier );
}
}
@@ -1120,7 +1124,11 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
}
case Qt::Key_Control:
if ( isActiveWindow() )
// Enter selection mode if:
// -> this window is active
// -> shift is not pressed
// (<S-C-drag> is shortcut for sticky note resize)
if ( !( ke->modifiers() & Qt::ShiftModifier ) && isActiveWindow() )
{
m_ctrlMode = m_editMode;
m_editMode = ModeSelect;
@@ -1265,7 +1273,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
return;
}
// if holding control, go to selection mode
// if holding control, go to selection mode unless shift is also pressed
if( me->modifiers() & Qt::ControlModifier && m_editMode != ModeSelect )
{
m_ctrlMode = m_editMode;
@@ -1991,12 +1999,10 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
pauseTestNotes();
}
dragNotes(
me->x(),
me->y(),
dragNotes( me->x(), me->y(),
me->modifiers() & Qt::AltModifier,
me->modifiers() & Qt::ShiftModifier
);
me->modifiers() & Qt::ShiftModifier,
me->modifiers() & Qt::ControlModifier );
if( replay_note && m_action == ActionMoveNote && ! ( ( me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) )
{
@@ -2408,7 +2414,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
void PianoRoll::dragNotes( int x, int y, bool alt, bool shift )
void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
{
// dragging one or more notes around
@@ -2458,9 +2464,12 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift )
{
Note *note = *it;
const int pos = note->pos().getTicks();
// when resizing a note and holding shift: shift the following
// notes to preserve the melody
if( m_action == ActionResizeNote && shift )
// When resizing notes:
// If shift is pressed we resize and rearrange only the selected notes
// If shift + ctrl then we also rearrange all posterior notes (sticky)
if( m_action == ActionResizeNote && shift &&
( note->selected() || ctrl ) )
{
int shifted_pos = note->oldPos().getTicks() + shift_offset;
if( shifted_pos && pos == shift_ref_pos )