diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index a15441a8..7f376e08 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -293,6 +293,7 @@ AppConfig::AppConfig() : configName("") { mainSplit = -1; visSplit = -1; bookmarkSplit = -1; + bookmarksVisible.store(true); #ifdef USE_HAMLIB rigEnabled.store(false); @@ -469,6 +470,14 @@ float AppConfig::getBookmarkSplit() { return bookmarkSplit.load(); } +void AppConfig::setBookmarksVisible(bool state) { + bookmarksVisible.store(state); +} + +bool AppConfig::getBookmarksVisible() { + return bookmarksVisible.load(); +} + void AppConfig::setConfigName(std::string configName) { this->configName = configName; @@ -520,6 +529,7 @@ bool AppConfig::save() { *window_node->newChild("main_split") = mainSplit.load(); *window_node->newChild("vis_split") = visSplit.load(); *window_node->newChild("bookmark_split") = bookmarkSplit.load(); + *window_node->newChild("bookmark_visible") = bookmarksVisible.load(); } DataNode *devices_node = cfg.rootNode()->newChild("devices"); @@ -695,6 +705,12 @@ bool AppConfig::load() { win_node->getNext("bookmark_split")->element()->get(gVal); bookmarkSplit.store(gVal); } + + if (win_node->hasAnother("bookmark_visible")) { + int bVal; + win_node->getNext("bookmark_visible")->element()->get(bVal); + bookmarksVisible.store(bVal); + } } if (cfg.rootNode()->hasAnother("devices")) { diff --git a/src/AppConfig.h b/src/AppConfig.h index cedff38b..0eb8f3f1 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -127,6 +127,9 @@ class AppConfig { void setBookmarkSplit(float value); float getBookmarkSplit(); + void setBookmarksVisible(bool state); + bool getBookmarksVisible(); + #if USE_HAMLIB int getRigModel(); @@ -176,6 +179,6 @@ class AppConfig { #if USE_HAMLIB std::atomic_int rigModel, rigRate; std::string rigPort; - std::atomic_bool rigEnabled, rigFollowMode, rigControlMode, rigCenterLock, rigFollowModem; + std::atomic_bool rigEnabled, rigFollowMode, rigControlMode, rigCenterLock, rigFollowModem, bookmarksVisible; #endif }; diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 96c28825..cb6407a9 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -364,6 +364,11 @@ AppFrame::AppFrame() : bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter ); mainSplitter->SplitHorizontally( demodPanel, bookmarkSplitter ); + + if (!wxGetApp().getConfig()->getBookmarksVisible()) { + bookmarkSplitter->Unsplit(bookmarkView); + bookmarkSplitter->Layout(); + } vbox->Add(mainSplitter, 1, wxEXPAND | wxALL, 0); @@ -523,6 +528,9 @@ AppFrame::AppFrame() : themeMenu->AppendRadioItem(wxID_THEME_HD, "HD")->Check(themeId==COLOR_THEME_HD); displayMenu->AppendSubMenu(themeMenu, wxT("&Color Scheme")); + + hideBookmarksItem = displayMenu->AppendCheckItem(wxID_DISPLAY_BOOKMARKS, wxT("Hide Bookmarks")); + hideBookmarksItem->Check(!wxGetApp().getConfig()->getBookmarksVisible()); GLFont::setScale((GLFont::GLFontScale)fontScale); @@ -1012,6 +1020,9 @@ void AppFrame::OnMenu(wxCommandEvent& event) { demodTuner->Refresh(); SetTitle(CUBICSDR_TITLE); currentSessionFile = ""; + bookmarkSplitter->Unsplit(bookmarkView); + bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter, wxGetApp().getConfig()->getBookmarkSplit() ); + hideBookmarksItem->Check(false); } else if (event.GetId() == wxID_CLOSE || event.GetId() == wxID_EXIT) { Close(false); } else if (event.GetId() == wxID_THEME_DEFAULT) { @@ -1044,6 +1055,14 @@ void AppFrame::OnMenu(wxCommandEvent& event) { GLFont::setScale(GLFont::GLFONT_SCALE_LARGE); //force all windows refresh Refresh(); + } else if (event.GetId() == wxID_DISPLAY_BOOKMARKS) { + if (hideBookmarksItem->IsChecked()) { + bookmarkSplitter->Unsplit(bookmarkView); + bookmarkSplitter->Layout(); + } else { + bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter, wxGetApp().getConfig()->getBookmarkSplit() ); + bookmarkSplitter->Layout(); + } } if (event.GetId() >= wxID_SETTINGS_BASE && event.GetId() < settingsIdMax) { @@ -1311,7 +1330,8 @@ void AppFrame::OnClose(wxCloseEvent& event) { wxGetApp().getConfig()->setModemPropsCollapsed(modemProps->isCollapsed()); wxGetApp().getConfig()->setMainSplit(mainSplitter->GetSashPosition()); wxGetApp().getConfig()->setVisSplit(mainVisSplitter->GetSashPosition()); - wxGetApp().getConfig()->setBookmarkSplit(bookmarkSplitter->GetSashPosition()); + if (!hideBookmarksItem->IsChecked()) wxGetApp().getConfig()->setBookmarkSplit(bookmarkSplitter->GetSashPosition()); + wxGetApp().getConfig()->setBookmarksVisible(!hideBookmarksItem->IsChecked()); #ifdef USE_HAMLIB wxGetApp().getConfig()->setRigEnabled(rigEnableMenuItem->IsChecked()); wxGetApp().getConfig()->setRigModel(rigModel); diff --git a/src/AppFrame.h b/src/AppFrame.h index fca2a7e8..bb6f8b0b 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -49,6 +49,8 @@ #define wxID_THEME_HD 2105 #define wxID_THEME_RADAR 2106 +#define wxID_DISPLAY_BOOKMARKS 2107 + #define wxID_BANDWIDTH_BASE 2150 #define wxID_BANDWIDTH_MANUAL 2200 @@ -196,6 +198,7 @@ class AppFrame: public wxFrame { wxMenuItem *rigCenterLockMenuItem; wxMenuItem *rigFollowModemMenuItem; wxMenuItem *sdrIFMenuItem; + wxMenuItem *hideBookmarksItem; std::map rigSerialMenuItems; std::map rigModelMenuItems; int rigModel; diff --git a/src/forms/Bookmark/BookmarkView.cpp b/src/forms/Bookmark/BookmarkView.cpp index 06f902fc..e77523d9 100644 --- a/src/forms/Bookmark/BookmarkView.cpp +++ b/src/forms/Bookmark/BookmarkView.cpp @@ -126,6 +126,9 @@ BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, void BookmarkView::onUpdateTimer( wxTimerEvent& event ) { + if (!this->IsShown()) { + return; + } if (doUpdateActive.load()) { doUpdateActiveList();