comparison src/MainWindow.cpp @ 281:2a18f846dd6c

implemented move by one note (replacing big jumps left/right)
author matthiasm
date Thu, 22 May 2014 17:49:58 +0100
parents 2c19b0537bd2
children 118775decf28
comparison
equal deleted inserted replaced
280:3fe77ed06eba 281:2a18f846dd6c
654 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates())); 654 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates()));
655 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool))); 655 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool)));
656 menu->addAction(m_showCandidatesAction); 656 menu->addAction(m_showCandidatesAction);
657 m_rightButtonMenu->addAction(m_showCandidatesAction); 657 m_rightButtonMenu->addAction(m_showCandidatesAction);
658 658
659 action = new QAction(tr("Remove Pitches"), this); 659
660 action->setShortcut(tr("Ctrl+Backspace")); 660 // action = new QAction(tr("Remove Pitches"), this);
661 action = toolbar->addAction(il.load("navigate"), tr("Navigate"));
662 action->setShortcut(tr("Backspace"));
661 action->setStatusTip(tr("Remove all pitch estimates within the selected region, making it unvoiced")); 663 action->setStatusTip(tr("Remove all pitch estimates within the selected region, making it unvoiced"));
662 m_keyReference->registerShortcut(action); 664 m_keyReference->registerShortcut(action);
663 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches())); 665 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches()));
664 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool))); 666 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
665 menu->addAction(action); 667 menu->addAction(action);
731 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight())); 733 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
732 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 734 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
733 m_keyReference->registerShortcut(action); 735 m_keyReference->registerShortcut(action);
734 menu->addAction(action); 736 menu->addAction(action);
735 737
736 action = new QAction(tr("&Jump Left"), this); 738 action = new QAction(tr("&One Note Left"), this);
737 action->setShortcut(tr("Ctrl+Left")); 739 action->setShortcut(tr("Ctrl+Left"));
738 action->setStatusTip(tr("Scroll the current pane a big step to the left")); 740 action->setStatusTip(tr("Move cursor to the preceding note (or silence) onset."));
739 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft())); 741 connect(action, SIGNAL(triggered()), this, SLOT(moveOneNoteLeft()));
740 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 742 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
741 m_keyReference->registerShortcut(action); 743 m_keyReference->registerShortcut(action);
742 menu->addAction(action); 744 menu->addAction(action);
743 745
744 action = new QAction(tr("J&ump Right"), this); 746 action = new QAction(tr("O&ne Note Right"), this);
745 action->setShortcut(tr("Ctrl+Right")); 747 action->setShortcut(tr("Ctrl+Right"));
746 action->setStatusTip(tr("Scroll the current pane a big step to the right")); 748 action->setStatusTip(tr("Move cursor to the succeeding note (or silence)."));
747 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight())); 749 connect(action, SIGNAL(triggered()), this, SLOT(moveOneNoteRight()));
748 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); 750 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
749 m_keyReference->registerShortcut(action); 751 m_keyReference->registerShortcut(action);
750 menu->addAction(action); 752 menu->addAction(action);
751 753
752 menu->addSeparator(); 754 menu->addSeparator();
1117 m_showSpect->setCheckable(true); 1119 m_showSpect->setCheckable(true);
1118 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled())); 1120 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
1119 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool))); 1121 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
1120 1122
1121 Pane::registerShortcuts(*m_keyReference); 1123 Pane::registerShortcuts(*m_keyReference);
1124 }
1125
1126
1127 void
1128 MainWindow::moveOneNoteRight()
1129 {
1130 // cerr << "MainWindow::moveOneNoteRight" << endl;
1131 moveByOneNote(true);
1132 }
1133
1134 void
1135 MainWindow::moveOneNoteLeft()
1136 {
1137 // cerr << "MainWindow::moveOneNoteLeft" << endl;
1138 moveByOneNote(false);
1139 }
1140
1141 void
1142 MainWindow::moveByOneNote(bool right)
1143 {
1144 // cerr << "MainWindow::moveByOneNote" << endl;
1145 int frame = m_viewManager->getPlaybackFrame();
1146
1147 Pane *p = m_analyser->getPane();
1148
1149 Layer *layer = m_analyser->getLayer(Analyser::Notes);
1150 if (!layer) return;
1151
1152 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
1153 if (!model) return;
1154
1155 FlexiNoteModel::PointList points = model->getPoints();
1156 if (points.empty()) return;
1157
1158 FlexiNoteModel::PointList::iterator i = points.begin();
1159 std::set<int> snapFrames;
1160 snapFrames.insert(0);
1161 while (i != points.end()) {
1162 snapFrames.insert(i->frame);
1163 snapFrames.insert(i->frame + i->duration + 1);
1164 ++i;
1165 }
1166 std::set<int>::iterator i2;
1167 if (snapFrames.find(frame) == snapFrames.end())
1168 {
1169 // we're not on an existing snap point, so go to previous
1170 snapFrames.insert(frame);
1171 }
1172 i2 = snapFrames.find(frame);
1173 if (right)
1174 {
1175 i2++;
1176 if (i2 == snapFrames.end()) i2--;
1177 } else {
1178 if (i2 != snapFrames.begin()) i2--;
1179 }
1180 frame = *i2;
1181 m_viewManager->setPlaybackFrame(frame);
1122 } 1182 }
1123 1183
1124 void 1184 void
1125 MainWindow::toolNavigateSelected() 1185 MainWindow::toolNavigateSelected()
1126 { 1186 {