From be75c627780ce1944470fb1b0bc48d6f0759aeeb Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 2 Jan 2018 23:51:32 -0500 Subject: [PATCH] Menu and demod display tweaks --- src/AppFrame.cpp | 95 +++++++++++++++++++------------ src/AppFrame.h | 4 ++ src/demod/DemodulatorInstance.cpp | 4 +- src/visual/PrimaryGLContext.cpp | 27 +++++---- 4 files changed, 81 insertions(+), 49 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index fc901fc..7f2998d 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -402,45 +402,15 @@ AppFrame::AppFrame() : // Make a menubar menuBar = new wxMenuBar; - wxMenu *menu = new wxMenu; -#ifndef __APPLE__ -#ifdef CUBICSDR_ENABLE_ABOUT_DIALOG - menu->Append(wxID_ABOUT_CUBICSDR, "About " CUBICSDR_INSTALL_NAME); -#endif -#endif - menu->Append(wxID_SDR_DEVICES, "SDR Devices"); - menu->AppendSeparator(); - menu->Append(wxID_SDR_START_STOP, "Stop / Start Device"); - menu->AppendSeparator(); - menu->Append(wxID_RECORDING_PATH, "Set Recording Path"); - menu->AppendSeparator(); - menu->Append(wxID_OPEN, "&Open Session"); - menu->Append(wxID_SAVE, "&Save Session"); - menu->Append(wxID_SAVEAS, "Save Session &As.."); - menu->AppendSeparator(); - menu->Append(wxID_RESET, "&Reset Session"); - -#ifndef __APPLE__ - menu->AppendSeparator(); - menu->Append(wxID_CLOSE); -#else -#ifdef CUBICSDR_ENABLE_ABOUT_DIALOG - if ( wxApp::s_macAboutMenuItemId != wxID_NONE ) { - wxString aboutLabel; - aboutLabel.Printf(_("About %s"), CUBICSDR_INSTALL_NAME); - menu->Append( wxApp::s_macAboutMenuItemId, aboutLabel); - } -#endif -#endif + + fileMenu = makeFileMenu(); - menuBar->Append(menu, wxT("&File")); + menuBar->Append(fileMenu, wxT("&File")); settingsMenu = new wxMenu; menuBar->Append(settingsMenu, wxT("&Settings")); - menu = new wxMenu; - std::vector::iterator devices_i; std::map::iterator mdevices_i; AudioThread::enumerateDevices(devices); @@ -474,7 +444,7 @@ AppFrame::AppFrame() : menuBar->Append(sampleRateMenu, wxT("Sample &Rate")); // Audio Sample Rates - menu = new wxMenu; + wxMenu *audioSampleRateMenu = new wxMenu; #define NUM_RATES_DEFAULT 4 unsigned int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 }; @@ -504,7 +474,7 @@ AppFrame::AppFrame() : for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) { int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first; wxMenu *subMenu = new wxMenu; - menu->AppendSubMenu(subMenu, mdevices_i->second.name, wxT("Description?")); + audioSampleRateMenu->AppendSubMenu(subMenu, mdevices_i->second.name, wxT("Description?")); int j = 0; for (std::vector::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); @@ -522,7 +492,7 @@ AppFrame::AppFrame() : } } - menuBar->Append(menu, wxT("Audio &Sample Rate")); + menuBar->Append(audioSampleRateMenu, wxT("Audio &Sample Rate")); //Add Display menu displayMenu = new wxMenu; @@ -531,7 +501,7 @@ AppFrame::AppFrame() : int fontScale = wxGetApp().getConfig()->getFontScale(); - fontMenu->AppendRadioItem(wxID_DISPLAY_BASE, "Normal")->Check(GLFont::GLFONT_SCALE_NORMAL == fontScale); + fontMenu->AppendRadioItem(wxID_DISPLAY_BASE, "Default")->Check(GLFont::GLFONT_SCALE_NORMAL == fontScale); fontMenu->AppendRadioItem(wxID_DISPLAY_BASE + 1, "1.5x")->Check(GLFont::GLFONT_SCALE_MEDIUM == fontScale); fontMenu->AppendRadioItem(wxID_DISPLAY_BASE + 2, "2.0x")->Check(GLFont::GLFONT_SCALE_LARGE == fontScale); @@ -725,6 +695,56 @@ AppFrame::~AppFrame() { t_FFTData->join(); } +wxMenu *AppFrame::makeFileMenu() { + + wxMenu *menu = new wxMenu; +#ifndef __APPLE__ +#ifdef CUBICSDR_ENABLE_ABOUT_DIALOG + menu->Append(wxID_ABOUT_CUBICSDR, "About " CUBICSDR_INSTALL_NAME); +#endif +#endif + menu->Append(wxID_SDR_DEVICES, "SDR Devices"); + menu->AppendSeparator(); + menu->Append(wxID_SDR_START_STOP, "Stop / Start Device"); + menu->AppendSeparator(); + + std::string recPath = wxGetApp().getConfig()->getRecordingPath(); + if (recPath.length() > 32) { + recPath = "..." + recPath.substr(recPath.length() - 32, 32); + } + + menu->Append(wxID_RECORDING_PATH, getSettingsLabel("Set Recording Path", recPath.empty() ? "" : recPath)); + + menu->AppendSeparator(); + menu->Append(wxID_OPEN, "&Open Session"); + menu->Append(wxID_SAVE, "&Save Session"); + menu->Append(wxID_SAVEAS, "Save Session &As.."); + menu->AppendSeparator(); + menu->Append(wxID_RESET, "&Reset Session"); + +#ifndef __APPLE__ + menu->AppendSeparator(); + menu->Append(wxID_CLOSE); +#else +#ifdef CUBICSDR_ENABLE_ABOUT_DIALOG + if (wxApp::s_macAboutMenuItemId != wxID_NONE) { + wxString aboutLabel; + aboutLabel.Printf(_("About %s"), CUBICSDR_INSTALL_NAME); + menu->Append(wxApp::s_macAboutMenuItemId, aboutLabel); + } +#endif +#endif + + return menu; +} + +void AppFrame::updateFileMenu() { + wxMenu *newFileMenu = makeFileMenu(); + menuBar->Replace(0, newFileMenu, wxT("&File")); + fileMenu = newFileMenu; +} + + void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo) { this->devInfo = devInfo; deviceChanged.store(true); @@ -1570,6 +1590,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) { } wxGetApp().getConfig()->setRecordingPath(recPathDialog.GetPath().ToStdString()); + updateFileMenu(); } else if (event.GetId() == wxID_LOW_PERF) { lowPerfMode = lowPerfMenuItem->IsChecked(); diff --git a/src/AppFrame.h b/src/AppFrame.h index 8033685..57576a8 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -97,6 +97,9 @@ public: AppFrame(); ~AppFrame(); + wxMenu *makeFileMenu(); + void updateFileMenu(); + void initDeviceParams(SDRDeviceInfo *devInfo); void updateDeviceParams(); @@ -221,6 +224,7 @@ private: wxMenuItem *agcMenuItem = nullptr; wxMenuItem *iqSwapMenuItem = nullptr; wxMenuItem *lowPerfMenuItem = nullptr; + wxMenu *fileMenu = nullptr; wxMenu *settingsMenu = nullptr; SoapySDR::ArgInfoList settingArgs; diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index 92a4f4c..067745b 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -635,8 +635,8 @@ void DemodulatorInstance::startRecording() { std::wstring userLabel = getDemodulatorUserLabel(); - // TODO: Can we support wstring filenames for user labels? - std::string userLabelStr(userLabel.begin(), userLabel.end()); + wxString userLabelForFileName(userLabel); + std::string userLabelStr = userLabelForFileName.ToStdString(); if (!userLabelStr.empty()) { fileName << userLabelStr; diff --git a/src/visual/PrimaryGLContext.cpp b/src/visual/PrimaryGLContext.cpp index a21dc78..cd56408 100644 --- a/src/visual/PrimaryGLContext.cpp +++ b/src/visual/PrimaryGLContext.cpp @@ -165,22 +165,29 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstancePtr demod, RGBA4f color, glColor4f(1.0, 1.0, 1.0, 0.8f); - std::string demodLabel = demod->getLabel(); - - if (demod->isMuted()) { - demodLabel = std::string("[M] ") + demodLabel; - } else if (isSolo) { - demodLabel = std::string("[S] ") + demodLabel; - } - + std::string demodLabel, demodPrefix; + if (demod->isDeltaLock()) { - demodLabel.append(" [V]"); + demodPrefix.append("V"); } if (isRecording) { - demodLabel.append(" [R]"); + demodPrefix.append("R"); } + if (demod->isMuted()) { + demodPrefix.append("M"); + } else if (isSolo) { + demodPrefix.append("S"); + } + + // Set the prefix + if (!demodPrefix.empty()) { + demodLabel = "[" + demodPrefix + "] "; + } + // Append the default label + demodLabel.append(demod->getLabel()); + if (demod->getDemodulatorType() == "USB") { GLFont::getFont(16, GLFont::getScaleFactor()).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); } else if (demod->getDemodulatorType() == "LSB") {