Mercurial > hg > tony
comparison src/MainWindow.cpp @ 240:6ac45eb0f4c7
Implement "Form Note from Selection"; remove Snap Notes to Pitch Track because every other editing operation *should* now be doing that automatically
author | Chris Cannam |
---|---|
date | Thu, 27 Mar 2014 18:12:38 +0000 |
parents | d40c6cdb30a4 |
children | 69e6ceb459cd |
comparison
equal
deleted
inserted
replaced
239:d40c6cdb30a4 | 240:6ac45eb0f4c7 |
---|---|
589 m_rightButtonMenu->addAction(action); | 589 m_rightButtonMenu->addAction(action); |
590 | 590 |
591 menu->addSeparator(); | 591 menu->addSeparator(); |
592 m_rightButtonMenu->addSeparator(); | 592 m_rightButtonMenu->addSeparator(); |
593 | 593 |
594 action = new QAction(tr("Split Notes at Selection Boundaries"), this); | 594 action = new QAction(tr("Split Note"), this); |
595 action->setShortcut(tr("Ctrl+/")); | 595 action->setShortcut(tr("Ctrl+/")); |
596 action->setStatusTip(tr("If any notes overlap the start or end of the selected region, split them at those points")); | 596 action->setStatusTip(tr("Split the note at the current playback position into two")); |
597 m_keyReference->registerShortcut(action); | 597 m_keyReference->registerShortcut(action); |
598 connect(action, SIGNAL(triggered()), this, SLOT(splitNotesAtSelection())); | 598 connect(action, SIGNAL(triggered()), this, SLOT(splitNote())); |
599 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | 599 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool))); |
600 menu->addAction(action); | 600 menu->addAction(action); |
601 m_rightButtonMenu->addAction(action); | 601 m_rightButtonMenu->addAction(action); |
602 | 602 |
603 action = new QAction(tr("Merge Notes"), this); | 603 action = new QAction(tr("Merge Notes"), this); |
604 action->setShortcut(tr("Ctrl+.")); | |
605 action->setStatusTip(tr("Merge all notes within the selected region into a single note")); | 604 action->setStatusTip(tr("Merge all notes within the selected region into a single note")); |
606 m_keyReference->registerShortcut(action); | 605 m_keyReference->registerShortcut(action); |
607 connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes())); | 606 connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes())); |
608 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | 607 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); |
609 menu->addAction(action); | 608 menu->addAction(action); |
610 m_rightButtonMenu->addAction(action); | 609 m_rightButtonMenu->addAction(action); |
611 | 610 |
611 action = new QAction(tr("Form Note from Selection"), this); | |
612 action->setStatusTip(tr("Form a note spanning the selected region, splitting any existing notes at its boundaries")); | |
613 m_keyReference->registerShortcut(action); | |
614 connect(action, SIGNAL(triggered()), this, SLOT(formNoteFromSelection())); | |
615 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | |
616 menu->addAction(action); | |
617 m_rightButtonMenu->addAction(action); | |
618 /* | |
612 action = new QAction(tr("Snap Notes to Pitch Track"), this); | 619 action = new QAction(tr("Snap Notes to Pitch Track"), this); |
613 action->setShortcut(tr("Ctrl+=")); | 620 action->setShortcut(tr("Ctrl+=")); |
614 action->setStatusTip(tr("Set notes within the selected region to the median frequency of their underlying pitches, or remove them if there are no underlying pitches")); | 621 action->setStatusTip(tr("Set notes within the selected region to the median frequency of their underlying pitches, or remove them if there are no underlying pitches")); |
615 m_keyReference->registerShortcut(action); | 622 m_keyReference->registerShortcut(action); |
616 connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches())); | 623 connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches())); |
617 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); | 624 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool))); |
618 menu->addAction(action); | 625 menu->addAction(action); |
619 m_rightButtonMenu->addAction(action); | 626 m_rightButtonMenu->addAction(action); |
620 | 627 */ |
621 } | 628 } |
622 | 629 |
623 void | 630 void |
624 MainWindow::setupViewMenu() | 631 MainWindow::setupViewMenu() |
625 { | 632 { |
2095 | 2102 |
2096 layer->snapSelectedNotesToPitchTrack(m_analyser->getPane(), s); | 2103 layer->snapSelectedNotesToPitchTrack(m_analyser->getPane(), s); |
2097 } | 2104 } |
2098 | 2105 |
2099 void | 2106 void |
2100 MainWindow::splitNotesAtSelection() | 2107 MainWindow::splitNote() |
2101 { | 2108 { |
2102 FlexiNoteLayer *layer = | 2109 FlexiNoteLayer *layer = |
2103 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes)); | 2110 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes)); |
2104 if (!layer) return; | 2111 if (!layer) return; |
2105 | 2112 |
2113 layer->splitNotesAt(m_analyser->getPane(), m_viewManager->getPlaybackFrame()); | |
2114 } | |
2115 | |
2116 void | |
2117 MainWindow::mergeNotes() | |
2118 { | |
2119 FlexiNoteLayer *layer = | |
2120 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes)); | |
2121 if (!layer) return; | |
2122 | |
2106 MultiSelection::SelectionList selections = m_viewManager->getSelections(); | 2123 MultiSelection::SelectionList selections = m_viewManager->getSelections(); |
2107 | 2124 |
2108 if (!selections.empty()) { | 2125 if (!selections.empty()) { |
2109 | 2126 |
2110 CommandHistory::getInstance()->startCompoundOperation | 2127 CommandHistory::getInstance()->startCompoundOperation |
2111 (tr("Split Notes at Selection Boundaries"), true); | 2128 (tr("Merge Notes"), true); |
2129 | |
2130 for (MultiSelection::SelectionList::iterator k = selections.begin(); | |
2131 k != selections.end(); ++k) { | |
2132 layer->mergeNotes(m_analyser->getPane(), *k, true); | |
2133 } | |
2134 | |
2135 CommandHistory::getInstance()->endCompoundOperation(); | |
2136 } | |
2137 } | |
2138 | |
2139 void | |
2140 MainWindow::formNoteFromSelection() | |
2141 { | |
2142 FlexiNoteLayer *layer = | |
2143 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes)); | |
2144 if (!layer) return; | |
2145 | |
2146 MultiSelection::SelectionList selections = m_viewManager->getSelections(); | |
2147 | |
2148 if (!selections.empty()) { | |
2149 | |
2150 CommandHistory::getInstance()->startCompoundOperation | |
2151 (tr("Form Note from Selection"), true); | |
2112 | 2152 |
2113 for (MultiSelection::SelectionList::iterator k = selections.begin(); | 2153 for (MultiSelection::SelectionList::iterator k = selections.begin(); |
2114 k != selections.end(); ++k) { | 2154 k != selections.end(); ++k) { |
2115 layer->splitNotesAt(m_analyser->getPane(), k->getStartFrame()); | 2155 layer->splitNotesAt(m_analyser->getPane(), k->getStartFrame()); |
2116 layer->splitNotesAt(m_analyser->getPane(), k->getEndFrame()); | 2156 layer->splitNotesAt(m_analyser->getPane(), k->getEndFrame()); |
2157 layer->mergeNotes(m_analyser->getPane(), *k, false); | |
2117 } | 2158 } |
2118 | 2159 |
2119 CommandHistory::getInstance()->endCompoundOperation(); | |
2120 } | |
2121 } | |
2122 | |
2123 void | |
2124 MainWindow::mergeNotes() | |
2125 { | |
2126 FlexiNoteLayer *layer = | |
2127 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes)); | |
2128 if (!layer) return; | |
2129 | |
2130 MultiSelection::SelectionList selections = m_viewManager->getSelections(); | |
2131 | |
2132 if (!selections.empty()) { | |
2133 | |
2134 CommandHistory::getInstance()->startCompoundOperation | |
2135 (tr("Merge Notes"), true); | |
2136 | |
2137 for (MultiSelection::SelectionList::iterator k = selections.begin(); | |
2138 k != selections.end(); ++k) { | |
2139 layer->mergeNotes(m_analyser->getPane(), *k); | |
2140 } | |
2141 | |
2142 CommandHistory::getInstance()->endCompoundOperation(); | 2160 CommandHistory::getInstance()->endCompoundOperation(); |
2143 } | 2161 } |
2144 } | 2162 } |
2145 | 2163 |
2146 void | 2164 void |