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
This commit is contained in:
Steffen Baranowsky
2017-03-01 17:31:00 +01:00
committed by Umcaruje
parent 06e4033cb9
commit fd74ddfe15
2 changed files with 12 additions and 8 deletions

View File

@@ -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() );
}
}

View File

@@ -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() );
}
}