Menu and demod display tweaks

This commit is contained in:
Charles J. Cliffe 2018-01-02 23:51:32 -05:00
parent 8609667f33
commit be75c62778
4 changed files with 81 additions and 49 deletions

View File

@ -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<RtAudio::DeviceInfo>::iterator devices_i;
std::map<int, RtAudio::DeviceInfo>::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<unsigned int>::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() ? "<Not Set>" : 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();

View File

@ -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;

View File

@ -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;

View File

@ -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") {