diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index 85b3016..1fb7d99 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -284,6 +284,7 @@ AppConfig::AppConfig() : configName("") { showTips.store(true); lowPerfMode.store(false); themeId.store(0); + fontScale.store(0); snap.store(1); centerFreq.store(100000000); waterfallLinesPerSec.store(DEFAULT_WATERFALL_LPS); @@ -373,6 +374,14 @@ int AppConfig::getTheme() { return themeId.load(); } +void AppConfig::setFontScale(int fontScale) { + this->fontScale.store(fontScale); +} + +int AppConfig::getFontScale() { + return fontScale.load(); +} + void AppConfig::setSnap(long long snapVal) { this->snap.store(snapVal); @@ -454,6 +463,7 @@ bool AppConfig::save() { *window_node->newChild("tips") = showTips.load(); *window_node->newChild("low_perf_mode") = lowPerfMode.load(); *window_node->newChild("theme") = themeId.load(); + *window_node->newChild("font_scale") = fontScale.load(); *window_node->newChild("snap") = snap.load(); *window_node->newChild("center_freq") = centerFreq.load(); *window_node->newChild("waterfall_lps") = waterfallLinesPerSec.load(); @@ -574,6 +584,12 @@ bool AppConfig::load() { themeId.store(theme); } + if (win_node->hasAnother("font_scale")) { + int fscale; + win_node->getNext("font_scale")->element()->get(fscale); + fontScale.store(fscale); + } + if (win_node->hasAnother("snap")) { long long snapVal; win_node->getNext("snap")->element()->get(snapVal); diff --git a/src/AppConfig.h b/src/AppConfig.h index 1b39b29..fdc4a24 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -94,6 +94,9 @@ public: void setTheme(int themeId); int getTheme(); + void setFontScale(int scaleValue); + int getFontScale(); + void setSnap(long long snapVal); long long getSnap(); @@ -147,6 +150,7 @@ private: std::atomic_int winX,winY,winW,winH; std::atomic_bool winMax, showTips, lowPerfMode; std::atomic_int themeId; + std::atomic_int fontScale; std::atomic_llong snap; std::atomic_llong centerFreq; std::atomic_int waterfallLinesPerSec; diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 223fb7b..f81f09c 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -447,14 +447,18 @@ AppFrame::AppFrame() : menuBar->Append(menu, wxT("Audio &Sample Rate")); + + //Add Display menu displayMenu = new wxMenu; menuBar->Append(displayMenu, wxT("&Display")); - wxMenuItem *itmNormal = displayMenu->AppendRadioItem(wxID_DISPLAY_BASE, "Normal font (1x)"); - displayMenu->AppendRadioItem(wxID_DISPLAY_BASE + 1, "Medium font (1.5x)"); - displayMenu->AppendRadioItem(wxID_DISPLAY_BASE + 2, "Large font (2x)"); + int fontScale = wxGetApp().getConfig()->getFontScale(); - itmNormal->Check(true); + displayMenu->AppendRadioItem(wxID_DISPLAY_BASE, "Normal font (1x)")->Check(GLFont::GLFONT_SCALE_NORMAL == fontScale); + displayMenu->AppendRadioItem(wxID_DISPLAY_BASE + 1, "Medium font (1.5x)")->Check(GLFont::GLFONT_SCALE_MEDIUM == fontScale); + displayMenu->AppendRadioItem(wxID_DISPLAY_BASE + 2, "Large font (2x)")->Check(GLFont::GLFONT_SCALE_LARGE == fontScale); + + GLFont::setScale((GLFont::GLFontScale)fontScale); #ifdef USE_HAMLIB @@ -590,6 +594,9 @@ AppFrame::AppFrame() : // static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; // wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not"); // ShowFullScreen(true); + + //Force refresh of all + Refresh(); } AppFrame::~AppFrame() { @@ -782,7 +789,9 @@ void AppFrame::disableRig() { } #endif + void AppFrame::OnMenu(wxCommandEvent& event) { + if (event.GetId() >= wxID_RT_AUDIO_DEVICE && event.GetId() < wxID_RT_AUDIO_DEVICE + (int)devices.size()) { if (activeDemodulator) { activeDemodulator->setOutputDevice(event.GetId() - wxID_RT_AUDIO_DEVICE); @@ -1184,6 +1193,7 @@ void AppFrame::OnClose(wxCloseEvent& event) { wxGetApp().getConfig()->setWindow(this->GetPosition(), this->GetClientSize()); wxGetApp().getConfig()->setWindowMaximized(this->IsMaximized()); wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme()); + wxGetApp().getConfig()->setFontScale(GLFont::getScale()); wxGetApp().getConfig()->setSnap(wxGetApp().getFrequencySnap()); wxGetApp().getConfig()->setCenterFreq(wxGetApp().getFrequency()); wxGetApp().getConfig()->setSpectrumAvgSpeed(wxGetApp().getSpectrumProcessor()->getFFTAverageRate()); @@ -1570,6 +1580,8 @@ void AppFrame::OnUnSplit(wxSplitterEvent& event) event.Veto(); } + + void AppFrame::saveSession(std::string fileName) { DataTree s("cubicsdr_session"); DataNode *header = s.rootNode()->newChild("header"); @@ -1609,7 +1621,7 @@ void AppFrame::saveSession(std::string fileName) { *settingsNode->newChild(msi->first.c_str()) = msi->second; } } - } + } //end for demodulators s.SaveToFileXML(fileName); diff --git a/src/AppFrame.h b/src/AppFrame.h index 2ecce1a..5c9774b 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -109,7 +109,7 @@ private: void OnIdle(wxIdleEvent& event); void OnDoubleClickSash(wxSplitterEvent& event); void OnUnSplit(wxSplitterEvent& event); - + ScopeCanvas *scopeCanvas; SpectrumCanvas *spectrumCanvas; WaterfallCanvas *waterfallCanvas; @@ -141,12 +141,14 @@ private: std::map audioSampleRateMenuItems; std::map directSamplingMenuItems; wxMenuBar *menuBar; + wxMenu *sampleRateMenu; wxMenu *displayMenu; wxMenuItem *agcMenuItem; wxMenuItem *iqSwapMenuItem; wxMenuItem *lowPerfMenuItem; wxMenu *settingsMenu; + SoapySDR::ArgInfoList settingArgs; int settingsIdMax; std::vector sampleRates; diff --git a/src/util/GLFont.cpp b/src/util/GLFont.cpp index 0be4e57..0c30563 100644 --- a/src/util/GLFont.cpp +++ b/src/util/GLFont.cpp @@ -811,8 +811,7 @@ void GLFont::setScale(GLFontScale scale) { //0) Normal: std::lock_guard lock(g_userFontZoomMappingMutex); - currentScaleFactor = scale; - + userFontZoomMapping[GLFont::GLFONT_SIZE12] = GLFont::GLFONT_SIZE12; userFontZoomMapping[GLFont::GLFONT_SIZE16] = GLFont::GLFONT_SIZE16; userFontZoomMapping[GLFont::GLFONT_SIZE18] = GLFont::GLFONT_SIZE18; @@ -824,6 +823,14 @@ void GLFont::setScale(GLFontScale scale) { userFontZoomMapping[GLFont::GLFONT_SIZE64] = GLFont::GLFONT_SIZE64; userFontZoomMapping[GLFont::GLFONT_SIZE72] = GLFont::GLFONT_SIZE72; userFontZoomMapping[GLFont::GLFONT_SIZE96] = GLFont::GLFONT_SIZE96; + + currentScaleFactor = scale; + + //safety vs. inputs + if (currentScaleFactor < GLFONT_SCALE_NORMAL || currentScaleFactor > GLFONT_SCALE_LARGE) { + + currentScaleFactor = GLFontScale::GLFONT_SCALE_NORMAL; + } //override depending of zoom level: //Medium : more or less 1.5 x @@ -877,3 +884,10 @@ double GLFont::getScaleFactor() { return 1.0; } +GLFont::GLFontScale GLFont::getScale() { + + std::lock_guard lock(g_userFontZoomMappingMutex); + + return currentScaleFactor; +} + diff --git a/src/util/GLFont.h b/src/util/GLFont.h index 84bf10d..f520c9b 100644 --- a/src/util/GLFont.h +++ b/src/util/GLFont.h @@ -105,6 +105,8 @@ public: //Called to change the scale of the rendered fonts static void setScale(GLFontScale scale); + static GLFontScale getScale(); + //Return the current scale factor in use (1.0 for normal, 1.5 for medium, 2.0 for large for ex.) static double getScaleFactor();