Add Tab/Shift-Tab next/prev modem
This commit is contained in:
parent
d31a628b13
commit
5a26669832
|
@ -1582,6 +1582,8 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
DemodulatorInstance *demod = nullptr, *lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
switch (event.GetKeyCode()) {
|
||||
case WXK_UP:
|
||||
case WXK_NUMPAD_UP:
|
||||
|
@ -1611,6 +1613,21 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
|
|||
wxGetApp().showFrequencyInput(getFrequencyDialogTarget(), std::to_string(event.GetKeyCode() - '0'));
|
||||
return 1;
|
||||
break;
|
||||
case WXK_TAB:
|
||||
lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
if (!lastDemod) {
|
||||
break;
|
||||
}
|
||||
if (event.ShiftDown()) {
|
||||
demod = wxGetApp().getDemodMgr().getPreviousDemodulator(lastDemod);
|
||||
} else {
|
||||
demod = wxGetApp().getDemodMgr().getNextDemodulator(lastDemod);
|
||||
}
|
||||
if (demod) {
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr);
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(demod, false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
#include "CubicSDR.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
bool demodFreqCompare (DemodulatorInstance *i, DemodulatorInstance *j) { return (i->getFrequency()<j->getFrequency()); }
|
||||
bool inactiveCompare (DemodulatorInstance *i, DemodulatorInstance *j) { return (i->isActive()<j->isActive()); }
|
||||
|
||||
DemodulatorMgr::DemodulatorMgr() :
|
||||
activeDemodulator(NULL), lastActiveDemodulator(NULL), activeVisualDemodulator(NULL), lastBandwidth(DEFAULT_DEMOD_BW), lastDemodType(
|
||||
|
@ -38,6 +42,69 @@ std::vector<DemodulatorInstance *> &DemodulatorMgr::getDemodulators() {
|
|||
return demods;
|
||||
}
|
||||
|
||||
std::vector<DemodulatorInstance *> DemodulatorMgr::getOrderedDemodulators(bool actives) {
|
||||
std::vector<DemodulatorInstance *> demods_ordered = demods;
|
||||
if (actives) {
|
||||
std::sort(demods_ordered.begin(), demods_ordered.end(), inactiveCompare);
|
||||
std::vector<DemodulatorInstance *>::iterator i;
|
||||
for (i = demods_ordered.begin(); i != demods_ordered.end(); i++) {
|
||||
if ((*i)->isActive()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == demods_ordered.end()) {
|
||||
demods_ordered.erase(demods_ordered.begin(), demods_ordered.end());
|
||||
} else if ((*i) != demods_ordered.front()) {
|
||||
demods_ordered.erase(demods_ordered.begin(), i);
|
||||
}
|
||||
}
|
||||
std::sort(demods_ordered.begin(), demods_ordered.end(), demodFreqCompare);
|
||||
return demods_ordered;
|
||||
}
|
||||
|
||||
DemodulatorInstance *DemodulatorMgr::getPreviousDemodulator(DemodulatorInstance *demod, bool actives) {
|
||||
if (!getLastActiveDemodulator()) {
|
||||
return nullptr;
|
||||
}
|
||||
std::vector<DemodulatorInstance *> demods_ordered = getOrderedDemodulators(actives);
|
||||
std::vector<DemodulatorInstance *>::iterator p = std::find(demods_ordered.begin(), demods_ordered.end(), demod);
|
||||
if (p == demods_ordered.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (*p == demods_ordered.front()) {
|
||||
return demods_ordered.back();
|
||||
}
|
||||
return *(--p);
|
||||
}
|
||||
|
||||
DemodulatorInstance *DemodulatorMgr::getNextDemodulator(DemodulatorInstance *demod, bool actives) {
|
||||
if (!getLastActiveDemodulator()) {
|
||||
return nullptr;
|
||||
}
|
||||
std::vector<DemodulatorInstance *> demods_ordered = getOrderedDemodulators(actives);
|
||||
std::vector<DemodulatorInstance *>::iterator p = std::find(demods_ordered.begin(), demods_ordered.end(), demod);
|
||||
if (actives) {
|
||||
|
||||
}
|
||||
if (p == demods_ordered.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (*p == demods_ordered.back()) {
|
||||
return demods_ordered.front();
|
||||
}
|
||||
return *(++p);
|
||||
}
|
||||
|
||||
DemodulatorInstance *DemodulatorMgr::getLastDemodulator() {
|
||||
std::vector<DemodulatorInstance *> demods_ordered = getOrderedDemodulators();
|
||||
return *(demods_ordered.end());
|
||||
}
|
||||
|
||||
DemodulatorInstance *DemodulatorMgr::getFirstDemodulator() {
|
||||
std::vector<DemodulatorInstance *> demods_ordered = getOrderedDemodulators();
|
||||
return *(demods_ordered.begin());
|
||||
}
|
||||
|
||||
void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
|
||||
std::vector<DemodulatorInstance *>::iterator i;
|
||||
|
||||
|
|
|
@ -13,7 +13,12 @@ public:
|
|||
|
||||
DemodulatorInstance *newThread();
|
||||
std::vector<DemodulatorInstance *> &getDemodulators();
|
||||
std::vector<DemodulatorInstance *> getOrderedDemodulators(bool actives = true);
|
||||
std::vector<DemodulatorInstance *> *getDemodulatorsAt(long long freq, int bandwidth);
|
||||
DemodulatorInstance *getPreviousDemodulator(DemodulatorInstance *demod, bool actives = true);
|
||||
DemodulatorInstance *getNextDemodulator(DemodulatorInstance *demod, bool actives = true);
|
||||
DemodulatorInstance *getLastDemodulator();
|
||||
DemodulatorInstance *getFirstDemodulator();
|
||||
bool anyDemodulatorsAt(long long freq, int bandwidth);
|
||||
void deleteThread(DemodulatorInstance *);
|
||||
|
||||
|
|
Loading…
Reference in New Issue