Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4098 #5449

Merged
merged 3 commits into from
May 7, 2020
Merged
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
32 changes: 19 additions & 13 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2662,7 +2662,12 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
break;
}
// start drawing at the bottom
int key_line_y = keyAreaBottom() - 1;
int key_line_y = qMin(keyAreaBottom() - 1, KEY_LINE_HEIGHT * NumKeys);
// we need to set m_notesEditHeight here because it needs to fill in the
// rest of the window if key_line_y is bound to KEY_LINE_HEIGHT * NumKeys
if (key_line_y == KEY_LINE_HEIGHT * NumKeys) {
m_notesEditHeight = height() - (PR_TOP_MARGIN + KEY_LINE_HEIGHT * NumKeys);
}
// used for aligning black-keys later
int first_white_key_height = WHITE_KEY_SMALL_HEIGHT;
// key-counter - only needed for finding out whether the processed
Expand Down Expand Up @@ -2782,9 +2787,10 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
key = m_startKey;
keys_processed = 0;
int white_cnt = 0;
key_line_y = qMin(keyAreaBottom(), KEY_LINE_HEIGHT * NumKeys);

// and go!
for( int y = keyAreaBottom() + y_offset;
for( int y = key_line_y + y_offset;
y > PR_TOP_MARGIN; ++keys_processed )
{
// check for black key that is only half visible on the bottom
Expand Down Expand Up @@ -2850,16 +2856,16 @@ void PianoRoll::paintEvent(QPaintEvent * pe )

// erase the area below the piano, because there might be keys that
// should be only half-visible
p.fillRect( QRect( 0, keyAreaBottom(),
WHITE_KEY_WIDTH, noteEditBottom() - keyAreaBottom() ), bgColor );
p.fillRect( QRect( 0, key_line_y,
WHITE_KEY_WIDTH, noteEditBottom() - key_line_y ), bgColor );

// display note editing info
QFont f = p.font();
f.setBold( false );
p.setFont( pointSize<10>( f ) );
p.setPen( noteModeColor() );
p.drawText( QRect( 0, keyAreaBottom(),
WHITE_KEY_WIDTH, noteEditBottom() - keyAreaBottom() ),
p.drawText( QRect( 0, key_line_y,
WHITE_KEY_WIDTH, noteEditBottom() - key_line_y ),
Qt::AlignCenter | Qt::TextWordWrap,
m_nemStr.at( m_noteEditMode ) + ":" );

Expand Down Expand Up @@ -2900,7 +2906,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )

// Draw horizontal lines
key = m_startKey;
for( int y = keyAreaBottom() - 1; y > PR_TOP_MARGIN;
for( int y = key_line_y - 1; y > PR_TOP_MARGIN;
y -= KEY_LINE_HEIGHT )
{
if( static_cast<Keys>( key % KeysPerOctave ) == Key_C )
Expand Down Expand Up @@ -2959,10 +2965,10 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
for( int i = 0; i < m_markedSemiTones.size(); i++ )
{
const int key_num = m_markedSemiTones.at( i );
const int y = keyAreaBottom() + 5
const int y = key_line_y + 5
- KEY_LINE_HEIGHT * ( key_num - m_startKey + 1 );

if( y > keyAreaBottom() )
if( y > key_line_y )
{
break;
}
Expand Down Expand Up @@ -2990,14 +2996,14 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
qSwap<int>( sel_key_start, sel_key_end );
}

int y_base = keyAreaBottom() - 1;
int y_base = key_line_y - 1;
if( hasValidPattern() )
{
p.setClipRect( WHITE_KEY_WIDTH, PR_TOP_MARGIN,
width() - WHITE_KEY_WIDTH,
height() - PR_TOP_MARGIN );

const int visible_keys = ( keyAreaBottom()-keyAreaTop() ) /
const int visible_keys = ( key_line_y-keyAreaTop() ) /
KEY_LINE_HEIGHT + 2;

QPolygonF editHandles;
Expand Down Expand Up @@ -3146,13 +3152,13 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
if( hasValidPattern() )
{
int key_num = getKey( mapFromGlobal( QCursor::pos() ).y() );
p.fillRect( 10, keyAreaBottom() + 3 - KEY_LINE_HEIGHT *
p.fillRect( 10, key_line_y + 3 - KEY_LINE_HEIGHT *
( key_num - m_startKey + 1 ), width() - 10, KEY_LINE_HEIGHT - 7, currentKeyCol );
}

// bar to resize note edit area
p.setClipRect( 0, 0, width(), height() );
p.fillRect( QRect( 0, keyAreaBottom(),
p.fillRect( QRect( 0, key_line_y,
width()-PR_RIGHT_MARGIN, NOTE_EDIT_RESIZE_BAR ), editAreaCol );

const QPixmap * cursor = NULL;
Expand Down