Skip to content

Commit

Permalink
Fixed white keys names positions.
Browse files Browse the repository at this point in the history
  • Loading branch information
akimaze committed Apr 21, 2020
1 parent 4de220f commit 101c0d2
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe )

// set font-size to 8
p.setFont( pointSize<8>( p.font() ) );
QFontMetrics fontMetrics(p.font());
int const fontHeight = fontMetrics.boundingRect(QChar::fromLatin1('H')).height();

// y_offset is used to align the piano-keys on the key-lines
int y_offset = 0;
Expand Down Expand Up @@ -2961,20 +2963,22 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
int yCorrectionForNoteLabels = 0;

int keyCode = key % KeysPerOctave;
switch( keyCode )
switch (keyCode)
{
case 0:
case 5:
yCorrectionForNoteLabels = -4;
case 0: // C
case 5: // F
yCorrectionForNoteLabels = (m_whiteKeySmallHeight - fontHeight + 1) / -2;
break;
case 2:
case 7:
case 9:
yCorrectionForNoteLabels = -2;
case 2: // D
case 7: // G
case 9: // A
yCorrectionForNoteLabels = (m_whiteKeyBigHeight / 2 - fontHeight + 1) / -2;
break;
case 4:
case 11:
yCorrectionForNoteLabels = 2;
case 4: // E
case 11: // B
// calculate center point of key and move half of text
yCorrectionForNoteLabels = -(((m_whiteKeySmallHeight - (m_whiteKeySmallHeight * 2 + 3) / 6) / 4)
- fontHeight / 2);
break;
}

Expand Down

0 comments on commit 101c0d2

Please sign in to comment.