Improve automationEditor mouse-drawing

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1209 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-06-29 12:56:03 +00:00
parent cc520a6b2d
commit 4463d67629
3 changed files with 67 additions and 0 deletions

View File

@@ -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 <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/Makefile.am:

View File

@@ -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;

View File

@@ -637,6 +637,52 @@ void automationEditor::leaveEvent( QEvent * _e )
}
void automationEditor::drawLine( int x0, float y0, int x1, float y1 )
{
int deltax = tAbs<float>(x1 - x0);
float deltay = tAbs<float>(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