diff --git a/ChangeLog b/ChangeLog index 9d117d400..1927ee322 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,11 @@ * configure.in: Fix LIBDIR for when people do not use --prefix + * include/automation_editor.h: + * src/gui/automation_editor.cpp: + - Don't miss points when scribbling quickly + - Shift-Click to draw a line + 2008-06-28 Tobias Doerffel * plugins/Makefile.am: diff --git a/include/automation_editor.h b/include/automation_editor.h index bf44f4f2f..19d9f48b3 100644 --- a/include/automation_editor.h +++ b/include/automation_editor.h @@ -98,6 +98,7 @@ protected: void selectAll( void ); void getSelectedValues( timeMap & _selected_values ); + void drawLine( int x0, float y0, int x1, float y1 ); protected slots: void play( void ); @@ -212,6 +213,9 @@ private: tick m_moveStartTick; int m_moveXOffset; + float m_drawLastLevel; + tick m_drawLastTick; + int m_ppt; int m_y_delta; bool m_y_auto; diff --git a/src/gui/automation_editor.cpp b/src/gui/automation_editor.cpp index 8e3d89b89..8e0c56905 100644 --- a/src/gui/automation_editor.cpp +++ b/src/gui/automation_editor.cpp @@ -637,6 +637,52 @@ void automationEditor::leaveEvent( QEvent * _e ) } +void automationEditor::drawLine( int x0, float y0, int x1, float y1 ) +{ + int deltax = tAbs(x1 - x0); + float deltay = tAbs(y1 - y0); + int x = x0; + float y = y0; + int xstep; + int ystep; + + if( deltax == 0 ) + { + return; + } + + float yscale = deltay / deltax; + + if( x0 < x1) + { + xstep = quantization(); + } + else + { + xstep = -( quantization() ); + } + + if( y0 < y1 ) + { + ystep = 1; + } + else + { + ystep = -1; + } + + int i = 0; + while( i < deltax ) + { + y = y0 + ( ystep * yscale * i ); + + x += xstep; + i += quantization(); + m_pattern->removeValue( midiTime( x ) ); + m_pattern->putValue( midiTime( x ), y ); + } +}; + void automationEditor::mousePressEvent( QMouseEvent * _me ) @@ -690,6 +736,14 @@ void automationEditor::mousePressEvent( QMouseEvent * _me ) if( _me->button() == Qt::LeftButton && m_editMode == DRAW ) { + // Connect the dots + if( engine::getMainWindow()->isShiftPressed() == TRUE ) + { + drawLine( m_drawLastTick, m_drawLastLevel, pos_ticks, level ); + } + m_drawLastTick = pos_ticks; + m_drawLastLevel = level; + // did it reach end of map because // there's no value?? if( it == time_map.end() ) @@ -830,6 +884,10 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) pos_ticks = 0; } + drawLine( m_drawLastTick, m_drawLastLevel, pos_ticks, level ); + m_drawLastTick = pos_ticks; + m_drawLastLevel = level; + // we moved the value so the value has to be // moved properly according to new starting- // time in the time map of pattern