diff --git a/src/BookmarkMgr.cpp b/src/BookmarkMgr.cpp index bf0411a..4b4f172 100644 --- a/src/BookmarkMgr.cpp +++ b/src/BookmarkMgr.cpp @@ -59,6 +59,19 @@ BookmarkList BookmarkMgr::getBookmarks(std::string group, std::string folder) { return results; } +BookmarkGroup BookmarkMgr::getGroup(std::string group) { + return bmData[group]; +} + +BookmarkNames BookmarkMgr::getGroups() { + BookmarkNames results; + for (BookmarkMap::iterator i = bmData.begin(); i!= bmData.end(); ++i) { + results.push_back(i->first); + } + return results; +} + + void BookmarkMgr::updateActiveList() { BookmarkView *bmv = wxGetApp().getAppFrame()->getBookmarkView(); diff --git a/src/BookmarkMgr.h b/src/BookmarkMgr.h index d396f21..b88160b 100644 --- a/src/BookmarkMgr.h +++ b/src/BookmarkMgr.h @@ -31,7 +31,9 @@ struct BookmarkEntryCompare : public std::binary_function BookmarkList; -typedef std::map > BookmarkMap; +typedef std::set BookmarkGroup; +typedef std::map BookmarkMap; +typedef std::vector BookmarkNames; class BookmarkMgr { public: @@ -41,7 +43,8 @@ public: void addBookmark(std::string group, DemodulatorInstance *demod, std::string folder = ""); void removeBookmark(std::string group, BookmarkEntry *be); BookmarkList getBookmarks(std::string group, std::string folder = ""); - + BookmarkGroup getGroup(std::string group); + BookmarkNames getGroups(); void updateActiveList(); protected: diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index acc888e..db82134 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -753,6 +753,7 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM switch (targetMode) { case FrequencyDialog::FDIALOG_TARGET_DEFAULT: + case FrequencyDialog::FDIALOG_TARGET_FREQ: title = demodMgr.getActiveDemodulator()?demodTitle:freqTitle; break; case FrequencyDialog::FDIALOG_TARGET_BANDWIDTH: diff --git a/src/demod/DemodulatorMgr.cpp b/src/demod/DemodulatorMgr.cpp index b312bf7..5aa2da9 100644 --- a/src/demod/DemodulatorMgr.cpp +++ b/src/demod/DemodulatorMgr.cpp @@ -217,6 +217,7 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool tempo wxGetApp().getRigThread()->setFrequency(lastActiveDemodulator.load()->getFrequency(),true); } #endif + wxGetApp().getBookmarkMgr().updateActiveList(); } else { std::lock_guard < std::recursive_mutex > lock(demods_busy); garbageCollect(); diff --git a/src/forms/Bookmark/BookmarkPanel.cpp b/src/forms/Bookmark/BookmarkPanel.cpp index a3ae15c..4090714 100644 --- a/src/forms/Bookmark/BookmarkPanel.cpp +++ b/src/forms/Bookmark/BookmarkPanel.cpp @@ -14,7 +14,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); - m_treeView = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE ); + m_treeView = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT ); bSizer1->Add( m_treeView, 5, wxEXPAND, 5 ); m_propPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); @@ -84,6 +84,8 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this ); m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this ); m_labelText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this ); + m_frequencyVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this ); + m_bandwidthVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this ); m_bookmarkButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onBookmark ), NULL, this ); m_activateButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onActivate ), NULL, this ); m_removeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onRemove ), NULL, this ); @@ -101,6 +103,8 @@ BookmarkPanel::~BookmarkPanel() m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this ); m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this ); m_labelText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this ); + m_frequencyVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this ); + m_bandwidthVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this ); m_bookmarkButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onBookmark ), NULL, this ); m_activateButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onActivate ), NULL, this ); m_removeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onRemove ), NULL, this ); diff --git a/src/forms/Bookmark/BookmarkPanel.fbp b/src/forms/Bookmark/BookmarkPanel.fbp index 23d466c..10f3f80 100644 --- a/src/forms/Bookmark/BookmarkPanel.fbp +++ b/src/forms/Bookmark/BookmarkPanel.fbp @@ -132,7 +132,7 @@ Resizable 1 - wxTR_DEFAULT_STYLE + wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT 0 @@ -597,7 +597,7 @@ - + onDoubleClickFreq @@ -763,7 +763,7 @@ - + onDoubleClickBandwidth diff --git a/src/forms/Bookmark/BookmarkPanel.h b/src/forms/Bookmark/BookmarkPanel.h index 6bc1293..bb07915 100644 --- a/src/forms/Bookmark/BookmarkPanel.h +++ b/src/forms/Bookmark/BookmarkPanel.h @@ -58,6 +58,8 @@ class BookmarkPanel : public wxPanel virtual void onTreeSelect( wxTreeEvent& event ) { event.Skip(); } virtual void onTreeSelectChanging( wxTreeEvent& event ) { event.Skip(); } virtual void onLabelText( wxCommandEvent& event ) { event.Skip(); } + virtual void onDoubleClickFreq( wxMouseEvent& event ) { event.Skip(); } + virtual void onDoubleClickBandwidth( wxMouseEvent& event ) { event.Skip(); } virtual void onBookmark( wxCommandEvent& event ) { event.Skip(); } virtual void onActivate( wxCommandEvent& event ) { event.Skip(); } virtual void onRemove( wxCommandEvent& event ) { event.Skip(); } diff --git a/src/forms/Bookmark/BookmarkView.cpp b/src/forms/Bookmark/BookmarkView.cpp index c144390..ed98ccb 100644 --- a/src/forms/Bookmark/BookmarkView.cpp +++ b/src/forms/Bookmark/BookmarkView.cpp @@ -2,8 +2,9 @@ #include "CubicSDR.h" BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) { - - activeBranch = m_treeView->AddRoot("Active"); + rootBranch = m_treeView->AddRoot("Root"); + activeBranch = m_treeView->AppendItem(rootBranch, "Active"); + bookmarkBranch = m_treeView->AppendItem(rootBranch, "Bookmarks"); doUpdateActive = false; activeSel = nullptr; m_updateTimer.Start(500); @@ -26,15 +27,28 @@ void BookmarkView::updateActiveList() { void BookmarkView::doUpdateActiveList() { std::vector &demods = wxGetApp().getDemodMgr().getDemodulators(); -// DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); + DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); // DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); activeItems.erase(activeItems.begin(),activeItems.end()); m_treeView->DeleteChildren(activeBranch); + wxTreeItemId selItem = nullptr; for (auto demod_i : demods) { wxTreeItemId itm = m_treeView->AppendItem(activeBranch,demod_i->getLabel()); activeItems[itm] = demod_i; + if (activeDemodulator) { + if (activeDemodulator == demod_i) { + selItem = itm; + activeSel = demod_i; + } + } + else if (activeSel == demod_i) { + selItem = itm; + } + } + if (selItem != nullptr) { + m_treeView->SelectItem(selItem); } m_treeView->Enable(); @@ -134,6 +148,24 @@ void BookmarkView::onLabelText( wxCommandEvent& event ) { event.Skip(); } +void BookmarkView::onDoubleClickFreq( wxMouseEvent& event ) { + if (activeSel) { + wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false); + wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT); + } else { + event.Skip(); + } +} + +void BookmarkView::onDoubleClickBandwidth( wxMouseEvent& event ) { + if (activeSel) { + wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false); + wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH); + } else { + event.Skip(); + } +} + void BookmarkView::onBookmark( wxCommandEvent& event ) { event.Skip(); } diff --git a/src/forms/Bookmark/BookmarkView.h b/src/forms/Bookmark/BookmarkView.h index dd00217..0519fde 100644 --- a/src/forms/Bookmark/BookmarkView.h +++ b/src/forms/Bookmark/BookmarkView.h @@ -26,12 +26,16 @@ protected: void onTreeSelect( wxTreeEvent& event ); void onTreeSelectChanging( wxTreeEvent& event ); void onLabelText( wxCommandEvent& event ); + void onDoubleClickFreq( wxMouseEvent& event ); + void onDoubleClickBandwidth( wxMouseEvent& event ); void onBookmark( wxCommandEvent& event ); void onActivate( wxCommandEvent& event ); void onRemove( wxCommandEvent& event ); bool doUpdateActive; - wxTreeItemId activeBranch; + wxTreeItemId rootBranch, activeBranch, bookmarkBranch; + std::map groups; + std::map activeItems; DemodulatorInstance *activeSel; }; \ No newline at end of file