# HG changeset patch # User Chris Cannam # Date 1427280909 0 # Node ID 86df7de08e033b0d0abd5251a05ac1bf11e8cf70 # Parent 20698aa6a5179f4763ad373f950e8e6f1e212feb A number of fixes to level-pan button (including mute toggle) diff -r 20698aa6a517 -r 86df7de08e03 widgets/LevelPanToolButton.cpp --- a/widgets/LevelPanToolButton.cpp Wed Mar 25 10:33:19 2015 +0000 +++ b/widgets/LevelPanToolButton.cpp Wed Mar 25 10:55:09 2015 +0000 @@ -25,15 +25,19 @@ LevelPanToolButton::LevelPanToolButton(QWidget *parent) : QToolButton(parent), - m_pixels(32) + m_pixels(32), + m_muted(false), + m_savedLevel(1.f) { m_lpw = new LevelPanWidget(); connect(m_lpw, SIGNAL(levelChanged(float)), this, SIGNAL(levelChanged(float))); - connect(m_lpw, SIGNAL(levelChanged(float)), this, SLOT(redraw())); + connect(m_lpw, SIGNAL(levelChanged(float)), this, SLOT(selfLevelChanged(float))); connect(m_lpw, SIGNAL(panChanged(float)), this, SIGNAL(panChanged(float))); connect(m_lpw, SIGNAL(panChanged(float)), this, SLOT(redraw())); + + connect(this, SIGNAL(clicked(bool)), this, SLOT(selfClicked())); QMenu *menu = new QMenu(); QWidgetAction *wa = new QWidgetAction(menu); @@ -42,7 +46,6 @@ setPopupMode(MenuButtonPopup); setMenu(menu); - setCheckable(true); redraw(); } @@ -74,12 +77,42 @@ LevelPanToolButton::setLevel(float level) { m_lpw->setLevel(level); + redraw(); } void LevelPanToolButton::setPan(float pan) { m_lpw->setPan(pan); + redraw(); +} + +void +LevelPanToolButton::selfLevelChanged(float level) +{ + if (level > 0.f) { + m_muted = false; + } else { + m_muted = true; + m_savedLevel = 1.f; + } + redraw(); +} + +void +LevelPanToolButton::selfClicked() +{ + cerr << "selfClicked" << endl; + + if (m_muted) { + m_muted = false; + m_lpw->setLevel(m_savedLevel); + } else { + m_savedLevel = m_lpw->getLevel(); + m_muted = true; + m_lpw->setLevel(0.f); + } + redraw(); } void diff -r 20698aa6a517 -r 86df7de08e03 widgets/LevelPanToolButton.h --- a/widgets/LevelPanToolButton.h Wed Mar 25 10:33:19 2015 +0000 +++ b/widgets/LevelPanToolButton.h Wed Mar 25 10:55:09 2015 +0000 @@ -49,9 +49,15 @@ void levelChanged(float); void panChanged(float); +private slots: + void selfLevelChanged(float); + void selfClicked(); + protected: LevelPanWidget *m_lpw; int m_pixels; + bool m_muted; + float m_savedLevel; }; #endif diff -r 20698aa6a517 -r 86df7de08e03 widgets/LevelPanWidget.cpp --- a/widgets/LevelPanWidget.cpp Wed Mar 25 10:33:19 2015 +0000 +++ b/widgets/LevelPanWidget.cpp Wed Mar 25 10:55:09 2015 +0000 @@ -286,8 +286,10 @@ pen.setWidthF(thin * 2); pen.setCapStyle(Qt::RoundCap); paint.setPen(pen); - paint.drawLine(rect.topLeft(), rect.bottomRight()); - paint.drawLine(rect.bottomLeft(), rect.topRight()); + paint.drawLine(cellCentre(rect, 0, -maxPan), + cellCentre(rect, maxLevel, maxPan)); + paint.drawLine(cellCentre(rect, maxLevel, -maxPan), + cellCentre(rect, 0, maxPan)); return; }