From 4bcae1a7cdec8ca851f06df52ee3092005d822cd Mon Sep 17 00:00:00 2001 From: Veratil Date: Fri, 26 Mar 2021 02:11:08 -0500 Subject: [PATCH] Fix PianoRoll m_positionLine misalignment on zoom --- src/gui/editors/PianoRoll.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index d758adf55..32df7d75a 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -4443,11 +4443,16 @@ void PianoRoll::updatePosition( const TimePos & t ) { autoScroll( t ); } - const int pos = m_timeLine->pos() * m_ppb / TimePos::ticksPerBar(); - if (pos >= m_currentPosition && pos <= m_currentPosition + width() - m_whiteKeyWidth) + // ticks relative to m_currentPosition + // < 0 = outside viewport left + // > width = outside viewport right + const int pos = (static_cast(m_timeLine->pos()) - m_currentPosition) * m_ppb / TimePos::ticksPerBar(); + // if pos is within visible range, show it + if (pos >= 0 && pos <= width() - m_whiteKeyWidth) { m_positionLine->show(); - m_positionLine->move(pos - (m_positionLine->width() - 1) - m_currentPosition + m_whiteKeyWidth, keyAreaTop()); + // adjust pos for piano keys width and self line width (align to rightmost of line) + m_positionLine->move(pos + m_whiteKeyWidth - (m_positionLine->width() - 1), keyAreaTop()); } else {