Skip to content

Commit

Permalink
fix alternate shading for changing time signature (#3559)
Browse files Browse the repository at this point in the history
* fix alternate shading for changing time signature

* fix alternade shading for automation editor on changing time signature

* code cleanup
  • Loading branch information
BaraMGB authored May 17, 2017
1 parent c0b910e commit 6970c88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>( Engine::getSong()->getTimeSigModel().getNumerator() )
/ static_cast<float>( 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() );
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>( Engine::getSong()->getTimeSigModel().getNumerator() )
/ static_cast<float>( 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() );
}
}
Expand Down

0 comments on commit 6970c88

Please sign in to comment.