Skip to content
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
19 changes: 10 additions & 9 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3099,6 +3099,12 @@ void PianoRoll::paintEvent(QPaintEvent * pe )

QPolygonF editHandles;

// Return a note's Y position on the grid
auto noteYPos = [&](const int key)
{
return (topKey - key) * m_keyLineHeight + keyAreaTop() - 1;
};

// -- Begin ghost pattern
if( !m_ghostNotes.empty() )
{
Expand All @@ -3114,7 +3120,6 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
{
len_ticks = 4;
}
const int key = note->key() - m_startKey + 1;

int pos_ticks = note->pos();

Expand All @@ -3133,7 +3138,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )

// we've done and checked all, let's draw the note
drawNoteRect(
p, x + m_whiteKeyWidth, y_base - key * m_keyLineHeight, note_width,
p, x + m_whiteKeyWidth, noteYPos(note->key()), note_width,
note, m_ghostNoteColor, m_ghostNoteTextColor, m_selectedNoteColor,
m_ghostNoteOpacity, m_ghostNoteBorders, drawNoteNames);
}
Expand All @@ -3155,8 +3160,6 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
len_ticks = 4;
}

const int key = note->key() - m_startKey + 1;

int pos_ticks = note->pos();

int note_width = len_ticks * m_ppb / TimePos::ticksPerBar();
Expand All @@ -3171,10 +3174,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// is the note in visible area?
if (note->key() > bottomKey && note->key() <= topKey)
{

// we've done and checked all, let's draw the note
drawNoteRect(
p, x + m_whiteKeyWidth, y_base - key * m_keyLineHeight, note_width,
p, x + m_whiteKeyWidth, noteYPos(note->key()), note_width,
note, m_noteColor, m_noteTextColor, m_selectedNoteColor,
m_noteOpacity, m_noteBorders, drawNoteNames);
}
Expand Down Expand Up @@ -3223,7 +3225,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )

if( note->hasDetuningInfo() )
{
drawDetuningInfo(p, note, x + m_whiteKeyWidth, y_base - key * m_keyLineHeight);
drawDetuningInfo(p, note, x + m_whiteKeyWidth, noteYPos(note->key()));
p.setClipRect(
m_whiteKeyWidth,
PR_TOP_MARGIN,
Expand All @@ -3242,7 +3244,6 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
continue;
}

const int key = note->key() - m_startKey + 1;

int pos_ticks = note->pos();

Expand All @@ -3261,7 +3262,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )

// we've done and checked all, let's draw the note
drawNoteRect(
p, x + m_whiteKeyWidth, y_base - key * m_keyLineHeight, note_width,
p, x + m_whiteKeyWidth, noteYPos(note->key()), note_width,
note, m_stepRecorder.curStepNoteColor(), m_noteTextColor, m_selectedNoteColor,
m_noteOpacity, m_noteBorders, drawNoteNames);
}
Expand Down