Bookmark panel active list testing

This commit is contained in:
Charles J. Cliffe 2016-09-14 22:49:32 -04:00
parent 488e8ed9e7
commit f4ab6fbaad
7 changed files with 48 additions and 11 deletions

View File

@ -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() {

View File

@ -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;

View File

@ -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 ) );
}

View File

@ -1215,6 +1215,15 @@
</object>
</object>
</object>
<object class="wxTimer" expanded="1">
<property name="enabled">0</property>
<property name="id">wxID_ANY</property>
<property name="name">m_updateTimer</property>
<property name="oneshot">0</property>
<property name="period">500</property>
<property name="permission">protected</property>
<event name="OnTimer">onUpdateTimer</event>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -21,6 +21,7 @@
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/timer.h>
///////////////////////////////////////////////////////////////////////////
@ -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:

View File

@ -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<DemodulatorInstance *> &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 ) {

View File

@ -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 );