Move mute handler to global keys; now works with selected + hovered

This commit is contained in:
Charles J. Cliffe 2016-06-11 22:13:42 -04:00
parent c33a359153
commit 8f2ce9f6dc
2 changed files with 12 additions and 8 deletions

View File

@ -1916,6 +1916,7 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
case 'U': case 'U':
case 'S': case 'S':
case 'P': case 'P':
case 'M':
return 1; return 1;
case '0': case '0':
case '1': case '1':
@ -1966,6 +1967,7 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) {
return -1; return -1;
} }
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator();
DemodulatorInstance *lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstance *lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
#ifdef wxHAS_RAW_KEY_CODES #ifdef wxHAS_RAW_KEY_CODES
@ -1995,8 +1997,8 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) {
waterfallCanvas->OnKeyUp(event); waterfallCanvas->OnKeyUp(event);
return 1; return 1;
case 'V': case 'V':
if (wxGetApp().getDemodMgr().getActiveDemodulator()) { if (activeDemod) {
lastDemod = wxGetApp().getDemodMgr().getActiveDemodulator(); lastDemod = activeDemod;
} }
if (lastDemod && lastDemod->isDeltaLock()) { if (lastDemod && lastDemod->isDeltaLock()) {
lastDemod->setDeltaLock(false); lastDemod->setDeltaLock(false);
@ -2040,6 +2042,14 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) {
case ']': case ']':
case '[': case '[':
return 1; return 1;
case 'M':
if (activeDemod) {
lastDemod = activeDemod;
}
if (lastDemod) {
lastDemod->setMuted(!lastDemod->isMuted());
}
break;
default: default:
break; break;
} }

View File

@ -437,12 +437,6 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
wxGetApp().removeDemodulator(activeDemod); wxGetApp().removeDemodulator(activeDemod);
wxGetApp().getDemodMgr().deleteThread(activeDemod); wxGetApp().getDemodMgr().deleteThread(activeDemod);
break; break;
case 'M':
if (!activeDemod) {
break;
}
activeDemod->setMuted(!activeDemod->isMuted());
break;
case 'B': case 'B':
if (spectrumCanvas) { if (spectrumCanvas) {
spectrumCanvas->setShowDb(!spectrumCanvas->getShowDb()); spectrumCanvas->setShowDb(!spectrumCanvas->getShowDb());