diff 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
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp	Thu Mar 27 18:02:12 2014 +0000
+++ b/layer/FlexiNoteLayer.cpp	Thu Mar 27 18:12:38 2014 +0000
@@ -1354,15 +1354,22 @@
 }
 
 void
-FlexiNoteLayer::mergeNotes(View *v, Selection s)
+FlexiNoteLayer::mergeNotes(View *v, Selection s, bool inclusive)
 {
     FlexiNoteModel::PointList points =
         m_model->getPoints(s.getStartFrame(), s.getEndFrame());
 
     FlexiNoteModel::PointList::iterator i = points.begin();
-    while (i != points.end() && i->frame + i->duration < s.getStartFrame()) {
-        ++i;
+    if (inclusive) {
+        while (i != points.end() && i->frame + i->duration < s.getStartFrame()) {
+            ++i;
+        }
+    } else {
+        while (i != points.end() && i->frame < s.getStartFrame()) {
+            ++i;
+        }
     }
+        
     if (i == points.end()) return;
 
     FlexiNoteModel::EditCommand *command = 
@@ -1372,7 +1379,11 @@
 
     while (i != points.end()) {
 
-        if (i->frame >= s.getEndFrame()) break;
+        if (inclusive) {
+            if (i->frame >= s.getEndFrame()) break;
+        } else {
+            if (i->frame + i->duration > s.getEndFrame()) break;
+        }
 
         newNote.duration = i->frame + i->duration - newNote.frame;
         command->deletePoint(*i);