Skip to content

Commit

Permalink
Better note text height calculation (proposed by PhysSong).
Browse files Browse the repository at this point in the history
  • Loading branch information
akimaze committed Apr 20, 2020
1 parent c1ddc58 commit 4de220f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,12 @@ void PianoRoll::drawNoteRect( QPainter & p, int x, int y,

int const distanceToBorder = 2;
int const xOffset = borderWidth + distanceToBorder;
int const yOffset = ((noteHeight + fontMetrics.capHeight()) + 1) / 2;

// noteTextHeight, textSize are not suitable for determining vertical spacing,
// capHeight() can be used for this, but requires Qt 5.8.
// We use boundingRect() with QChar (the QString version returns wrong value).
QRect const boundingRect = fontMetrics.boundingRect(QChar::fromLatin1('H'));
int const yOffset = (noteHeight - boundingRect.top() - boundingRect.bottom()) / 2;

if (textSize.width() < noteWidth - xOffset)
{
Expand Down

0 comments on commit 4de220f

Please sign in to comment.