Mercurial > hg > svgui
changeset 1427:f792a5001d80 single-point
Update to use external set of commands
author | Chris Cannam |
---|---|
date | Fri, 15 Mar 2019 11:09:17 +0000 |
parents | e1a08da75427 |
children | c9fa16e41664 |
files | layer/FlexiNoteLayer.cpp layer/FlexiNoteLayer.h layer/NoteLayer.cpp layer/NoteLayer.h |
diffstat | 4 files changed, 37 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp Thu Mar 14 15:32:58 2019 +0000 +++ b/layer/FlexiNoteLayer.cpp Fri Mar 15 11:09:17 2019 +0000 @@ -53,16 +53,6 @@ FlexiNoteLayer::FlexiNoteLayer() : SingleColourLayer(), - - // m_model(0), - // m_editing(false), - // m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), - // m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), - // m_editingCommand(0), - // m_verticalScale(AutoAlignScale), - // m_scaleMinimum(0), - // m_scaleMaximum(0) - m_model(nullptr), m_editing(false), m_intelligentActions(true), @@ -945,7 +935,7 @@ m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); - m_editingCommand = new NoteModel::EditCommand(m_model, tr("Draw Point")); + m_editingCommand = new ChangeEventsCommand(m_model, tr("Draw Point")); m_editingCommand->add(m_editingPoint); m_editing = true; @@ -1022,10 +1012,8 @@ if (!getPointToDrag(v, e->x(), e->y(), p)) return; if (p.getFrame() != m_editingPoint.getFrame() || p.getValue() != m_editingPoint.getValue()) return; - m_editingCommand = new NoteModel::EditCommand(m_model, tr("Erase Point")); - + m_editingCommand = new ChangeEventsCommand(m_model, tr("Erase Point")); m_editingCommand->remove(m_editingPoint); - finish(m_editingCommand); m_editingCommand = nullptr; m_editing = false; @@ -1108,10 +1096,8 @@ double value = getValueForY(v, newy); if (!m_editingCommand) { - m_editingCommand = new NoteModel::EditCommand(m_model, - tr("Drag Point")); + m_editingCommand = new ChangeEventsCommand(m_model, tr("Drag Point")); } - m_editingCommand->remove(m_editingPoint); std::cerr << "edit mode: " << m_editMode << " intelligent actions = " @@ -1285,7 +1271,7 @@ Event note(*onPoints.begin()); - NoteModel::EditCommand *command = new NoteModel::EditCommand + ChangeEventsCommand *command = new ChangeEventsCommand (m_model, tr("Edit Point")); command->remove(note); @@ -1349,7 +1335,7 @@ if (!m_intelligentActions || (m_model->getEventsCovering(frame).empty() && duration > 0)) { Event newNote(frame, float(value), duration, 100.f, tr("new note")); - NoteModel::EditCommand *command = new NoteModel::EditCommand + ChangeEventsCommand *command = new ChangeEventsCommand (m_model, tr("Add Point")); command->add(newNote); finish(command); @@ -1389,7 +1375,7 @@ EventVector points = m_model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); - NoteModel::EditCommand *command = new NoteModel::EditCommand + ChangeEventsCommand *command = new ChangeEventsCommand (m_model, tr("Snap Notes")); cerr << "snapSelectedNotesToPitchTrack: selection is from " << s.getStartFrame() << " to " << s.getEndFrame() << endl; @@ -1432,8 +1418,8 @@ EventVector::iterator i = points.begin(); if (i == points.end()) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Merge Notes")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Merge Notes")); Event newNote(*i); @@ -1600,7 +1586,7 @@ .withDuration(dialog->getFrameDuration()) .withLabel(dialog->getText()); - NoteModel::EditCommand *command = new NoteModel::EditCommand + ChangeEventsCommand *command = new ChangeEventsCommand (m_model, tr("Edit Point")); command->remove(note); command->add(newNote); @@ -1616,8 +1602,8 @@ { if (!m_model) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Drag Selection")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Drag Selection")); EventVector points = m_model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); @@ -1637,8 +1623,8 @@ { if (!m_model || !s.getDuration()) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Resize Selection")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Resize Selection")); EventVector points = m_model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); @@ -1667,8 +1653,8 @@ { if (!m_model) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Delete Selected Points")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Delete Selected Points")); EventVector points = m_model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); @@ -1685,8 +1671,8 @@ { if (!m_model) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Delete Selected Points")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Delete Selected Points")); EventVector points = m_model->getEventsSpanning(s.getStartFrame(), s.getDuration()); @@ -1737,8 +1723,8 @@ } } - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Paste")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Paste")); for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -1807,7 +1793,7 @@ m_pendingNoteOns.erase(i); Event note = p.withDuration(frame - p.getFrame()); if (m_model) { - NoteModel::EditCommand *c = new NoteModel::EditCommand + ChangeEventsCommand *c = new ChangeEventsCommand (m_model, tr("Record Note")); c->add(note); // execute and bundle:
--- a/layer/FlexiNoteLayer.h Thu Mar 14 15:32:58 2019 +0000 +++ b/layer/FlexiNoteLayer.h Fri Mar 15 11:09:17 2019 +0000 @@ -191,7 +191,7 @@ Event m_editingPoint; sv_frame_t m_greatestLeftNeighbourFrame; sv_frame_t m_smallestRightNeighbourFrame; - NoteModel::EditCommand *m_editingCommand; + ChangeEventsCommand *m_editingCommand; VerticalScale m_verticalScale; EditMode m_editMode; @@ -203,7 +203,7 @@ bool shouldAutoAlign() const; - void finish(NoteModel::EditCommand *command) { + void finish(ChangeEventsCommand *command) { Command *c = command->finish(); if (c) CommandHistory::getInstance()->addCommand(c, false); }
--- a/layer/NoteLayer.cpp Thu Mar 14 15:32:58 2019 +0000 +++ b/layer/NoteLayer.cpp Fri Mar 15 11:09:17 2019 +0000 @@ -881,7 +881,7 @@ m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); - m_editingCommand = new NoteModel::EditCommand(m_model, tr("Draw Point")); + m_editingCommand = new ChangeEventsCommand(m_model, tr("Draw Point")); m_editingCommand->add(m_editingPoint); m_editing = true; @@ -959,7 +959,7 @@ if (p.getFrame() != m_editingPoint.getFrame() || p.getValue() != m_editingPoint.getValue()) return; - m_editingCommand = new NoteModel::EditCommand(m_model, tr("Erase Point")); + m_editingCommand = new ChangeEventsCommand(m_model, tr("Erase Point")); m_editingCommand->remove(m_editingPoint); @@ -1010,7 +1010,7 @@ double value = getValueForY(v, newy); if (!m_editingCommand) { - m_editingCommand = new NoteModel::EditCommand(m_model, + m_editingCommand = new ChangeEventsCommand(m_model, tr("Drag Point")); } @@ -1083,7 +1083,7 @@ .withDuration(dialog->getFrameDuration()) .withLabel(dialog->getText()); - NoteModel::EditCommand *command = new NoteModel::EditCommand + ChangeEventsCommand *command = new ChangeEventsCommand (m_model, tr("Edit Point")); command->remove(note); command->add(newNote); @@ -1102,8 +1102,8 @@ { if (!m_model) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Drag Selection")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Drag Selection")); EventVector points = m_model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); @@ -1123,8 +1123,8 @@ { if (!m_model || !s.getDuration()) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Resize Selection")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Resize Selection")); EventVector points = m_model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); @@ -1153,8 +1153,8 @@ { if (!m_model) return; - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Delete Selected Points")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Delete Selected Points")); EventVector points = m_model->getEventsStartingWithin(s.getStartFrame(), s.getDuration()); @@ -1206,8 +1206,8 @@ } } - NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Paste")); + ChangeEventsCommand *command = + new ChangeEventsCommand(m_model, tr("Paste")); for (EventVector::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -1277,7 +1277,7 @@ m_pendingNoteOns.erase(i); Event note = p.withDuration(frame - p.getFrame()); if (m_model) { - NoteModel::EditCommand *c = new NoteModel::EditCommand + ChangeEventsCommand *c = new ChangeEventsCommand (m_model, tr("Record Note")); c->add(note); // execute and bundle:
--- a/layer/NoteLayer.h Thu Mar 14 15:32:58 2019 +0000 +++ b/layer/NoteLayer.h Fri Mar 15 11:09:17 2019 +0000 @@ -154,7 +154,7 @@ int m_dragStartY; Event m_originalPoint; Event m_editingPoint; - NoteModel::EditCommand *m_editingCommand; + ChangeEventsCommand *m_editingCommand; bool m_editIsOpen; VerticalScale m_verticalScale; @@ -166,7 +166,7 @@ bool shouldAutoAlign() const; - void finish(NoteModel::EditCommand *command) { + void finish(ChangeEventsCommand *command) { Command *c = command->finish(); if (c) CommandHistory::getInstance()->addCommand(c, false); }