diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 42b812f7674..6d029a2c9a6 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -350,6 +350,7 @@ protected slots: bool m_mouseDownLeft; //true if left click is being held down bool m_mouseDownRight; //true if right click is being held down + bool m_mouseInPianoRoll; //true if mouse is the edit area TimeLineWidget * m_timeLine; bool m_scrollBack; @@ -359,6 +360,7 @@ protected slots: void drawDetuningInfo( QPainter & _p, const Note * _n, int _x, int _y ) const; bool mouseOverNote(); Note * noteUnderMouse(); + void setMousePointer(); // turn a selection rectangle into selected notes void computeSelectedNotes( bool shift ); @@ -381,6 +383,7 @@ protected slots: QColor m_markedSemitoneColor; int m_noteOpacity; bool m_noteBorders; + QPixmap * m_cursor; signals: void positionChanged( const MidiTime & ); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 24636a0c2c3..27db3914729 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -188,6 +188,7 @@ PianoRoll::PianoRoll() : m_editMode( ModeDraw ), m_mouseDownLeft( false ), m_mouseDownRight( false ), + m_mouseInPianoRoll( false ), m_scrollBack( false ), m_gridColor( 0, 0, 0 ), m_noteModeColor( 0, 0, 0 ), @@ -199,7 +200,8 @@ PianoRoll::PianoRoll() : m_textShadow( 0, 0, 0 ), m_markedSemitoneColor( 0, 0, 0 ), m_noteOpacity( 255 ), - m_noteBorders( true ) + m_noteBorders( true ), + m_cursor( NULL ) { // gui names of edit modes m_nemStr.push_back( tr( "Note Velocity" ) ); @@ -1257,6 +1259,9 @@ void PianoRoll::leaveEvent(QEvent * e ) QApplication::restoreOverrideCursor(); } + m_mouseDownRight = false; + m_mouseInPianoRoll = false; + update(); QWidget::leaveEvent( e ); s_textFloat->hide(); } @@ -1577,8 +1582,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) m_action = ActionMoveNote; // set move-cursor - QCursor c( Qt::SizeAllCursor ); - QApplication::setOverrideCursor( c ); +// QCursor c( Qt::SizeAllCursor ); +// QApplication::setOverrideCursor( c ); // if they're holding shift, copy all selected notes if( ! is_new_note && me->modifiers() & Qt::ShiftModifier ) @@ -1974,29 +1979,42 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) void PianoRoll::mouseMoveEvent( QMouseEvent * me ) { - if( ! hasValidPattern() ) + if( !hasValidPattern() ) { update(); return; } + if( me->x() > WHITE_KEY_WIDTH + && me->x() < width() - PR_RIGHT_MARGIN - 2 + && me->y() < height() - PR_BOTTOM_MARGIN - m_notesEditHeight ) + { + m_mouseInPianoRoll = true; + } + else + { + m_mouseInPianoRoll = false; + } + + setMousePointer(); + if( m_action == ActionNone && me->buttons() == 0 ) { if( me->y() > keyAreaBottom() && me->y() < noteEditTop() ) { - QApplication::setOverrideCursor( - QCursor( Qt::SizeVerCursor ) ); + setCursor( Qt::SizeVerCursor ); return; } } else if( m_action == ActionResizeNoteEditArea ) { // change m_notesEditHeight and then repaint + setCursor( Qt::SizeVerCursor ); m_notesEditHeight = tLimit( m_oldNotesEditHeight - ( me->y() - m_moveStartY ), NOTE_EDIT_MIN_HEIGHT, height() - PR_TOP_MARGIN - NOTE_EDIT_RESIZE_BAR - - PR_BOTTOM_MARGIN - KEY_AREA_MIN_HEIGHT ); + PR_BOTTOM_MARGIN - KEY_AREA_MIN_HEIGHT ); repaint(); return; } @@ -3080,32 +3098,40 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) p.fillRect( QRect( 0, keyAreaBottom(), width()-PR_RIGHT_MARGIN, NOTE_EDIT_RESIZE_BAR ), horizCol ); - const QPixmap * cursor = NULL; + m_cursor = NULL; // draw current edit-mode-icon below the cursor switch( m_editMode ) { - case ModeDraw: - if( m_mouseDownRight ) - { - cursor = s_toolErase; - } - else if( m_action == ActionMoveNote ) - { - cursor = s_toolMove; - } - else - { - cursor = s_toolDraw; - } - break; - case ModeErase: cursor = s_toolErase; break; - case ModeSelect: cursor = s_toolSelect; break; - case ModeEditDetuning: cursor = s_toolOpen; break; - } - if( cursor != NULL ) - { - p.drawPixmap( mapFromGlobal( QCursor::pos() ) + QPoint( 8, 8 ), - *cursor ); + case ModeDraw: + if( m_mouseDownRight ) + { + m_cursor = s_toolErase; + } + else if( m_action == ActionMoveNote ) + { + m_cursor = s_toolMove; + } + else + { + m_cursor = s_toolDraw; + } + setMousePointer(); + break; + case ModeErase: m_cursor = s_toolErase; break; + case ModeSelect: + m_cursor = NULL; + if( m_mouseInPianoRoll ) + { + p.drawPixmap( mapFromGlobal( QCursor::pos() ) + QPoint( 13, 13 ), *s_toolSelect ); + } + break; + case ModeEditDetuning: + m_cursor = NULL; + if( m_mouseInPianoRoll ) + { + p.drawPixmap( mapFromGlobal( QCursor::pos() ) + QPoint( 13, 13 ), *s_toolOpen ); + } + break; } } @@ -3993,6 +4019,21 @@ Note * PianoRoll::noteUnderMouse() +void PianoRoll::setMousePointer() +{ + if( m_cursor && m_mouseInPianoRoll ) + { + setCursor( QCursor( *m_cursor, 0, m_cursor->height() ) ); + } + else + { + setCursor( Qt::ArrowCursor ); + } +} + + + + PianoRollWindow::PianoRollWindow() : Editor(true), m_editor(new PianoRoll())