From 48b9b6508e684fbadd53e0ffb7e293f70260e6ea Mon Sep 17 00:00:00 2001 From: Hyunjin Song Date: Thu, 9 Nov 2017 06:58:51 +0900 Subject: [PATCH] Fix visual glitch with automation patterns (#3945) Fix off-by-one visual glitch in automation editor and automation pattern view --- src/gui/AutomationPatternView.cpp | 12 +++++++++++- src/gui/editors/AutomationEditor.cpp | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 68bdb4bf2..448c233cb 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -319,6 +319,16 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) float *values = m_pat->valuesAfter( it.key() ); + float nextValue; + if( m_pat->progressionType() == AutomationPattern::DiscreteProgression ) + { + nextValue = it.value(); + } + else + { + nextValue = ( it + 1 ).value(); + } + QPainterPath path; QPointF origin = QPointF( x_base + it.key() * ppTick, 0.0f ); path.moveTo( origin ); @@ -332,7 +342,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) path.lineTo( QPointF( x, value ) ); } - path.lineTo( x_base + ( ( it + 1 ).key() ) * ppTick, values[ ( it + 1 ).key() - 1 - it.key() ] ); + path.lineTo( x_base + ( ( it + 1 ).key() ) * ppTick, nextValue ); path.lineTo( x_base + ( ( it + 1 ).key() ) * ppTick, 0.0f ); path.lineTo( origin ); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index ca65b5275..965314087 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1378,13 +1378,13 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) float *values = m_pattern->valuesAfter( it.key() ); float nextValue; - if ( m_pattern->valuesAfter( ( it + 1 ).key() ) != NULL ) + if( m_pattern->progressionType() == AutomationPattern::DiscreteProgression ) { - nextValue = *( m_pattern->valuesAfter( ( it + 1 ).key() ) ); + nextValue = it.value(); } else { - nextValue = values[ ( it + 1 ).key() - it.key() -1 ]; + nextValue = ( it + 1 ).value(); } p.setRenderHints( QPainter::Antialiasing, true );