Skip to content

Commit 06c40fc

Browse files
authored
Automation Editor - Straighten out draw line function (#3997)
Fixes: AutomationEditor::drawLine(..) - quantize input AutomationEditor::drawLine(..) - Adjust line level.
1 parent 260c184 commit 06c40fc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/gui/editors/AutomationEditor.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,11 @@ void AutomationEditor::leaveEvent(QEvent * e )
434434
}
435435

436436

437-
void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 )
437+
void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 )
438438
{
439-
int deltax = qRound( qAbs<float>( x1 - x0 ) );
439+
int x0 = Note::quantized( x0In, AutomationPattern::quantization() );
440+
int x1 = Note::quantized( x1In, AutomationPattern::quantization() );
441+
int deltax = qAbs( x1 - x0 );
440442
float deltay = qAbs<float>( y1 - y0 );
441443
int x = x0;
442444
float y = y0;
@@ -452,7 +454,7 @@ void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 )
452454

453455
float yscale = deltay / ( deltax );
454456

455-
if( x0 < x1)
457+
if( x0 < x1 )
456458
{
457459
xstep = AutomationPattern::quantization();
458460
}
@@ -461,19 +463,22 @@ void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 )
461463
xstep = -( AutomationPattern::quantization() );
462464
}
463465

466+
float lineAdjust;
464467
if( y0 < y1 )
465468
{
466469
ystep = 1;
470+
lineAdjust = yscale;
467471
}
468472
else
469473
{
470474
ystep = -1;
475+
lineAdjust = -( yscale );
471476
}
472477

473478
int i = 0;
474479
while( i < deltax )
475480
{
476-
y = y0 + ( ystep * yscale * i );
481+
y = y0 + ( ystep * yscale * i ) + lineAdjust;
477482

478483
x += xstep;
479484
i += 1;

0 commit comments

Comments
 (0)