# HG changeset patch # User matthiasm # Date 1371678977 -3600 # Node ID ac26de7b727a5539a50fc69433be24d632f5cef3 # Parent 902c7c9d77eaef3363711b7871b140aaec632097 re-did, and improved the moving constraints diff -r 902c7c9d77ea -r ac26de7b727a layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Wed Jun 19 22:05:45 2013 +0100 +++ b/layer/FlexiNoteLayer.cpp Wed Jun 19 22:56:17 2013 +0100 @@ -1002,9 +1002,9 @@ int newx = m_dragPointX + xdist; int newy = m_dragPointY + ydist; - long frame = v->getFrameForX(newx); - if (frame < 0) frame = 0; - frame = frame / m_model->getResolution() * m_model->getResolution(); + long dragFrame = v->getFrameForX(newx); + if (dragFrame < 0) dragFrame = 0; + dragFrame = dragFrame / m_model->getResolution() * m_model->getResolution(); float value = getValueForY(v, newy); @@ -1016,28 +1016,34 @@ m_editingCommand->deletePoint(m_editingPoint); std::cerr << "edit mode: " << m_editMode << std::endl; + switch (m_editMode) { case LeftBoundary : { - if ((frame > m_greatestLeftNeighbourFrame) - && (frame < m_originalPoint.frame + m_originalPoint.duration - 1) - && (frame < m_smallestRightNeighbourFrame)) { - m_editingPoint.duration = m_editingPoint.frame + m_editingPoint.duration - frame + 1; - m_editingPoint.frame = frame; + // left + if (dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; + // right + if (dragFrame >= m_originalPoint.frame + m_originalPoint.duration) { + dragFrame = m_originalPoint.frame + m_originalPoint.duration - 1; } + m_editingPoint.frame = dragFrame; + m_editingPoint.duration = m_originalPoint.frame - dragFrame + m_originalPoint.duration; break; } case RightBoundary : { - long tempDuration = frame - m_originalPoint.frame; - if (tempDuration > 0 && m_originalPoint.frame + tempDuration - 1 < m_smallestRightNeighbourFrame) { - m_editingPoint.duration = tempDuration; - } + // left + if (dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; + if (dragFrame >= m_smallestRightNeighbourFrame) dragFrame = m_smallestRightNeighbourFrame - 1; + m_editingPoint.duration = dragFrame - m_originalPoint.frame + 1; break; } case DragNote : { - if (frame <= m_smallestRightNeighbourFrame - m_editingPoint.duration - && frame > m_greatestLeftNeighbourFrame) { - m_editingPoint.frame = frame; // only move if it doesn't overlap with right note or left note + // left + if (dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; + // right + if (dragFrame + m_originalPoint.duration >= m_smallestRightNeighbourFrame) { + dragFrame = m_smallestRightNeighbourFrame - m_originalPoint.duration; } + m_editingPoint.frame = dragFrame; m_editingPoint.value = value; break; }