diff widgets/Pane.cpp @ 99:453f7da3534e

* Fix serious failure to reload "imported" (i.e. all non-derived non-main) models from .sv file * Give a short playback duration to notes with formal duration of 0 or 1 * Show crosshairs on spectrogram even when there is another layer on top (if it isn't opaque) * Always paste to the same time in the layer as the cut/copy was from, rather than to the playback pointer -- less flexible, but more predictable and less annoying. We probably need a way to get the old behaviour if pasting from somewhere else in the future (e.g. from a text file), but we can't do that yet anyway * Use a compound operation for dragging and resizing selections, so as to ensure a single undo operation works * Use a note model as the target for feature extraction plugins that output variable samplerate data with more than one value per feature * Avoid possible crashes in cut/paste if a layer proves to have no model
author Chris Cannam
date Thu, 11 May 2006 11:35:46 +0000
parents 803830f186ef
children 0f36cdf407a6
line wrap: on
line diff
--- a/widgets/Pane.cpp	Wed May 10 16:34:03 2006 +0000
+++ b/widgets/Pane.cpp	Thu May 11 11:35:46 2006 +0000
@@ -20,6 +20,7 @@
 #include "base/RealTime.h"
 #include "base/Profiler.h"
 #include "base/ViewManager.h"
+#include "base/CommandHistory.h"
 #include "layer/WaveformLayer.h"
 
 #include <QPaintEvent>
@@ -144,24 +145,31 @@
     int fontHeight = paint.fontMetrics().height();
     int fontAscent = paint.fontMetrics().ascent();
 
-    for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
-        --vi;
-            
-        if (dynamic_cast<WaveformLayer *>(*vi)) {
-            waveformModel = (*vi)->getModel();
-        }
+    if (m_manager &&
+        !m_manager->isPlaying() &&
+        m_manager->getToolMode() == ViewManager::SelectMode) {
 
-        if (m_manager &&
-            !m_manager->isPlaying() &&
-            m_manager->getToolMode() == ViewManager::SelectMode) {
+        for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
+            --vi;
 
             std::vector<QRect> crosshairExtents;
 
             if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint,
                                            crosshairExtents)) {
                 (*vi)->paintCrosshairs(this, paint, m_identifyPoint);
+                break;
+            } else if ((*vi)->isLayerOpaque()) {
+                break;
             }
         }
+    }
+
+    for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
+        --vi;
+            
+        if (dynamic_cast<WaveformLayer *>(*vi)) {
+            waveformModel = (*vi)->getModel();
+        }
 
         if (!m_manager ||
             m_manager->getOverlayMode() == ViewManager::NoOverlays) {
@@ -972,10 +980,16 @@
     
     if (m_editingSelectionEdge == 0) {
 	
+        CommandHistory::getInstance()->startCompoundOperation
+            (tr("Drag Selection"), true);
+
 	layer->moveSelection(m_editingSelection, f0);
 	
     } else {
 	
+        CommandHistory::getInstance()->startCompoundOperation
+            (tr("Resize Selection"), true);
+
 	if (m_editingSelectionEdge < 0) {
 	    f1 = m_editingSelection.getEndFrame();
 	} else {
@@ -989,6 +1003,8 @@
     m_manager->removeSelection(m_editingSelection);
     m_manager->addSelection(newSelection);
 
+    CommandHistory::getInstance()->endCompoundOperation();
+
     m_editingSelection = Selection();
     return true;
 }