Fix nudging out of view, fix keypad triggering and tuner freq entry target

This commit is contained in:
Charles J. Cliffe 2019-05-24 00:30:22 -04:00
parent 0fa818c2fb
commit 99ecbef373
12 changed files with 50 additions and 28 deletions

View File

@ -2769,15 +2769,19 @@ FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() {
return target;
}
void AppFrame::gkNudgeLeft(DemodulatorInstancePtr demod, int snap) {
void AppFrame::gkNudge(DemodulatorInstancePtr demod, int snap) {
if (demod) {
demod->setFrequency(demod->getFrequency()-snap);
demod->updateLabel(demod->getFrequency());
}
}
auto demodFreq = demod->getFrequency()+snap;
auto demodBw = demod->getBandwidth();
auto ctr = wxGetApp().getFrequency();
auto bw = wxGetApp().getSampleRate();
// Don't let it get nudged out of view.
if (ctr - (bw / 2) > (demodFreq - demodBw / 2) || ctr + (bw / 2) < (demodFreq + demodBw / 2)) {
wxGetApp().setFrequency(ctr+(snap*2));
}
void AppFrame::gkNudgeRight(DemodulatorInstancePtr demod, int snap) {
if (demod) {
demod->setFrequency(demod->getFrequency()+snap);
demod->updateLabel(demod->getFrequency());
}
@ -2821,10 +2825,10 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
#ifdef wxHAS_RAW_KEY_CODES
switch (event.GetRawKeyCode()) {
case 30:
gkNudgeRight(lastDemod, snap);
gkNudge(lastDemod, snap);
return 1;
case 33:
gkNudgeLeft(lastDemod, snap);
gkNudge(lastDemod, -snap);
return 1;
}
#endif
@ -2844,10 +2848,10 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
case 'V':
return 1;
case ']':
gkNudgeRight(lastDemod, snap);
gkNudge(lastDemod, snap);
return 1;
case '[':
gkNudgeLeft(lastDemod, snap);
gkNudge(lastDemod, -snap);
return 1;
case 'A':
case 'F':
@ -2858,6 +2862,18 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
case 'M':
case 'R':
return 1;
case WXK_NUMPAD0:
case WXK_NUMPAD1:
case WXK_NUMPAD2:
case WXK_NUMPAD3:
case WXK_NUMPAD4:
case WXK_NUMPAD5:
case WXK_NUMPAD6:
case WXK_NUMPAD7:
case WXK_NUMPAD8:
case WXK_NUMPAD9:
wxGetApp().showFrequencyInput(getFrequencyDialogTarget(), std::to_string(event.GetKeyCode() - WXK_NUMPAD0));
return 1;
case '0':
case '1':
case '2':

View File

@ -197,8 +197,7 @@ private:
/**
* Keyboard handlers
*/
void gkNudgeLeft(DemodulatorInstancePtr demod, int snap);
void gkNudgeRight(DemodulatorInstancePtr demod, int snap);
void gkNudge(DemodulatorInstancePtr demod, int snap);
void toggleActiveDemodRecording();
void toggleAllActiveDemodRecording();

View File

@ -945,11 +945,12 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
const wxString gainTitle("Gain Entry: "+wxGetApp().getActiveGainEntry());
wxString title;
auto activeModem = demodMgr.getActiveContextModem();
switch (targetMode) {
case FrequencyDialog::FDIALOG_TARGET_DEFAULT:
case FrequencyDialog::FDIALOG_TARGET_FREQ:
title = demodMgr.getActiveContextModem()?demodTitle:freqTitle;
title = activeModem ?demodTitle:freqTitle;
break;
case FrequencyDialog::FDIALOG_TARGET_BANDWIDTH:
title = bwTitle;
@ -969,8 +970,8 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
default:
break;
}
FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveContextModem(), wxPoint(-100,-100), wxSize(350, 75), wxDEFAULT_DIALOG_STYLE, targetMode, initString);
FrequencyDialog fdialog(appframe, -1, title, activeModem, wxPoint(-100,-100), wxSize(350, 75), wxDEFAULT_DIALOG_STYLE, targetMode, initString);
fdialog.ShowModal();
}

View File

@ -97,7 +97,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
}
}
if (targetMode == FDIALOG_TARGET_DEFAULT) {
if (targetMode == FDIALOG_TARGET_DEFAULT || targetMode == FDIALOG_TARGET_FREQ) {
if (ranged) {
freq = strToFrequency(strValue);
freq2 = strToFrequency(strValue2);
@ -105,10 +105,16 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
freq = strToFrequency(strValue);
}
if (activeDemod) {
activeDemod->setTracking(true);
activeDemod->setFollow(true);
activeDemod->setFrequency(freq);
activeDemod->updateLabel(freq);
freq_ctr = wxGetApp().getFrequency();
range_bw = wxGetApp().getSampleRate();
if (freq_ctr - (range_bw / 2) > freq || freq_ctr + (range_bw / 2) < freq) {
wxGetApp().setFrequency(freq);
}
} else {
if (ranged && (freq || freq2)) {
if (freq > freq2) {

View File

@ -38,7 +38,7 @@ UITestCanvas::~UITestCanvas() {
}
void UITestCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this);

View File

@ -51,7 +51,7 @@ GainCanvas::~GainCanvas() {
}
void GainCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this);

View File

@ -82,7 +82,7 @@ void MeterCanvas::setShowUserInput(bool showUserInput) {
}
void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this);

View File

@ -51,7 +51,7 @@ int ModeSelectorCanvas::getHoveredSelection() {
}
void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this);

View File

@ -101,7 +101,7 @@ bool ScopeCanvas::getShowDb() {
}
void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
ScopeRenderDataPtr avData;

View File

@ -51,7 +51,7 @@ SpectrumCanvas::~SpectrumCanvas() {
}
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
SpectrumVisualDataPtr vData;

View File

@ -84,7 +84,7 @@ void TuningCanvas::setHalfBand(bool hb) {
}
void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this);

View File

@ -128,7 +128,7 @@ void WaterfallCanvas::processInputQueue() {
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
std::lock_guard < std::mutex > lock(tex_update);
wxPaintDC dc(this);
// wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
long double currentZoom = zoom;