From fd74ddfe155edbf35a0ebc44de4e5e36e8e7cd84 Mon Sep 17 00:00:00 2001 From: Steffen Baranowsky Date: Wed, 1 Mar 2017 17:31:00 +0100 Subject: [PATCH] fix alternate shading of pianoroll and automation editor on zooming (#3391) * fixes alternate shading in piano roll on zooming * fixes alternate shading in automation editor on zooming --- src/gui/editors/AutomationEditor.cpp | 10 ++++++---- src/gui/editors/PianoRoll.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 09bdf012c..fd42090d8 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1199,14 +1199,16 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // alternating shades for better contrast // count the bars which disappear on left by scrolling - int barCount = m_currentPosition / MidiTime::ticksPerTact(); - int leftBars = m_currentPosition / m_ppt; - for( int x = VALUES_WIDTH; x < width() + m_currentPosition; x += m_ppt, ++barCount ) + float zoomFactor = m_zoomXLevels[m_zoomingXModel.value()]; + int barCount = m_currentPosition / MidiTime::ticksPerTact(); + int leftBars = m_currentPosition * zoomFactor / m_ppt; + + for( int x = VALUES_WIDTH; x < width() + m_currentPosition * zoomFactor; x += m_ppt, ++barCount ) { if( ( barCount + leftBars ) % 2 != 0 ) { - p.fillRect( x - m_currentPosition, TOP_MARGIN, m_ppt, + p.fillRect( x - m_currentPosition * zoomFactor, TOP_MARGIN, m_ppt, height() - ( SCROLLBAR_SIZE + TOP_MARGIN ), backgroundShade() ); } } diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index a5e54789f..d0efefab9 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -2907,14 +2907,16 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // Draw alternating shades on bars // count the bars which disappear on left by scrolling - int barCount = m_currentPosition / MidiTime::ticksPerTact(); - int leftBars = m_currentPosition / m_ppt; - for( int x = WHITE_KEY_WIDTH; x < width() + m_currentPosition; x += m_ppt, ++barCount ) + float zoomFactor = m_zoomLevels[m_zoomingModel.value()]; + int barCount = m_currentPosition / MidiTime::ticksPerTact(); + int leftBars = m_currentPosition * zoomFactor / m_ppt; + + for( int x = WHITE_KEY_WIDTH; x < width() + m_currentPosition * zoomFactor; x += m_ppt, ++barCount ) { if( ( barCount + leftBars ) % 2 != 0 ) { - p.fillRect( x - m_currentPosition, PR_TOP_MARGIN, m_ppt, + p.fillRect( x - m_currentPosition * zoomFactor, PR_TOP_MARGIN, m_ppt, height() - ( PR_BOTTOM_MARGIN + PR_TOP_MARGIN ), backgroundShade() ); } }