Automation Editor - Straighten out draw line function (#3997)
Fixes: AutomationEditor::drawLine(..) - quantize input AutomationEditor::drawLine(..) - Adjust line level.
This commit is contained in:
@@ -434,9 +434,11 @@ void AutomationEditor::leaveEvent(QEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 )
|
||||
void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 )
|
||||
{
|
||||
int deltax = qRound( qAbs<float>( x1 - x0 ) );
|
||||
int x0 = Note::quantized( x0In, AutomationPattern::quantization() );
|
||||
int x1 = Note::quantized( x1In, AutomationPattern::quantization() );
|
||||
int deltax = qAbs( x1 - x0 );
|
||||
float deltay = qAbs<float>( y1 - y0 );
|
||||
int x = x0;
|
||||
float y = y0;
|
||||
@@ -452,7 +454,7 @@ void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 )
|
||||
|
||||
float yscale = deltay / ( deltax );
|
||||
|
||||
if( x0 < x1)
|
||||
if( x0 < x1 )
|
||||
{
|
||||
xstep = AutomationPattern::quantization();
|
||||
}
|
||||
@@ -461,19 +463,22 @@ void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 )
|
||||
xstep = -( AutomationPattern::quantization() );
|
||||
}
|
||||
|
||||
float lineAdjust;
|
||||
if( y0 < y1 )
|
||||
{
|
||||
ystep = 1;
|
||||
lineAdjust = yscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
ystep = -1;
|
||||
lineAdjust = -( yscale );
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while( i < deltax )
|
||||
{
|
||||
y = y0 + ( ystep * yscale * i );
|
||||
y = y0 + ( ystep * yscale * i ) + lineAdjust;
|
||||
|
||||
x += xstep;
|
||||
i += 1;
|
||||
|
||||
Reference in New Issue
Block a user