Improve active list integration/interactivity

This commit is contained in:
Charles J. Cliffe 2016-09-29 20:47:38 -04:00
parent 9ffdf6808d
commit 003758b799
9 changed files with 70 additions and 10 deletions

View File

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

View File

@ -31,7 +31,9 @@ struct BookmarkEntryCompare : public std::binary_function<BookmarkEntry *,Bookma
typedef std::vector<BookmarkEntry *> BookmarkList;
typedef std::map<std::string, std::set<BookmarkEntry *, BookmarkEntryCompare> > BookmarkMap;
typedef std::set<BookmarkEntry *, BookmarkEntryCompare> BookmarkGroup;
typedef std::map<std::string, BookmarkGroup > BookmarkMap;
typedef std::vector<std::string> 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:

View File

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

View File

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

View File

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

View File

@ -132,7 +132,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxTR_DEFAULT_STYLE</property>
<property name="style">wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -597,7 +597,7 @@
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDClick">onDoubleClickFreq</event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
@ -763,7 +763,7 @@
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDClick">onDoubleClickBandwidth</event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>

View File

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

View File

@ -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<DemodulatorInstance *> &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();
}

View File

@ -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<std::string, wxTreeItemId> groups;
std::map<wxTreeItemId, DemodulatorInstance *> activeItems;
DemodulatorInstance *activeSel;
};