diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index e2c58f28681..7f2e549a3fa 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1233,18 +1233,20 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) } } - // alternating shades for better contrast - // count the bars which disappear on left by scrolling + // alternating shades for better contrast + float timeSignature = static_cast( Engine::getSong()->getTimeSigModel().getNumerator() ) + / static_cast( Engine::getSong()->getTimeSigModel().getDenominator() ); float zoomFactor = m_zoomXLevels[m_zoomingXModel.value()]; - int barCount = m_currentPosition / MidiTime::ticksPerTact(); - int leftBars = m_currentPosition * zoomFactor / m_ppt; + //the bars which disappears at the left side by scrolling + int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerTact(); - for( int x = VALUES_WIDTH; x < width() + m_currentPosition * zoomFactor; x += m_ppt, ++barCount ) + //iterates the visible bars and draw the shading on uneven bars + for( int x = VALUES_WIDTH, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; x += m_ppt, ++barCount ) { if( ( barCount + leftBars ) % 2 != 0 ) { - p.fillRect( x - m_currentPosition * zoomFactor, TOP_MARGIN, m_ppt, + p.fillRect( x - m_currentPosition * zoomFactor / timeSignature, 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 ced4e58a69a..0030825940e 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -2887,18 +2887,20 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) ++key; } - // Draw alternating shades on bars - // count the bars which disappear on left by scrolling + // Draw alternating shades on bars + float timeSignature = static_cast( Engine::getSong()->getTimeSigModel().getNumerator() ) + / static_cast( Engine::getSong()->getTimeSigModel().getDenominator() ); float zoomFactor = m_zoomLevels[m_zoomingModel.value()]; - int barCount = m_currentPosition / MidiTime::ticksPerTact(); - int leftBars = m_currentPosition * zoomFactor / m_ppt; + //the bars which disappears at the left side by scrolling + int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerTact(); - for( int x = WHITE_KEY_WIDTH; x < width() + m_currentPosition * zoomFactor; x += m_ppt, ++barCount ) + //iterates the visible bars and draw the shading on uneven bars + for( int x = WHITE_KEY_WIDTH, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; x += m_ppt, ++barCount ) { if( ( barCount + leftBars ) % 2 != 0 ) { - p.fillRect( x - m_currentPosition * zoomFactor, PR_TOP_MARGIN, m_ppt, + p.fillRect( x - m_currentPosition * zoomFactor / timeSignature, PR_TOP_MARGIN, m_ppt, height() - ( PR_BOTTOM_MARGIN + PR_TOP_MARGIN ), backgroundShade() ); } }