From abcfee13343051002aa0cb42161254013868e64e Mon Sep 17 00:00:00 2001 From: tecknixia <50790262+tecknixia@users.noreply.github.com> Date: Wed, 22 Apr 2020 13:47:59 -0500 Subject: [PATCH] disable drag after drawing line (#5315) --- include/AutomationEditor.h | 1 + src/gui/editors/AutomationEditor.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 60b894f1f..520416be8 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -240,6 +240,7 @@ private: EditModes m_editMode; + bool m_mouseDownLeft; bool m_mouseDownRight; //true if right click is being held down TimeLineWidget * m_timeLine; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index bf56e3039..048123ef5 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -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 ), @@ -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; @@ -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; @@ -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; @@ -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 ) {