diff view/Pane.cpp @ 277:8acd30ed735c

* Fix up and simplify the LayerTreeModel, removing a horrible memory leak * Move phase-unwrapped frequency estimation from SpectrogramLayer to FFTDataServer * Make the spectrum show peak phase-unwrapped frequencies as well (still needs work) * Start adding piano keyboard horizontal scale to spectrum * Debug output for id3 tags
author Chris Cannam
date Tue, 03 Jul 2007 12:46:18 +0000
parents 21c7152ddba8
children 3c402c6052f6
line wrap: on
line diff
--- a/view/Pane.cpp	Mon Jul 02 14:58:34 2007 +0000
+++ b/view/Pane.cpp	Tue Jul 03 12:46:18 2007 +0000
@@ -397,14 +397,18 @@
     }
 
     Layer *topLayer = getTopLayer();
+    bool haveSomeTimeXAxis = false;
 
     const Model *waveformModel = 0; // just for reporting purposes
     for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
         --vi;
+        if (!haveSomeTimeXAxis && (*vi)->hasTimeXAxis()) {
+            haveSomeTimeXAxis = true;
+        }
         if (dynamic_cast<WaveformLayer *>(*vi)) {
             waveformModel = (*vi)->getModel();
-            break;
         }
+        if (waveformModel && haveSomeTimeXAxis) break;
     }
 
     m_scaleWidth = 0;
@@ -423,7 +427,7 @@
     if (m_centreLineVisible &&
         m_manager &&
         m_manager->shouldShowCentreLine()) {
-        drawCentreLine(sampleRate, paint);
+        drawCentreLine(sampleRate, paint, !haveSomeTimeXAxis);
     }
     
     paint.setPen(QColor(50, 50, 50));
@@ -628,7 +632,7 @@
 }
 
 void
-Pane::drawCentreLine(int sampleRate, QPainter &paint)
+Pane::drawCentreLine(int sampleRate, QPainter &paint, bool omitLine)
 {
     int fontHeight = paint.fontMetrics().height();
     int fontAscent = paint.fontMetrics().ascent();
@@ -637,13 +641,17 @@
     if (!hasLightBackground()) {
         c = QColor(240, 240, 240);
     }
+
     paint.setPen(c);
     int x = width() / 2;
-    paint.drawLine(x, 0, x, height() - 1);
-    paint.drawLine(x-1, 1, x+1, 1);
-    paint.drawLine(x-2, 0, x+2, 0);
-    paint.drawLine(x-1, height() - 2, x+1, height() - 2);
-    paint.drawLine(x-2, height() - 1, x+2, height() - 1);
+
+    if (!omitLine) {
+        paint.drawLine(x, 0, x, height() - 1);
+        paint.drawLine(x-1, 1, x+1, 1);
+        paint.drawLine(x-2, 0, x+2, 0);
+        paint.drawLine(x-1, height() - 2, x+1, height() - 2);
+        paint.drawLine(x-2, height() - 1, x+2, height() - 1);
+    }
     
     paint.setPen(QColor(50, 50, 50));