diff layer/TimeInstantLayer.cpp @ 335:2f83b6e3b8ca

* Add Erase tool and mode * Add icons for Normalize buttons in property boxes, and for Show Peaks * Add support for velocity in notes -- not yet reflected in display or editable in the note edit dialog, but they are imported from MIDI, played, and exported * Begin work on making pastes align pasted times (subtler than I thought)
author Chris Cannam
date Fri, 23 Nov 2007 16:48:23 +0000
parents 984c1975f1ff
children bff85425228c 0895517bb2d1
line wrap: on
line diff
--- a/layer/TimeInstantLayer.cpp	Thu Nov 22 14:27:41 2007 +0000
+++ b/layer/TimeInstantLayer.cpp	Fri Nov 23 16:48:23 2007 +0000
@@ -493,6 +493,50 @@
 }
 
 void
+TimeInstantLayer::eraseStart(View *v, QMouseEvent *e)
+{
+    if (!m_model) return;
+
+    SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
+    if (points.empty()) return;
+
+    m_editingPoint = *points.begin();
+
+    if (m_editingCommand) {
+	m_editingCommand->finish();
+	m_editingCommand = 0;
+    }
+
+    m_editing = true;
+}
+
+void
+TimeInstantLayer::eraseDrag(View *v, QMouseEvent *e)
+{
+}
+
+void
+TimeInstantLayer::eraseEnd(View *v, QMouseEvent *e)
+{
+    if (!m_model || !m_editing) return;
+
+    m_editing = false;
+
+    SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
+    if (points.empty()) return;
+    if (points.begin()->frame != m_editingPoint.frame) return;
+
+    m_editingCommand = new SparseOneDimensionalModel::EditCommand
+        (m_model, tr("Erase Point"));
+
+    m_editingCommand->deletePoint(m_editingPoint);
+
+    m_editingCommand->finish();
+    m_editingCommand = 0;
+    m_editing = false;
+}
+
+void
 TimeInstantLayer::editStart(View *v, QMouseEvent *e)
 {
     std::cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << std::endl;
@@ -678,6 +722,7 @@
 	 i != points.end(); ++i) {
 	if (s.contains(i->frame)) {
             Clipboard::Point point(i->frame, i->label);
+            point.setReferenceFrame(m_model->alignToReference(i->frame));
             to.addPoint(point);
         }
     }
@@ -693,6 +738,19 @@
     SparseOneDimensionalModel::EditCommand *command =
 	new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste"));
 
+    //!!!
+    
+    // Clipboard::haveReferenceFrames() will return true if any of the
+    // items in the clipboard came from an aligned, non-reference model.
+    
+    // We need to know whether these points came from our model or not
+    // -- if they did, we don't want to align them.
+
+    // If they didn't come from our model, and if reference frames are
+    // available, then we want to offer to align them.  If reference
+    // frames are unavailable but they came from the reference model,
+    // we want to offer to align them too.
+
     for (Clipboard::PointList::const_iterator i = points.begin();
          i != points.end(); ++i) {