comparison layer/FlexiNoteLayer.cpp @ 749:03423269a9d0 tonioni

Implement "Form Note from Selection"; remove Snap Notes to Pitch Track because every other editing operation *should* now be doing that automatically
author Chris Cannam
date Thu, 27 Mar 2014 18:12:38 +0000
parents 84e4cf889659
children 09e2677e34e7
comparison
equal deleted inserted replaced
748:84e4cf889659 749:03423269a9d0
1352 1352
1353 finish(command); 1353 finish(command);
1354 } 1354 }
1355 1355
1356 void 1356 void
1357 FlexiNoteLayer::mergeNotes(View *v, Selection s) 1357 FlexiNoteLayer::mergeNotes(View *v, Selection s, bool inclusive)
1358 { 1358 {
1359 FlexiNoteModel::PointList points = 1359 FlexiNoteModel::PointList points =
1360 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 1360 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
1361 1361
1362 FlexiNoteModel::PointList::iterator i = points.begin(); 1362 FlexiNoteModel::PointList::iterator i = points.begin();
1363 while (i != points.end() && i->frame + i->duration < s.getStartFrame()) { 1363 if (inclusive) {
1364 ++i; 1364 while (i != points.end() && i->frame + i->duration < s.getStartFrame()) {
1365 } 1365 ++i;
1366 }
1367 } else {
1368 while (i != points.end() && i->frame < s.getStartFrame()) {
1369 ++i;
1370 }
1371 }
1372
1366 if (i == points.end()) return; 1373 if (i == points.end()) return;
1367 1374
1368 FlexiNoteModel::EditCommand *command = 1375 FlexiNoteModel::EditCommand *command =
1369 new FlexiNoteModel::EditCommand(m_model, tr("Merge Notes")); 1376 new FlexiNoteModel::EditCommand(m_model, tr("Merge Notes"));
1370 1377
1371 FlexiNote newNote(*i); 1378 FlexiNote newNote(*i);
1372 1379
1373 while (i != points.end()) { 1380 while (i != points.end()) {
1374 1381
1375 if (i->frame >= s.getEndFrame()) break; 1382 if (inclusive) {
1383 if (i->frame >= s.getEndFrame()) break;
1384 } else {
1385 if (i->frame + i->duration > s.getEndFrame()) break;
1386 }
1376 1387
1377 newNote.duration = i->frame + i->duration - newNote.frame; 1388 newNote.duration = i->frame + i->duration - newNote.frame;
1378 command->deletePoint(*i); 1389 command->deletePoint(*i);
1379 1390
1380 ++i; 1391 ++i;