2016-09-13 22:59:21 -04:00
|
|
|
#include "BookmarkView.h"
|
2016-09-14 22:10:27 -04:00
|
|
|
#include "CubicSDR.h"
|
2016-09-13 22:59:21 -04:00
|
|
|
|
|
|
|
BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) {
|
2016-09-29 20:47:38 -04:00
|
|
|
rootBranch = m_treeView->AddRoot("Root");
|
|
|
|
activeBranch = m_treeView->AppendItem(rootBranch, "Active");
|
|
|
|
bookmarkBranch = m_treeView->AppendItem(rootBranch, "Bookmarks");
|
2016-09-28 20:37:39 -04:00
|
|
|
doUpdateActive = false;
|
|
|
|
activeSel = nullptr;
|
2016-09-14 22:49:32 -04:00
|
|
|
m_updateTimer.Start(500);
|
2016-09-28 20:37:39 -04:00
|
|
|
hideProps();
|
|
|
|
m_propPanel->Hide();
|
2016-09-14 22:49:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onUpdateTimer( wxTimerEvent& event ) {
|
|
|
|
if (doUpdateActive) {
|
|
|
|
doUpdateActiveList();
|
|
|
|
|
2016-09-22 20:40:07 -04:00
|
|
|
doUpdateActive = false;
|
2016-09-14 22:49:32 -04:00
|
|
|
}
|
2016-09-14 22:10:27 -04:00
|
|
|
}
|
|
|
|
|
2016-09-29 21:57:23 -04:00
|
|
|
void BookmarkView::updateTheme() {
|
|
|
|
wxColour bgColor(ThemeMgr::mgr.currentTheme->generalBackground);
|
|
|
|
wxColour textColor(ThemeMgr::mgr.currentTheme->text);
|
|
|
|
wxColour btn(ThemeMgr::mgr.currentTheme->button);
|
|
|
|
wxColour btnHl(ThemeMgr::mgr.currentTheme->buttonHighlight);
|
|
|
|
|
|
|
|
m_treeView->SetBackgroundColour(bgColor);
|
|
|
|
m_treeView->SetForegroundColour(textColor);
|
|
|
|
|
|
|
|
m_propPanel->SetBackgroundColour(bgColor);
|
|
|
|
m_propPanel->SetForegroundColour(textColor);
|
|
|
|
|
|
|
|
m_labelLabel->SetForegroundColour(textColor);
|
|
|
|
m_frequencyVal->SetForegroundColour(textColor);
|
|
|
|
m_frequencyLabel->SetForegroundColour(textColor);
|
|
|
|
m_bandwidthVal->SetForegroundColour(textColor);
|
|
|
|
m_bandwidthLabel->SetForegroundColour(textColor);
|
|
|
|
m_modulationVal->SetForegroundColour(textColor);
|
|
|
|
m_modulationLabel->SetForegroundColour(textColor);
|
|
|
|
|
|
|
|
m_bookmarkButton->SetBackgroundColour(bgColor);
|
|
|
|
m_removeButton->SetBackgroundColour(bgColor);
|
|
|
|
m_activateButton->SetBackgroundColour(bgColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-14 22:10:27 -04:00
|
|
|
void BookmarkView::updateActiveList() {
|
2016-09-14 22:49:32 -04:00
|
|
|
doUpdateActive = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::doUpdateActiveList() {
|
2016-09-14 22:10:27 -04:00
|
|
|
std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators();
|
|
|
|
|
2016-09-29 20:47:38 -04:00
|
|
|
DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator();
|
2016-09-14 22:49:32 -04:00
|
|
|
// DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
2016-09-14 22:10:27 -04:00
|
|
|
|
|
|
|
activeItems.erase(activeItems.begin(),activeItems.end());
|
2016-09-14 22:49:32 -04:00
|
|
|
m_treeView->DeleteChildren(activeBranch);
|
2016-09-14 22:10:27 -04:00
|
|
|
|
2016-09-29 20:47:38 -04:00
|
|
|
wxTreeItemId selItem = nullptr;
|
2016-09-14 22:10:27 -04:00
|
|
|
for (auto demod_i : demods) {
|
|
|
|
wxTreeItemId itm = m_treeView->AppendItem(activeBranch,demod_i->getLabel());
|
|
|
|
activeItems[itm] = demod_i;
|
2016-09-29 20:47:38 -04:00
|
|
|
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);
|
2016-09-14 22:10:27 -04:00
|
|
|
}
|
2016-09-13 22:59:21 -04:00
|
|
|
|
2016-09-14 22:10:27 -04:00
|
|
|
m_treeView->Enable();
|
|
|
|
m_treeView->ExpandAll();
|
2016-09-13 22:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onTreeBeginLabelEdit( wxTreeEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onTreeEndLabelEdit( wxTreeEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onTreeExpanded( wxTreeEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2016-09-28 20:37:39 -04:00
|
|
|
void BookmarkView::hideProps() {
|
|
|
|
m_frequencyLabel->Hide();
|
|
|
|
m_frequencyVal->Hide();
|
|
|
|
|
|
|
|
m_bandwidthLabel->Hide();
|
|
|
|
m_bandwidthVal->Hide();
|
|
|
|
|
|
|
|
m_modulationVal->Hide();
|
|
|
|
m_modulationLabel->Hide();
|
|
|
|
|
|
|
|
m_labelText->Hide();
|
|
|
|
m_labelLabel->Hide();
|
|
|
|
|
|
|
|
m_bookmarkButton->Hide();
|
|
|
|
m_activateButton->Hide();
|
|
|
|
m_removeButton->Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::activeSelection(DemodulatorInstance *dsel) {
|
|
|
|
activeSel = dsel;
|
|
|
|
|
|
|
|
m_frequencyVal->SetLabelText(frequencyToStr(dsel->getFrequency()));
|
|
|
|
m_bandwidthVal->SetLabelText(frequencyToStr(dsel->getBandwidth()));
|
|
|
|
m_modulationVal->SetLabelText(dsel->getDemodulatorType());
|
|
|
|
m_labelText->SetValue(dsel->getLabel());
|
|
|
|
|
|
|
|
hideProps();
|
|
|
|
|
|
|
|
m_frequencyVal->Show();
|
|
|
|
m_frequencyLabel->Show();
|
|
|
|
|
|
|
|
m_bandwidthVal->Show();
|
|
|
|
m_bandwidthLabel->Show();
|
|
|
|
|
|
|
|
m_modulationVal->Show();
|
|
|
|
m_modulationLabel->Show();
|
|
|
|
|
|
|
|
m_labelText->Show();
|
|
|
|
m_labelLabel->Show();
|
|
|
|
|
|
|
|
m_bookmarkButton->Show();
|
|
|
|
m_removeButton->Show();
|
|
|
|
|
|
|
|
this->Layout();
|
|
|
|
}
|
|
|
|
|
2016-09-13 22:59:21 -04:00
|
|
|
void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
|
2016-09-28 20:37:39 -04:00
|
|
|
if (activeItems.find(event.GetItem()) != activeItems.end()) {
|
|
|
|
DemodulatorInstance *dsel = activeItems[event.GetItem()];
|
|
|
|
m_propPanel->Show();
|
|
|
|
activeSelection(dsel);
|
|
|
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
|
|
|
} else {
|
|
|
|
activeSel = nullptr;
|
|
|
|
|
|
|
|
m_propPanel->Hide();
|
|
|
|
hideProps();
|
|
|
|
this->Layout();
|
|
|
|
|
|
|
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
|
|
|
event.Skip();
|
|
|
|
}
|
2016-09-13 22:59:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onTreeSelectChanging( wxTreeEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onLabelText( wxCommandEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2016-09-29 20:47:38 -04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-13 22:59:21 -04:00
|
|
|
void BookmarkView::onBookmark( wxCommandEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onActivate( wxCommandEvent& event ) {
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkView::onRemove( wxCommandEvent& event ) {
|
2016-09-28 20:37:39 -04:00
|
|
|
if (activeSel != nullptr) {
|
|
|
|
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, false);
|
|
|
|
wxGetApp().removeDemodulator(activeSel);
|
|
|
|
wxGetApp().getDemodMgr().deleteThread(activeSel);
|
|
|
|
activeSel = nullptr;
|
|
|
|
} else {
|
|
|
|
event.Skip();
|
|
|
|
}
|
2016-09-13 22:59:21 -04:00
|
|
|
}
|
|
|
|
|