# HG changeset patch # User Chris Cannam # Date 1488291656 0 # Node ID 8ef67917c301ec66e96518344261ecb93c88244e # Parent fc40742bb91181003d27052ac603dce325a8df31 Ctrl-click, and middle-button click, on level-pan widget reset to default (not implemented yet for level-pan tool button though) diff -r fc40742bb911 -r 8ef67917c301 widgets/LevelPanToolButton.cpp --- a/widgets/LevelPanToolButton.cpp Tue Feb 28 14:07:47 2017 +0000 +++ b/widgets/LevelPanToolButton.cpp Tue Feb 28 14:20:56 2017 +0000 @@ -152,8 +152,6 @@ void LevelPanToolButton::selfClicked() { - cerr << "selfClicked" << endl; - if (m_muted) { m_muted = false; m_lpw->setLevel(m_savedLevel); diff -r fc40742bb911 -r 8ef67917c301 widgets/LevelPanWidget.cpp --- a/widgets/LevelPanWidget.cpp Tue Feb 28 14:07:47 2017 +0000 +++ b/widgets/LevelPanWidget.cpp Tue Feb 28 14:20:56 2017 +0000 @@ -40,6 +40,7 @@ m_monitorLeft(-1), m_monitorRight(-1), m_editable(true), + m_editing(false), m_includeMute(true) { setToolTip(tr("Drag vertically to adjust level, horizontally to adjust pan")); @@ -51,6 +52,13 @@ { } +void +LevelPanWidget::setToDefault() +{ + setLevel(1.0); + setPan(0.0); +} + QSize LevelPanWidget::sizeHint() const { @@ -211,13 +219,28 @@ void LevelPanWidget::mousePressEvent(QMouseEvent *e) { + if (e->button() == Qt::MidButton || + ((e->button() == Qt::LeftButton) && + (e->modifiers() & Qt::ControlModifier))) { + setToDefault(); + } else if (e->button() == Qt::LeftButton) { + m_editing = true; + mouseMoveEvent(e); + } +} + +void +LevelPanWidget::mouseReleaseEvent(QMouseEvent *e) +{ mouseMoveEvent(e); + m_editing = false; } void LevelPanWidget::mouseMoveEvent(QMouseEvent *e) { if (!m_editable) return; + if (!m_editing) return; int level, pan; toCell(rect(), e->pos(), level, pan); @@ -236,12 +259,6 @@ } void -LevelPanWidget::mouseReleaseEvent(QMouseEvent *e) -{ - mouseMoveEvent(e); -} - -void LevelPanWidget::wheelEvent(QWheelEvent *e) { if (e->modifiers() & Qt::ControlModifier) { diff -r fc40742bb911 -r 8ef67917c301 widgets/LevelPanWidget.h --- a/widgets/LevelPanWidget.h Tue Feb 28 14:07:47 2017 +0000 +++ b/widgets/LevelPanWidget.h Tue Feb 28 14:20:56 2017 +0000 @@ -63,6 +63,9 @@ /// Specify whether the level range should include muting or not void setIncludeMute(bool); + + /// Reset to default values + void setToDefault(); // public so it can be called from LevelPanToolButton (ew) virtual void wheelEvent(QWheelEvent *ev); @@ -90,6 +93,7 @@ float m_monitorLeft; float m_monitorRight; bool m_editable; + bool m_editing; bool m_includeMute; static int audioLevelToLevel(float audioLevel, bool withMute);