Skip to content

Commit

Permalink
disable drag after drawing line
Browse files Browse the repository at this point in the history
  • Loading branch information
tecknixia committed Nov 10, 2019
1 parent b4459be commit c251a74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/AutomationEditor.h
Expand Up @@ -240,6 +240,7 @@ protected slots:

EditModes m_editMode;

bool m_mouseDownLeft;
bool m_mouseDownRight; //true if right click is being held down

TimeLineWidget * m_timeLine;
Expand Down
14 changes: 13 additions & 1 deletion src/gui/editors/AutomationEditor.cpp
Expand Up @@ -96,6 +96,7 @@ AutomationEditor::AutomationEditor() :
m_y_delta( DEFAULT_Y_DELTA ),
m_y_auto( true ),
m_editMode( DRAW ),
m_mouseDownLeft(false),
m_mouseDownRight( false ),
m_scrollBack( false ),
m_barLineColor( 0, 0, 0 ),
Expand Down Expand Up @@ -539,6 +540,10 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )
++it;
}

if (mouseEvent->button() == Qt::LeftButton)
{
m_mouseDownLeft = true;
}
if( mouseEvent->button() == Qt::RightButton )
{
m_mouseDownRight = true;
Expand All @@ -555,6 +560,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )
drawLine( m_drawLastTick,
m_drawLastLevel,
pos_ticks, level );
m_mouseDownLeft = false;
}
m_drawLastTick = pos_ticks;
m_drawLastLevel = level;
Expand Down Expand Up @@ -657,6 +663,11 @@ void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent )
{
bool mustRepaint = false;

if (mouseEvent->button() == Qt::LeftButton)
{
m_mouseDownLeft = false;
mustRepaint = true;
}
if ( mouseEvent->button() == Qt::RightButton )
{
m_mouseDownRight = false;
Expand Down Expand Up @@ -742,7 +753,8 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )

int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == DRAW )
// m_mouseDownLeft used to prevent drag when drawing line
if (m_mouseDownLeft && m_editMode == DRAW)
{
if( m_action == MOVE_VALUE )
{
Expand Down

0 comments on commit c251a74

Please sign in to comment.