Save font scale in global settings

This commit is contained in:
vsonnier 2016-06-20 19:28:26 +02:00
parent f3d4b8868a
commit 92221bccdd
6 changed files with 58 additions and 8 deletions

View File

@ -284,6 +284,7 @@ AppConfig::AppConfig() : configName("") {
showTips.store(true); showTips.store(true);
lowPerfMode.store(false); lowPerfMode.store(false);
themeId.store(0); themeId.store(0);
fontScale.store(0);
snap.store(1); snap.store(1);
centerFreq.store(100000000); centerFreq.store(100000000);
waterfallLinesPerSec.store(DEFAULT_WATERFALL_LPS); waterfallLinesPerSec.store(DEFAULT_WATERFALL_LPS);
@ -373,6 +374,14 @@ int AppConfig::getTheme() {
return themeId.load(); return themeId.load();
} }
void AppConfig::setFontScale(int fontScale) {
this->fontScale.store(fontScale);
}
int AppConfig::getFontScale() {
return fontScale.load();
}
void AppConfig::setSnap(long long snapVal) { void AppConfig::setSnap(long long snapVal) {
this->snap.store(snapVal); this->snap.store(snapVal);
@ -454,6 +463,7 @@ bool AppConfig::save() {
*window_node->newChild("tips") = showTips.load(); *window_node->newChild("tips") = showTips.load();
*window_node->newChild("low_perf_mode") = lowPerfMode.load(); *window_node->newChild("low_perf_mode") = lowPerfMode.load();
*window_node->newChild("theme") = themeId.load(); *window_node->newChild("theme") = themeId.load();
*window_node->newChild("font_scale") = fontScale.load();
*window_node->newChild("snap") = snap.load(); *window_node->newChild("snap") = snap.load();
*window_node->newChild("center_freq") = centerFreq.load(); *window_node->newChild("center_freq") = centerFreq.load();
*window_node->newChild("waterfall_lps") = waterfallLinesPerSec.load(); *window_node->newChild("waterfall_lps") = waterfallLinesPerSec.load();
@ -574,6 +584,12 @@ bool AppConfig::load() {
themeId.store(theme); 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")) { if (win_node->hasAnother("snap")) {
long long snapVal; long long snapVal;
win_node->getNext("snap")->element()->get(snapVal); win_node->getNext("snap")->element()->get(snapVal);

View File

@ -94,6 +94,9 @@ public:
void setTheme(int themeId); void setTheme(int themeId);
int getTheme(); int getTheme();
void setFontScale(int scaleValue);
int getFontScale();
void setSnap(long long snapVal); void setSnap(long long snapVal);
long long getSnap(); long long getSnap();
@ -147,6 +150,7 @@ private:
std::atomic_int winX,winY,winW,winH; std::atomic_int winX,winY,winW,winH;
std::atomic_bool winMax, showTips, lowPerfMode; std::atomic_bool winMax, showTips, lowPerfMode;
std::atomic_int themeId; std::atomic_int themeId;
std::atomic_int fontScale;
std::atomic_llong snap; std::atomic_llong snap;
std::atomic_llong centerFreq; std::atomic_llong centerFreq;
std::atomic_int waterfallLinesPerSec; std::atomic_int waterfallLinesPerSec;

View File

@ -447,14 +447,18 @@ AppFrame::AppFrame() :
menuBar->Append(menu, wxT("Audio &Sample Rate")); menuBar->Append(menu, wxT("Audio &Sample Rate"));
//Add Display menu
displayMenu = new wxMenu; displayMenu = new wxMenu;
menuBar->Append(displayMenu, wxT("&Display")); menuBar->Append(displayMenu, wxT("&Display"));
wxMenuItem *itmNormal = displayMenu->AppendRadioItem(wxID_DISPLAY_BASE, "Normal font (1x)"); int fontScale = wxGetApp().getConfig()->getFontScale();
displayMenu->AppendRadioItem(wxID_DISPLAY_BASE + 1, "Medium font (1.5x)");
displayMenu->AppendRadioItem(wxID_DISPLAY_BASE + 2, "Large font (2x)");
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 #ifdef USE_HAMLIB
@ -590,6 +594,9 @@ AppFrame::AppFrame() :
// static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; // static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
// wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not"); // wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
// ShowFullScreen(true); // ShowFullScreen(true);
//Force refresh of all
Refresh();
} }
AppFrame::~AppFrame() { AppFrame::~AppFrame() {
@ -782,7 +789,9 @@ void AppFrame::disableRig() {
} }
#endif #endif
void AppFrame::OnMenu(wxCommandEvent& event) { void AppFrame::OnMenu(wxCommandEvent& event) {
if (event.GetId() >= wxID_RT_AUDIO_DEVICE && event.GetId() < wxID_RT_AUDIO_DEVICE + (int)devices.size()) { if (event.GetId() >= wxID_RT_AUDIO_DEVICE && event.GetId() < wxID_RT_AUDIO_DEVICE + (int)devices.size()) {
if (activeDemodulator) { if (activeDemodulator) {
activeDemodulator->setOutputDevice(event.GetId() - wxID_RT_AUDIO_DEVICE); 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()->setWindow(this->GetPosition(), this->GetClientSize());
wxGetApp().getConfig()->setWindowMaximized(this->IsMaximized()); wxGetApp().getConfig()->setWindowMaximized(this->IsMaximized());
wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme()); wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme());
wxGetApp().getConfig()->setFontScale(GLFont::getScale());
wxGetApp().getConfig()->setSnap(wxGetApp().getFrequencySnap()); wxGetApp().getConfig()->setSnap(wxGetApp().getFrequencySnap());
wxGetApp().getConfig()->setCenterFreq(wxGetApp().getFrequency()); wxGetApp().getConfig()->setCenterFreq(wxGetApp().getFrequency());
wxGetApp().getConfig()->setSpectrumAvgSpeed(wxGetApp().getSpectrumProcessor()->getFFTAverageRate()); wxGetApp().getConfig()->setSpectrumAvgSpeed(wxGetApp().getSpectrumProcessor()->getFFTAverageRate());
@ -1570,6 +1580,8 @@ void AppFrame::OnUnSplit(wxSplitterEvent& event)
event.Veto(); event.Veto();
} }
void AppFrame::saveSession(std::string fileName) { void AppFrame::saveSession(std::string fileName) {
DataTree s("cubicsdr_session"); DataTree s("cubicsdr_session");
DataNode *header = s.rootNode()->newChild("header"); DataNode *header = s.rootNode()->newChild("header");
@ -1609,7 +1621,7 @@ void AppFrame::saveSession(std::string fileName) {
*settingsNode->newChild(msi->first.c_str()) = msi->second; *settingsNode->newChild(msi->first.c_str()) = msi->second;
} }
} }
} } //end for demodulators
s.SaveToFileXML(fileName); s.SaveToFileXML(fileName);

View File

@ -141,12 +141,14 @@ private:
std::map<int, wxMenuItem *> audioSampleRateMenuItems; std::map<int, wxMenuItem *> audioSampleRateMenuItems;
std::map<int, wxMenuItem *> directSamplingMenuItems; std::map<int, wxMenuItem *> directSamplingMenuItems;
wxMenuBar *menuBar; wxMenuBar *menuBar;
wxMenu *sampleRateMenu; wxMenu *sampleRateMenu;
wxMenu *displayMenu; wxMenu *displayMenu;
wxMenuItem *agcMenuItem; wxMenuItem *agcMenuItem;
wxMenuItem *iqSwapMenuItem; wxMenuItem *iqSwapMenuItem;
wxMenuItem *lowPerfMenuItem; wxMenuItem *lowPerfMenuItem;
wxMenu *settingsMenu; wxMenu *settingsMenu;
SoapySDR::ArgInfoList settingArgs; SoapySDR::ArgInfoList settingArgs;
int settingsIdMax; int settingsIdMax;
std::vector<long> sampleRates; std::vector<long> sampleRates;

View File

@ -811,7 +811,6 @@ void GLFont::setScale(GLFontScale scale) {
//0) Normal: //0) Normal:
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex); std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);
currentScaleFactor = scale;
userFontZoomMapping[GLFont::GLFONT_SIZE12] = GLFont::GLFONT_SIZE12; userFontZoomMapping[GLFont::GLFONT_SIZE12] = GLFont::GLFONT_SIZE12;
userFontZoomMapping[GLFont::GLFONT_SIZE16] = GLFont::GLFONT_SIZE16; userFontZoomMapping[GLFont::GLFONT_SIZE16] = GLFont::GLFONT_SIZE16;
@ -825,6 +824,14 @@ void GLFont::setScale(GLFontScale scale) {
userFontZoomMapping[GLFont::GLFONT_SIZE72] = GLFont::GLFONT_SIZE72; userFontZoomMapping[GLFont::GLFONT_SIZE72] = GLFont::GLFONT_SIZE72;
userFontZoomMapping[GLFont::GLFONT_SIZE96] = GLFont::GLFONT_SIZE96; 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: //override depending of zoom level:
//Medium : more or less 1.5 x //Medium : more or less 1.5 x
if (currentScaleFactor == GLFontScale::GLFONT_SCALE_MEDIUM) { if (currentScaleFactor == GLFontScale::GLFONT_SCALE_MEDIUM) {
@ -877,3 +884,10 @@ double GLFont::getScaleFactor() {
return 1.0; return 1.0;
} }
GLFont::GLFontScale GLFont::getScale() {
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);
return currentScaleFactor;
}

View File

@ -105,6 +105,8 @@ public:
//Called to change the scale of the rendered fonts //Called to change the scale of the rendered fonts
static void setScale(GLFontScale scale); 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.) //Return the current scale factor in use (1.0 for normal, 1.5 for medium, 2.0 for large for ex.)
static double getScaleFactor(); static double getScaleFactor();