diff view/Pane.cpp @ 1389:1eb560b363e7 spectrogramparam

Make "zoom to region" work sensibly for slice/spectrum layers; ensure that min/max bin are remapped properly when changing fft size
author Chris Cannam
date Tue, 13 Nov 2018 14:06:48 +0000
parents 81dda64a7edc
children 3c99083a4d83
line wrap: on
line diff
--- a/view/Pane.cpp	Tue Nov 13 13:39:01 2018 +0000
+++ b/view/Pane.cpp	Tue Nov 13 14:06:48 2018 +0000
@@ -27,6 +27,7 @@
 #include "layer/WaveformLayer.h"
 #include "layer/TimeRulerLayer.h"
 #include "layer/PaintAssistant.h"
+#include "ViewProxy.h"
 
 // GF: added so we can propagate the mouse move event to the note layer for context handling.
 #include "layer/LayerFactory.h"
@@ -1822,6 +1823,18 @@
     int x1 = r.x() + r.width();
     int y1 = r.y() + r.height();
 
+    SVDEBUG << "Pane::zoomToRegion: region defined by pixel rect ("
+            << r.x() << "," << r.y() << "), " << r.width() << "x" << r.height()
+            << endl;
+
+    Layer *interactionLayer = getInteractionLayer();
+    if (interactionLayer && !(interactionLayer->hasTimeXAxis())) {
+        SVDEBUG << "Interaction layer does not have time X axis - delegating to it to decide what to do" << endl;
+        ViewProxy proxy(this, effectiveDevicePixelRatio());
+        interactionLayer->zoomToRegion(&proxy, r);
+        return;
+    }
+    
     sv_frame_t newStartFrame = getFrameForX(x0);
     sv_frame_t newEndFrame = getFrameForX(x1);
     sv_frame_t dist = newEndFrame - newStartFrame;