changeset 1249:8ef67917c301

Ctrl-click, and middle-button click, on level-pan widget reset to default (not implemented yet for level-pan tool button though)
author Chris Cannam
date Tue, 28 Feb 2017 14:20:56 +0000
parents fc40742bb911
children c49a48fcc364
files widgets/LevelPanToolButton.cpp widgets/LevelPanWidget.cpp widgets/LevelPanWidget.h
diffstat 3 files changed, 27 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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) {
--- 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);