Mercurial > hg > svgui
diff layer/FlexiNoteLayer.cpp @ 635:5c9dcec5f3e9 tonioni
splitting notes works but major cleanup needed
author | gyorgyf |
---|---|
date | Sat, 20 Apr 2013 08:38:37 +0100 |
parents | 4fa3951bbb05 |
children | ba76130ed7e5 |
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp Fri Apr 19 15:37:27 2013 +0100 +++ b/layer/FlexiNoteLayer.cpp Sat Apr 20 08:38:37 2013 +0100 @@ -625,13 +625,13 @@ max = Pitch::getFrequencyForPitch(lrintf(max + 1)); } - std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; + // std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; } else if (log) { LogRange::mapRange(min, max); - std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; + // std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; } @@ -908,6 +908,7 @@ FlexiNoteLayer::editStart(View *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; + std::cerr << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl; if (!m_model) return; @@ -931,6 +932,7 @@ FlexiNoteLayer::editDrag(View *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; + std::cerr << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << std::endl; if (!m_model || !m_editing) return; @@ -957,9 +959,11 @@ } void -FlexiNoteLayer::editEnd(View *, QMouseEvent *) +FlexiNoteLayer::editEnd(View *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; + std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; + if (!m_model || !m_editing) return; if (m_editingCommand) { @@ -984,6 +988,71 @@ m_editing = false; } +void +FlexiNoteLayer::splitStart(View *v, QMouseEvent *e) +{ + std::cerr << "splitStart" << std::endl; + if (!m_model) return; + + if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; + // m_originalPoint = m_editingPoint; + // + // m_dragPointX = v->getXForFrame(m_editingPoint.frame); + // m_dragPointY = getYForValue(v, m_editingPoint.value); + + if (m_editingCommand) { + finish(m_editingCommand); + m_editingCommand = 0; + } + + m_editing = true; + m_dragStartX = e->x(); + m_dragStartY = e->y(); + +} + +void +FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) +{ + std::cerr << "splitEnd" << std::endl; + if (!m_model || !m_editing) return; + + int xdist = e->x() - m_dragStartX; + int ydist = e->y() - m_dragStartY; + if (xdist != 0 || ydist != 0) { + std::cerr << "mouse moved" << std::endl; + return; + } + + FlexiNoteModel::Point note(0); + if (!getPointToDrag(v, e->x(), e->y(), note)) return; + + long frame = v->getFrameForX(e->x()); + + FlexiNoteModel::Point newNote1 = note; + newNote1.frame = note.frame; + newNote1.value = note.value; + // newNote1.duration = note.duration+10000; + newNote1.duration = frame - note.frame - 100; + newNote1.label = note.label; + + FlexiNoteModel::Point newNote2 = note; + newNote2.frame = frame + 100; + newNote2.value = note.value; + newNote2.duration = note.duration - (frame - note.frame - 100); + newNote2.label = note.label; + + + FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand + (m_model, tr("Edit Point")); + command->deletePoint(note); + command->addPoint(newNote1); + command->addPoint(newNote2); + finish(command); + +} + + bool FlexiNoteLayer::editOpen(View *v, QMouseEvent *e) {