diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/widget/woverview.cpp | 28 | ||||
-rw-r--r-- | src/widget/woverview.h | 2 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index aa24b3ecf8..0ee93047b7 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -55,6 +55,7 @@ WOverview::WOverview( m_pConfig(pConfig), m_endOfTrack(false), m_pCueMenu(std::make_unique<CueMenu>(this)), + m_bDrag(false), m_bShowCueTimes(true), m_iPosSeconds(0), m_iPos(0), @@ -204,6 +205,10 @@ void WOverview::setup(const QDomNode& node, const SkinContext& context) { void WOverview::onConnectedControlChanged(double dParameter, double dValue) { // this is connected via skin to "playposition" Q_UNUSED(dValue); + if (m_bDrag) { + // don't move slider under the mouse + return; + } // Calculate handle position. Clamp the value within 0-1 because that's // all we represent with this widget. dParameter = math_clamp(dParameter, 0.0, 1.0); @@ -381,6 +386,14 @@ void WOverview::receiveCuesUpdated() { } void WOverview::mouseMoveEvent(QMouseEvent* e) { + if (m_bDrag) { + if (m_orientation == Qt::Horizontal) { + m_iPos = math_clamp(e->x(), 0, width() - 1); + } else { + m_iPos = math_clamp(e->y(), 0, height() - 1); + } + } + // Do not activate cue hovering while right click is held down and the // button down event was not on a cue. if (m_bTimeRulerActive) { @@ -425,9 +438,15 @@ void WOverview::mouseMoveEvent(QMouseEvent* e) { void WOverview::mouseReleaseEvent(QMouseEvent* e) { mouseMoveEvent(e); + double dValue = positionToValue(m_iPos); //qDebug() << "WOverview::mouseReleaseEvent" << e->pos() << m_iPos << ">>" << dValue; - if (e->button() == Qt::RightButton) { + if (e->button() == Qt::LeftButton) { + setControlParameterUp(dValue); + m_bDrag = false; + } else if (e->button() == Qt::RightButton) { + // Do not seek when releasing a right click. This is important to + // prevent accidental seeking when trying to right click a hotcue. m_bTimeRulerActive = false; } } @@ -438,7 +457,6 @@ void WOverview::mousePressEvent(QMouseEvent* e) { if (m_pCurrentTrack == nullptr) { return; } - if (e->button() == Qt::LeftButton) { if (m_orientation == Qt::Horizontal) { m_iPos = math_clamp(e->x(), 0, width() - 1); @@ -450,8 +468,11 @@ void WOverview::mousePressEvent(QMouseEvent* e) { if (m_pHoveredMark != nullptr) { dValue = m_pHoveredMark->getSamplePosition() / m_trackSamplesControl->get(); m_iPos = valueToPosition(dValue); + setControlParameterUp(dValue); + m_bDrag = false; + } else { + m_bDrag = true; } - setControlParameterUp(dValue); } else if (e->button() == Qt::RightButton) { if (m_pHoveredMark == nullptr) { m_bTimeRulerActive = true; @@ -491,6 +512,7 @@ void WOverview::leaveEvent(QEvent* e) { if (!m_bHotcueMenuShowing) { m_pHoveredMark.clear(); } + m_bDrag = false; m_bTimeRulerActive = false; update(); } diff --git a/src/widget/woverview.h b/src/widget/woverview.h index d5bcc4792a..ed383aeba0 100644 --- a/src/widget/woverview.h +++ b/src/widget/woverview.h @@ -146,7 +146,9 @@ class WOverview : public WWidget, public TrackDropTarget { std::unique_ptr<CueMenu> m_pCueMenu; bool m_bShowCueTimes; + // True if slider is dragged. Only used when m_bEventWhileDrag is false int m_iPosSeconds; + bool m_bDrag; // Internal storage of slider position in pixels int m_iPos; |