Piano roll: fix scale marking algorithm and improve rendering

A patch to fix the scale marking algorithm and possibly improve on the
looks

Closes #3493928.
This commit is contained in:
Raine M. Ekman
2012-05-20 18:50:06 +02:00
committed by Tobias Doerffel
parent 12221d221f
commit 02db2fbd2f

View File

@@ -671,7 +671,8 @@ void pianoRoll::markSemiTone( int i )
for( int i = first; i <= last; i++ )
{
if( chord->hasSemiTone( std::abs( key - i ) % cap ) )
//if( chord->hasSemiTone( std::abs( key - i ) % cap ) )
if( chord->hasSemiTone( ( i + cap - ( key % cap ) ) % cap ) )
{
m_markedSemiTones.push_back( i );
}
@@ -2667,6 +2668,24 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
int key = m_startKey;
// display note marks before drawing other lines
for( int i = 0; i < m_markedSemiTones.size(); i++ )
{
const int key_num = m_markedSemiTones.at( i );
const int y = keyAreaBottom() + 5
- KEY_LINE_HEIGHT * ( key_num - m_startKey + 1 );
if( y > keyAreaBottom() )
{
break;
}
p.fillRect( WHITE_KEY_WIDTH+1, y-KEY_LINE_HEIGHT/2,
width() - 10, KEY_LINE_HEIGHT,
QColor( 0, 80 - ( key_num % KeysPerOctave ) * 3, 64 + key_num / 2) );
}
// draw all white keys...
for( int y = key_line_y + 1 + y_offset; y > PR_TOP_MARGIN;
key_line_y -= KEY_LINE_HEIGHT, ++keys_processed )
@@ -2795,22 +2814,6 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
++key;
}
// display note marks
for( int i = 0; i < m_markedSemiTones.size(); i++ )
{
const int key_num = m_markedSemiTones.at( i );
const int y = keyAreaBottom() + 5
- KEY_LINE_HEIGHT * ( key_num - m_startKey + 1 );
if( y > keyAreaBottom() )
{
break;
}
p.fillRect( WHITE_KEY_WIDTH, y,
width() - 10, 1,
QColor( 64, 64 + ( key_num % KeysPerOctave ) * 7, 96 + key_num ) );
}
// erase the area below the piano, because there might be keys that
// should be only half-visible