Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 753:09e2677e34e7 tonioni
Fix fancy note-editing mode (was not working in new multi-layer world, and shift-click delete was broken)
| author | Chris Cannam | 
|---|---|
| date | Tue, 01 Apr 2014 21:18:31 +0100 | 
| parents | 03423269a9d0 | 
| children | 6388ddae6ce3 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 752:f428bd852580 | 753:09e2677e34e7 | 
|---|---|
| 1041 | 1041 | 
| 1042 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; | 1042 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; | 
| 1043 m_originalPoint = FlexiNote(m_editingPoint); | 1043 m_originalPoint = FlexiNote(m_editingPoint); | 
| 1044 | 1044 | 
| 1045 if (m_editMode == RightBoundary) { | 1045 if (m_editMode == RightBoundary) { | 
| 1046 m_dragPointX = v->getXForFrame(m_editingPoint.frame + m_editingPoint.duration); | 1046 m_dragPointX = v->getXForFrame(m_editingPoint.frame + m_editingPoint.duration); | 
| 1047 } else { | 1047 } else { | 
| 1048 m_dragPointX = v->getXForFrame(m_editingPoint.frame); | 1048 m_dragPointX = v->getXForFrame(m_editingPoint.frame); | 
| 1049 } | 1049 } | 
| 1050 m_dragPointY = getYForValue(v, m_editingPoint.value); | 1050 m_dragPointY = getYForValue(v, m_editingPoint.value); | 
| 1051 | 1051 | 
| 1077 if (currentNote.frame > offset) { | 1077 if (currentNote.frame > offset) { | 
| 1078 m_smallestRightNeighbourFrame = currentNote.frame; | 1078 m_smallestRightNeighbourFrame = currentNote.frame; | 
| 1079 break; | 1079 break; | 
| 1080 } | 1080 } | 
| 1081 } | 1081 } | 
| 1082 std::cerr << "note frame: " << onset << ", left boundary: " << m_greatestLeftNeighbourFrame << ", right boundary: " << m_smallestRightNeighbourFrame << std::endl; | 1082 std::cerr << "editStart: mode is " << m_editMode << ", note frame: " << onset << ", left boundary: " << m_greatestLeftNeighbourFrame << ", right boundary: " << m_smallestRightNeighbourFrame << std::endl; | 
| 1083 } | 1083 } | 
| 1084 | 1084 | 
| 1085 void | 1085 void | 
| 1086 FlexiNoteLayer::editDrag(View *v, QMouseEvent *e) | 1086 FlexiNoteLayer::editDrag(View *v, QMouseEvent *e) | 
| 1087 { | 1087 { | 
| 1214 return; | 1214 return; | 
| 1215 } | 1215 } | 
| 1216 | 1216 | 
| 1217 long frame = v->getFrameForX(e->x()); | 1217 long frame = v->getFrameForX(e->x()); | 
| 1218 | 1218 | 
| 1219 splitNotesAt(v, frame); | 1219 splitNotesAt(v, frame, e); | 
| 1220 } | 1220 } | 
| 1221 | 1221 | 
| 1222 void | 1222 void | 
| 1223 FlexiNoteLayer::splitNotesAt(View *v, int frame) | 1223 FlexiNoteLayer::splitNotesAt(View *v, int frame) | 
| 1224 { | |
| 1225 splitNotesAt(v, frame, 0); | |
| 1226 } | |
| 1227 | |
| 1228 void | |
| 1229 FlexiNoteLayer::splitNotesAt(View *v, int frame, QMouseEvent *e) | |
| 1224 { | 1230 { | 
| 1225 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); | 1231 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); | 
| 1226 if (onPoints.empty()) return; | 1232 if (onPoints.empty()) return; | 
| 1227 | 1233 | 
| 1228 FlexiNote note(*onPoints.begin()); | 1234 FlexiNote note(*onPoints.begin()); | 
| 1229 | |
| 1230 int gap = 0; // MM: I prefer a gap of 0, but we can decide later | |
| 1231 | |
| 1232 FlexiNote newNote1(note.frame, note.value, | |
| 1233 frame - note.frame - gap, | |
| 1234 note.level, note.label); | |
| 1235 | |
| 1236 FlexiNote newNote2(frame, note.value, | |
| 1237 note.duration - newNote1.duration, | |
| 1238 note.level, note.label); | |
| 1239 | 1235 | 
| 1240 FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand | 1236 FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand | 
| 1241 (m_model, tr("Edit Point")); | 1237 (m_model, tr("Edit Point")); | 
| 1242 command->deletePoint(note); | 1238 command->deletePoint(note); | 
| 1239 | |
| 1240 if (!e || !(e->modifiers() & Qt::ShiftModifier)) { | |
| 1241 | |
| 1242 int gap = 0; // MM: I prefer a gap of 0, but we can decide later | |
| 1243 | |
| 1244 FlexiNote newNote1(note.frame, note.value, | |
| 1245 frame - note.frame - gap, | |
| 1246 note.level, note.label); | |
| 1247 | |
| 1248 FlexiNote newNote2(frame, note.value, | |
| 1249 note.duration - newNote1.duration, | |
| 1250 note.level, note.label); | |
| 1243 | 1251 | 
| 1244 if (m_intelligentActions) { | 1252 if (m_intelligentActions) { | 
| 1245 if (updateNoteValue(v, newNote1)) { | 1253 if (updateNoteValue(v, newNote1)) { | 
| 1254 command->addPoint(newNote1); | |
| 1255 } | |
| 1256 if (updateNoteValue(v, newNote2)) { | |
| 1257 command->addPoint(newNote2); | |
| 1258 } | |
| 1259 } else { | |
| 1246 command->addPoint(newNote1); | 1260 command->addPoint(newNote1); | 
| 1247 } | |
| 1248 if (updateNoteValue(v, newNote2)) { | |
| 1249 command->addPoint(newNote2); | 1261 command->addPoint(newNote2); | 
| 1250 } | 1262 } | 
| 1251 } else { | |
| 1252 command->addPoint(newNote1); | |
| 1253 command->addPoint(newNote2); | |
| 1254 } | 1263 } | 
| 1255 | 1264 | 
| 1256 finish(command); | 1265 finish(command); | 
| 1257 } | 1266 } | 
| 1258 | 1267 | 
