diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 527a8b9..25ef1c8 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -313,9 +313,9 @@ AppFrame::AppFrame() : mainVisSplitter->SplitHorizontally( spectrumPanel, waterfallPanel, 0 ); - bookmarkPanel = new BookmarkPanel(bookmarkSplitter, wxID_ANY, wxDefaultPosition, wxSize(120,-1)); + bookmarkView = new BookmarkView(bookmarkSplitter, wxID_ANY, wxDefaultPosition, wxSize(120,-1)); - bookmarkSplitter->SplitVertically( bookmarkPanel, mainVisSplitter ); + bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter ); mainSplitter->SplitHorizontally( demodPanel, bookmarkSplitter ); vbox->Add(mainSplitter, 1, wxEXPAND | wxALL, 0); @@ -1836,6 +1836,10 @@ bool AppFrame::isUserDemodBusy() { wxGetApp().getDemodMgr().getLastActiveDemodulator() != wxGetApp().getDemodMgr().getActiveDemodulator()); } +BookmarkView *AppFrame::getBookmarkView() { + return bookmarkView; +} + #ifdef _WIN32 bool AppFrame::canFocus() { diff --git a/src/AppFrame.h b/src/AppFrame.h index 6124b8c..c0b0299 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -103,7 +103,9 @@ public: void setViewState(long long center_freq); bool isUserDemodBusy(); - + + BookmarkView *getBookmarkView(); + #ifdef _WIN32 bool canFocus(); #endif @@ -136,7 +138,7 @@ private: wxSizerItem *gainSizerItem, *gainSpacerItem; wxSplitterWindow *mainVisSplitter, *mainSplitter, *bookmarkSplitter; wxBoxSizer *demodTray; - BookmarkPanel *bookmarkPanel; + BookmarkView *bookmarkView; DemodulatorInstance *activeDemodulator; diff --git a/src/forms/Bookmark/BookmarkPanel.cpp b/src/forms/Bookmark/BookmarkPanel.cpp index decffca..78c7f11 100644 --- a/src/forms/Bookmark/BookmarkPanel.cpp +++ b/src/forms/Bookmark/BookmarkPanel.cpp @@ -73,6 +73,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po this->SetSizer( bSizer1 ); this->Layout(); + m_updateTimer.SetOwner( this, wxID_ANY ); // Connect Events m_treeView->Connect( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, wxTreeEventHandler( BookmarkPanel::onTreeBeginLabelEdit ), NULL, this ); @@ -86,6 +87,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po 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 ); + this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( BookmarkPanel::onUpdateTimer ) ); } BookmarkPanel::~BookmarkPanel() @@ -102,5 +104,6 @@ BookmarkPanel::~BookmarkPanel() 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 ); + this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( BookmarkPanel::onUpdateTimer ) ); } diff --git a/src/forms/Bookmark/BookmarkPanel.fbp b/src/forms/Bookmark/BookmarkPanel.fbp index 9a34b9b..b1ec872 100644 --- a/src/forms/Bookmark/BookmarkPanel.fbp +++ b/src/forms/Bookmark/BookmarkPanel.fbp @@ -1215,6 +1215,15 @@ + + 0 + wxID_ANY + m_updateTimer + 0 + 500 + protected + onUpdateTimer + diff --git a/src/forms/Bookmark/BookmarkPanel.h b/src/forms/Bookmark/BookmarkPanel.h index 97e5848..7ef675f 100644 --- a/src/forms/Bookmark/BookmarkPanel.h +++ b/src/forms/Bookmark/BookmarkPanel.h @@ -21,6 +21,7 @@ #include #include #include +#include /////////////////////////////////////////////////////////////////////////// @@ -46,6 +47,7 @@ class BookmarkPanel : public wxPanel wxButton* m_bookmarkButton; wxButton* m_activateButton; wxButton* m_removeButton; + wxTimer m_updateTimer; // Virtual event handlers, overide them in your derived class virtual void onTreeBeginLabelEdit( wxTreeEvent& event ) { event.Skip(); } @@ -59,6 +61,7 @@ class BookmarkPanel : public wxPanel virtual void onBookmark( wxCommandEvent& event ) { event.Skip(); } virtual void onActivate( wxCommandEvent& event ) { event.Skip(); } virtual void onRemove( wxCommandEvent& event ) { event.Skip(); } + virtual void onUpdateTimer( wxTimerEvent& event ) { event.Skip(); } public: diff --git a/src/forms/Bookmark/BookmarkView.cpp b/src/forms/Bookmark/BookmarkView.cpp index fd82918..7b52abc 100644 --- a/src/forms/Bookmark/BookmarkView.cpp +++ b/src/forms/Bookmark/BookmarkView.cpp @@ -2,20 +2,32 @@ #include "CubicSDR.h" BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) { - doUpdateActive = false; + + activeBranch = m_treeView->AddRoot("Active"); + doUpdateActive = true; + m_updateTimer.Start(500); +} + +void BookmarkView::onUpdateTimer( wxTimerEvent& event ) { + if (doUpdateActive) { + doUpdateActiveList(); + +// doUpdateActive = false; + } } void BookmarkView::updateActiveList() { + doUpdateActive = true; +} + +void BookmarkView::doUpdateActiveList() { std::vector &demods = wxGetApp().getDemodMgr().getDemodulators(); - DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); - DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); +// DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); +// DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); - m_treeView->Disable(); - m_treeView->DeleteAllItems(); activeItems.erase(activeItems.begin(),activeItems.end()); - - activeBranch = m_treeView->AddRoot("Active"); + m_treeView->DeleteChildren(activeBranch); for (auto demod_i : demods) { wxTreeItemId itm = m_treeView->AppendItem(activeBranch,demod_i->getLabel()); @@ -24,6 +36,7 @@ void BookmarkView::updateActiveList() { m_treeView->Enable(); m_treeView->ExpandAll(); + } void BookmarkView::onTreeBeginLabelEdit( wxTreeEvent& event ) { diff --git a/src/forms/Bookmark/BookmarkView.h b/src/forms/Bookmark/BookmarkView.h index bbef98c..53aa07d 100644 --- a/src/forms/Bookmark/BookmarkView.h +++ b/src/forms/Bookmark/BookmarkView.h @@ -11,6 +11,9 @@ public: void updateActiveList(); protected: + void onUpdateTimer( wxTimerEvent& event ); + void doUpdateActiveList(); + void onTreeBeginLabelEdit( wxTreeEvent& event ); void onTreeEndLabelEdit( wxTreeEvent& event ); void onTreeActivate( wxTreeEvent& event );