diff main/MainWindow.cpp @ 761:956134fa9f24

If current pane has the main model in it as a waveform, use that for the pan layer even if it isn't the top layer in the pane
author Chris Cannam
date Wed, 13 Aug 2014 16:18:25 +0100
parents 5b4206f7d7d4
children 902756b8d8b1
line wrap: on
line diff
--- a/main/MainWindow.cpp	Wed Aug 13 16:10:36 2014 +0100
+++ b/main/MainWindow.cpp	Wed Aug 13 16:18:25 2014 +0100
@@ -3880,6 +3880,29 @@
     MainWindowBase::currentPaneChanged(pane);
 
     if (!pane || !m_panLayer) return;
+
+    // If this pane contains the main model, it usually makes sense to
+    // show the main model in the pan layer even if it isn't the top
+    // layer in the pane (e.g. if the top layer is one derived from
+    // the main model).
+    bool containsMainModel = false;
+    for (int i = pane->getLayerCount(); i > 0; ) {
+        --i;
+        Layer *layer = pane->getLayer(i);
+        if (layer &&
+            LayerFactory::getInstance()->getLayerType(layer) ==
+            LayerFactory::Waveform &&
+            layer->getModel() == getMainModel()) {
+            containsMainModel = true;
+            break;
+        }
+    }
+
+    if (containsMainModel) {
+        m_panLayer->setModel(getMainModel());
+        return;
+    }
+
     for (int i = pane->getLayerCount(); i > 0; ) {
         --i;
         Layer *layer = pane->getLayer(i);