Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 1470:696e569ff21b by-id
Further layer updates for ById
| author | Chris Cannam |
|---|---|
| date | Fri, 28 Jun 2019 17:37:22 +0100 |
| parents | 11a150e65ee1 |
| children | f2525e6cbdf1 |
comparison
equal
deleted
inserted
replaced
| 1469:11a150e65ee1 | 1470:696e569ff21b |
|---|---|
| 959 | 959 |
| 960 m_editingPoint = Event(frame, float(value), 0, 0.8f, tr("New Point")); | 960 m_editingPoint = Event(frame, float(value), 0, 0.8f, tr("New Point")); |
| 961 m_originalPoint = m_editingPoint; | 961 m_originalPoint = m_editingPoint; |
| 962 | 962 |
| 963 if (m_editingCommand) finish(m_editingCommand); | 963 if (m_editingCommand) finish(m_editingCommand); |
| 964 m_editingCommand = new ChangeEventsCommand<Model>(m_model, tr("Draw Point")); | 964 m_editingCommand = new ChangeEventsCommand(m_model.untyped, tr("Draw Point")); |
| 965 m_editingCommand->add(m_editingPoint); | 965 m_editingCommand->add(m_editingPoint); |
| 966 | 966 |
| 967 m_editing = true; | 967 m_editing = true; |
| 968 } | 968 } |
| 969 | 969 |
| 1039 Event p(0); | 1039 Event p(0); |
| 1040 if (!getPointToDrag(v, e->x(), e->y(), p)) return; | 1040 if (!getPointToDrag(v, e->x(), e->y(), p)) return; |
| 1041 if (p.getFrame() != m_editingPoint.getFrame() || | 1041 if (p.getFrame() != m_editingPoint.getFrame() || |
| 1042 p.getValue() != m_editingPoint.getValue()) return; | 1042 p.getValue() != m_editingPoint.getValue()) return; |
| 1043 | 1043 |
| 1044 m_editingCommand = new ChangeEventsCommand<Model>(m_model, tr("Erase Point")); | 1044 m_editingCommand = new ChangeEventsCommand(m_model.untyped, tr("Erase Point")); |
| 1045 m_editingCommand->remove(m_editingPoint); | 1045 m_editingCommand->remove(m_editingPoint); |
| 1046 finish(m_editingCommand); | 1046 finish(m_editingCommand); |
| 1047 m_editingCommand = nullptr; | 1047 m_editingCommand = nullptr; |
| 1048 m_editing = false; | 1048 m_editing = false; |
| 1049 } | 1049 } |
| 1126 | 1126 |
| 1127 double value = getValueForY(v, newy); | 1127 double value = getValueForY(v, newy); |
| 1128 | 1128 |
| 1129 if (!m_editingCommand) { | 1129 if (!m_editingCommand) { |
| 1130 m_editingCommand = | 1130 m_editingCommand = |
| 1131 new ChangeEventsCommand<Model>(m_model, tr("Drag Point")); | 1131 new ChangeEventsCommand(m_model.untyped, tr("Drag Point")); |
| 1132 } | 1132 } |
| 1133 m_editingCommand->remove(m_editingPoint); | 1133 m_editingCommand->remove(m_editingPoint); |
| 1134 | 1134 |
| 1135 std::cerr << "edit mode: " << m_editMode << " intelligent actions = " | 1135 std::cerr << "edit mode: " << m_editMode << " intelligent actions = " |
| 1136 << m_intelligentActions << std::endl; | 1136 << m_intelligentActions << std::endl; |
| 1308 EventVector onPoints = model->getEventsCovering(frame); | 1308 EventVector onPoints = model->getEventsCovering(frame); |
| 1309 if (onPoints.empty()) return; | 1309 if (onPoints.empty()) return; |
| 1310 | 1310 |
| 1311 Event note(*onPoints.begin()); | 1311 Event note(*onPoints.begin()); |
| 1312 | 1312 |
| 1313 auto command = new ChangeEventsCommand<Model>(m_model, tr("Edit Point")); | 1313 auto command = new ChangeEventsCommand(m_model.untyped, tr("Edit Point")); |
| 1314 command->remove(note); | 1314 command->remove(note); |
| 1315 | 1315 |
| 1316 if (!e || !(e->modifiers() & Qt::ShiftModifier)) { | 1316 if (!e || !(e->modifiers() & Qt::ShiftModifier)) { |
| 1317 | 1317 |
| 1318 int gap = 0; // MM: I prefer a gap of 0, but we can decide later | 1318 int gap = 0; // MM: I prefer a gap of 0, but we can decide later |
| 1372 } | 1372 } |
| 1373 | 1373 |
| 1374 if (!m_intelligentActions || | 1374 if (!m_intelligentActions || |
| 1375 (model->getEventsCovering(frame).empty() && duration > 0)) { | 1375 (model->getEventsCovering(frame).empty() && duration > 0)) { |
| 1376 Event newNote(frame, float(value), duration, 100.f, tr("new note")); | 1376 Event newNote(frame, float(value), duration, 100.f, tr("new note")); |
| 1377 auto command = new ChangeEventsCommand<Model>(m_model, tr("Add Point")); | 1377 auto command = new ChangeEventsCommand(m_model.untyped, tr("Add Point")); |
| 1378 command->add(newNote); | 1378 command->add(newNote); |
| 1379 finish(command); | 1379 finish(command); |
| 1380 } | 1380 } |
| 1381 } | 1381 } |
| 1382 | 1382 |
| 1411 if (!model) return; | 1411 if (!model) return; |
| 1412 | 1412 |
| 1413 EventVector points = | 1413 EventVector points = |
| 1414 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); | 1414 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); |
| 1415 | 1415 |
| 1416 auto command = new ChangeEventsCommand<Model>(m_model, tr("Snap Notes")); | 1416 auto command = new ChangeEventsCommand(m_model.untyped, tr("Snap Notes")); |
| 1417 | 1417 |
| 1418 cerr << "snapSelectedNotesToPitchTrack: selection is from " << s.getStartFrame() << " to " << s.getEndFrame() << endl; | 1418 cerr << "snapSelectedNotesToPitchTrack: selection is from " << s.getStartFrame() << " to " << s.getEndFrame() << endl; |
| 1419 | 1419 |
| 1420 for (EventVector::iterator i = points.begin(); | 1420 for (EventVector::iterator i = points.begin(); |
| 1421 i != points.end(); ++i) { | 1421 i != points.end(); ++i) { |
| 1456 } | 1456 } |
| 1457 | 1457 |
| 1458 EventVector::iterator i = points.begin(); | 1458 EventVector::iterator i = points.begin(); |
| 1459 if (i == points.end()) return; | 1459 if (i == points.end()) return; |
| 1460 | 1460 |
| 1461 auto command = new ChangeEventsCommand<Model>(m_model, tr("Merge Notes")); | 1461 auto command = new ChangeEventsCommand(m_model.untyped, tr("Merge Notes")); |
| 1462 | 1462 |
| 1463 Event newNote(*i); | 1463 Event newNote(*i); |
| 1464 | 1464 |
| 1465 while (i != points.end()) { | 1465 while (i != points.end()) { |
| 1466 | 1466 |
| 1621 .withFrame(dialog->getFrameTime()) | 1621 .withFrame(dialog->getFrameTime()) |
| 1622 .withValue(dialog->getValue()) | 1622 .withValue(dialog->getValue()) |
| 1623 .withDuration(dialog->getFrameDuration()) | 1623 .withDuration(dialog->getFrameDuration()) |
| 1624 .withLabel(dialog->getText()); | 1624 .withLabel(dialog->getText()); |
| 1625 | 1625 |
| 1626 auto command = new ChangeEventsCommand<Model>(m_model, tr("Edit Point")); | 1626 auto command = new ChangeEventsCommand(m_model.untyped, tr("Edit Point")); |
| 1627 command->remove(note); | 1627 command->remove(note); |
| 1628 command->add(newNote); | 1628 command->add(newNote); |
| 1629 finish(command); | 1629 finish(command); |
| 1630 } | 1630 } |
| 1631 | 1631 |
| 1637 FlexiNoteLayer::moveSelection(Selection s, sv_frame_t newStartFrame) | 1637 FlexiNoteLayer::moveSelection(Selection s, sv_frame_t newStartFrame) |
| 1638 { | 1638 { |
| 1639 auto model = ModelById::getAs<NoteModel>(m_model); | 1639 auto model = ModelById::getAs<NoteModel>(m_model); |
| 1640 if (!model) return; | 1640 if (!model) return; |
| 1641 | 1641 |
| 1642 auto command = new ChangeEventsCommand<Model>(m_model, tr("Drag Selection")); | 1642 auto command = new ChangeEventsCommand(m_model.untyped, tr("Drag Selection")); |
| 1643 | 1643 |
| 1644 EventVector points = | 1644 EventVector points = |
| 1645 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); | 1645 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); |
| 1646 | 1646 |
| 1647 for (Event p: points) { | 1647 for (Event p: points) { |
| 1658 FlexiNoteLayer::resizeSelection(Selection s, Selection newSize) | 1658 FlexiNoteLayer::resizeSelection(Selection s, Selection newSize) |
| 1659 { | 1659 { |
| 1660 auto model = ModelById::getAs<NoteModel>(m_model); | 1660 auto model = ModelById::getAs<NoteModel>(m_model); |
| 1661 if (!model || !s.getDuration()) return; | 1661 if (!model || !s.getDuration()) return; |
| 1662 | 1662 |
| 1663 auto command = new ChangeEventsCommand<Model>(m_model, tr("Resize Selection")); | 1663 auto command = new ChangeEventsCommand(m_model.untyped, tr("Resize Selection")); |
| 1664 | 1664 |
| 1665 EventVector points = | 1665 EventVector points = |
| 1666 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); | 1666 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); |
| 1667 | 1667 |
| 1668 double ratio = double(newSize.getDuration()) / double(s.getDuration()); | 1668 double ratio = double(newSize.getDuration()) / double(s.getDuration()); |
| 1689 { | 1689 { |
| 1690 auto model = ModelById::getAs<NoteModel>(m_model); | 1690 auto model = ModelById::getAs<NoteModel>(m_model); |
| 1691 if (!model) return; | 1691 if (!model) return; |
| 1692 | 1692 |
| 1693 auto command = | 1693 auto command = |
| 1694 new ChangeEventsCommand<Model>(m_model, tr("Delete Selected Points")); | 1694 new ChangeEventsCommand(m_model.untyped, tr("Delete Selected Points")); |
| 1695 | 1695 |
| 1696 EventVector points = | 1696 EventVector points = |
| 1697 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); | 1697 model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); |
| 1698 | 1698 |
| 1699 for (Event p: points) { | 1699 for (Event p: points) { |
| 1708 { | 1708 { |
| 1709 auto model = ModelById::getAs<NoteModel>(m_model); | 1709 auto model = ModelById::getAs<NoteModel>(m_model); |
| 1710 if (!model) return; | 1710 if (!model) return; |
| 1711 | 1711 |
| 1712 auto command = | 1712 auto command = |
| 1713 new ChangeEventsCommand<Model>(m_model, tr("Delete Selected Points")); | 1713 new ChangeEventsCommand(m_model.untyped, tr("Delete Selected Points")); |
| 1714 | 1714 |
| 1715 EventVector points = | 1715 EventVector points = |
| 1716 model->getEventsSpanning(s.getStartFrame(), s.getDuration()); | 1716 model->getEventsSpanning(s.getStartFrame(), s.getDuration()); |
| 1717 | 1717 |
| 1718 for (Event p: points) { | 1718 for (Event p: points) { |
| 1761 if (button == QMessageBox::Yes) { | 1761 if (button == QMessageBox::Yes) { |
| 1762 realign = true; | 1762 realign = true; |
| 1763 } | 1763 } |
| 1764 } | 1764 } |
| 1765 | 1765 |
| 1766 auto command = new ChangeEventsCommand<Model>(m_model, tr("Paste")); | 1766 auto command = new ChangeEventsCommand(m_model.untyped, tr("Paste")); |
| 1767 | 1767 |
| 1768 for (EventVector::const_iterator i = points.begin(); | 1768 for (EventVector::const_iterator i = points.begin(); |
| 1769 i != points.end(); ++i) { | 1769 i != points.end(); ++i) { |
| 1770 | 1770 |
| 1771 sv_frame_t frame = 0; | 1771 sv_frame_t frame = 0; |
| 1829 Event p = *i; | 1829 Event p = *i; |
| 1830 | 1830 |
| 1831 if (lrintf(p.getValue()) == pitch) { | 1831 if (lrintf(p.getValue()) == pitch) { |
| 1832 m_pendingNoteOns.erase(i); | 1832 m_pendingNoteOns.erase(i); |
| 1833 Event note = p.withDuration(frame - p.getFrame()); | 1833 Event note = p.withDuration(frame - p.getFrame()); |
| 1834 auto c = new ChangeEventsCommand<Model> | 1834 auto c = new ChangeEventsCommand |
| 1835 (m_model, tr("Record Note")); | 1835 (m_model.untyped, tr("Record Note")); |
| 1836 c->add(note); | 1836 c->add(note); |
| 1837 // execute and bundle: | 1837 // execute and bundle: |
| 1838 CommandHistory::getInstance()->addCommand(c, true, true); | 1838 CommandHistory::getInstance()->addCommand(c, true, true); |
| 1839 break; | 1839 break; |
| 1840 } | 1840 } |
