Skip to content

Commit

Permalink
Fixes for #635, round 1: BookmarkView
Browse files Browse the repository at this point in the history
  • Loading branch information
vsonnier committed Mar 20, 2018
1 parent 876b477 commit 225a795
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 122 deletions.
2 changes: 1 addition & 1 deletion src/CubicSDR.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class CubicSDR: public wxApp {
DemodulatorThreadOutputQueuePtr getAudioVisualQueue();
DemodulatorThreadInputQueuePtr getIQVisualQueue();
DemodulatorThreadInputQueuePtr getWaterfallVisualQueue();
DemodulatorThreadInputQueuePtr getActiveDemodVisualQueue();

DemodulatorMgr &getDemodMgr();
BookmarkMgr &getBookmarkMgr();

Expand Down
134 changes: 13 additions & 121 deletions src/forms/Bookmark/BookmarkView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void BookmarkView::onUpdateTimer( wxTimerEvent& /* event */ ) {
if (bmSel) {
m_treeView->SelectItem(bmSel);
}
doUpdateBookmarks.store(false);
doUpdateBookmarks.store(false);
}
}

Expand Down Expand Up @@ -517,10 +517,6 @@ void BookmarkView::doUpdateActiveList() {

void BookmarkView::onTreeActivate( wxTreeEvent& event ) {

if (skipUserEvents()) {
return;
}

wxTreeItemId itm = event.GetItem();
TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));

Expand Down Expand Up @@ -615,10 +611,6 @@ void BookmarkView::onTreeExpanded( wxTreeEvent& event ) {

void BookmarkView::onTreeItemMenu( wxTreeEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

if (m_treeView->GetSelection() == bookmarkBranch) {
wxMenu menu;
menu.Append(wxCONTEXT_ADD_GROUP_ID, BOOKMARK_VIEW_STR_ADD_GROUP);
Expand All @@ -630,10 +622,6 @@ void BookmarkView::onTreeItemMenu( wxTreeEvent& /* event */ ) {

void BookmarkView::onMenuItem(wxCommandEvent& event) {

if (skipUserEvents()) {
return;
}

if (event.GetId() == wxCONTEXT_ADD_GROUP_ID) {
onAddGroup(event);
}
Expand Down Expand Up @@ -711,10 +699,13 @@ wxButton *BookmarkView::makeButton(wxWindow *parent, std::string labelVal, wxObj
nButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, handler, nullptr, this);

wxColour bgColor(ThemeMgr::mgr.currentTheme->generalBackground);
wxColour textColor(ThemeMgr::mgr.currentTheme->text);
// wxColour fgColor(ThemeMgr::mgr.currentTheme->button);
//Force white color:
wxColour textColorWhite(RGBA4f(255,255,255));

nButton->SetBackgroundColour(bgColor);
nButton->SetForegroundColour(textColor);
nButton->SetForegroundColour(textColorWhite);

return nButton;
}

Expand Down Expand Up @@ -790,11 +781,7 @@ void BookmarkView::addBookmarkChoice(wxWindow *parent) {


void BookmarkView::onBookmarkChoice( wxCommandEvent & /* event */ ) {

if (skipUserEvents()) {
return;
}


TreeViewItem *tvi = itemToTVI(m_treeView->GetSelection());

int numSel = bookmarkChoice->GetCount();
Expand Down Expand Up @@ -855,15 +842,16 @@ void BookmarkView::activeSelection(DemodulatorInstancePtr dsel) {

addBookmarkChoice(m_buttonPanel);

if (dsel->isActive() && !(dsel->isRecording())) {
addButton(m_buttonPanel, "Start Recording", wxCommandEventHandler( BookmarkView::onStartRecording ));
} else {
addButton(m_buttonPanel, "Stop Recording", wxCommandEventHandler( BookmarkView::onStopRecording ));
if (dsel->isActive()) {
if (!(dsel->isRecording())) {
addButton(m_buttonPanel, "Start Recording", wxCommandEventHandler(BookmarkView::onStartRecording));
} else {
addButton(m_buttonPanel, "Stop Recording", wxCommandEventHandler(BookmarkView::onStopRecording));
}
}

addButton(m_buttonPanel, "Remove Active", wxCommandEventHandler( BookmarkView::onRemoveActive ));


showProps();
showButtons();
refreshLayout();
Expand Down Expand Up @@ -1086,10 +1074,6 @@ void BookmarkView::activeBranchSelection() {

void BookmarkView::onTreeSelect( wxTreeEvent& event ) {

if (skipUserEvents()) {
return;
}

wxTreeItemId itm = event.GetItem();
TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));

Expand Down Expand Up @@ -1145,10 +1129,6 @@ void BookmarkView::onTreeSelectChanging( wxTreeEvent& event ) {

void BookmarkView::onLabelText( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

std::wstring newLabel = m_labelText->GetValue().ToStdWstring();
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

Expand Down Expand Up @@ -1182,10 +1162,6 @@ void BookmarkView::onLabelText( wxCommandEvent& /* event */ ) {

void BookmarkView::onDoubleClickFreq( wxMouseEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
Expand All @@ -1198,10 +1174,6 @@ void BookmarkView::onDoubleClickFreq( wxMouseEvent& /* event */ ) {

void BookmarkView::onDoubleClickBandwidth( wxMouseEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
Expand All @@ -1214,10 +1186,6 @@ void BookmarkView::onDoubleClickBandwidth( wxMouseEvent& /* event */ ) {

void BookmarkView::onRemoveActive( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
Expand All @@ -1230,10 +1198,6 @@ void BookmarkView::onRemoveActive( wxCommandEvent& /* event */ ) {

void BookmarkView::onStartRecording( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
Expand All @@ -1247,10 +1211,6 @@ void BookmarkView::onStartRecording( wxCommandEvent& /* event */ ) {

void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
Expand All @@ -1265,10 +1225,6 @@ void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {

void BookmarkView::onRemoveBookmark( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

if (editingLabel) {
return;
}
Expand All @@ -1283,10 +1239,6 @@ void BookmarkView::onRemoveBookmark( wxCommandEvent& /* event */ ) {

void BookmarkView::onActivateBookmark( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
Expand All @@ -1297,10 +1249,6 @@ void BookmarkView::onActivateBookmark( wxCommandEvent& /* event */ ) {

void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
Expand All @@ -1317,10 +1265,6 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {

void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

if (editingLabel) {
return;
}
Expand All @@ -1339,10 +1283,6 @@ void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) {

void BookmarkView::onClearRecents ( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

if (editingLabel) {
return;
}
Expand All @@ -1352,10 +1292,6 @@ void BookmarkView::onClearRecents ( wxCommandEvent& /* event */ ) {

void BookmarkView::onAddGroup( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

wxString stringVal = wxGetTextFromUser(BOOKMARK_VIEW_STR_ADD_GROUP_DESC, BOOKMARK_VIEW_STR_ADD_GROUP, "");
if (stringVal.ToStdString() != "") {
wxGetApp().getBookmarkMgr().addGroup(stringVal.ToStdString());
Expand All @@ -1366,10 +1302,6 @@ void BookmarkView::onAddGroup( wxCommandEvent& /* event */ ) {

void BookmarkView::onRemoveGroup( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

if (editingLabel) {
return;
}
Expand All @@ -1383,10 +1315,6 @@ void BookmarkView::onRemoveGroup( wxCommandEvent& /* event */ ) {


void BookmarkView::onAddRange( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

BookmarkRangeEntryPtr re = BookmarkView::makeActiveRangeEntry();

Expand All @@ -1399,10 +1327,6 @@ void BookmarkView::onAddRange( wxCommandEvent& /* event */ ) {

void BookmarkView::onRemoveRange( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

if (editingLabel) {
return;
}
Expand All @@ -1417,10 +1341,6 @@ void BookmarkView::onRemoveRange( wxCommandEvent& /* event */ ) {

void BookmarkView::onRenameRange( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (!curSel || curSel->type != TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
Expand All @@ -1440,10 +1360,6 @@ void BookmarkView::onRenameRange( wxCommandEvent& /* event */ ) {

void BookmarkView::onActivateRange( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
Expand All @@ -1453,10 +1369,6 @@ void BookmarkView::onActivateRange( wxCommandEvent& /* event */ ) {

void BookmarkView::onUpdateRange( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());

if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
Expand All @@ -1466,10 +1378,6 @@ void BookmarkView::onUpdateRange( wxCommandEvent& /* event */ ) {

void BookmarkView::onTreeBeginDrag( wxTreeEvent& event ) {

if (skipUserEvents()) {
return;
}

TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(event.GetItem()));

dragItem = nullptr;
Expand Down Expand Up @@ -1514,10 +1422,6 @@ void BookmarkView::onTreeBeginDrag( wxTreeEvent& event ) {


void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) {

if (skipUserEvents()) {
return;
}

wxColour bgColor(ThemeMgr::mgr.currentTheme->generalBackground);
wxColour textColor(ThemeMgr::mgr.currentTheme->text);
Expand Down Expand Up @@ -1635,10 +1539,6 @@ TreeViewItem *BookmarkView::itemToTVI(wxTreeItemId item) {

void BookmarkView::onSearchTextFocus( wxMouseEvent& event ) {

if (skipUserEvents()) {
return;
}

mouseTracker.OnMouseMoved(event);

//apparently needed ???
Expand All @@ -1664,10 +1564,6 @@ void BookmarkView::onSearchTextFocus( wxMouseEvent& event ) {

void BookmarkView::onSearchText( wxCommandEvent& event ) {

if (skipUserEvents()) {
return;
}

std::wstring searchText = m_searchText->GetValue().Trim().Lower().ToStdWstring();

searchKeywords.clear();
Expand Down Expand Up @@ -1699,10 +1595,6 @@ void BookmarkView::onSearchText( wxCommandEvent& event ) {

void BookmarkView::onClearSearch( wxCommandEvent& /* event */ ) {

if (skipUserEvents()) {
return;
}

m_clearSearchButton->Hide();
m_searchText->SetValue(L"Search..");
m_treeView->SetFocus();
Expand Down

0 comments on commit 225a795

Please sign in to comment.