changeset 279:47fe0352861e

* add pitch label to spectrogram harmonic cursor as well
author Chris Cannam
date Tue, 03 Jul 2007 18:56:27 +0000
parents a078aa2932cc
children 3c402c6052f6
files layer/SpectrogramLayer.cpp view/View.cpp
diffstat 2 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Tue Jul 03 18:47:39 2007 +0000
+++ b/layer/SpectrogramLayer.cpp	Tue Jul 03 18:56:27 2007 +0000
@@ -2467,10 +2467,15 @@
     int sw = getVerticalScaleWidth(v, paint);
 
     QRect label(sw, cursorPos.y() - paint.fontMetrics().ascent() - 2,
-                paint.fontMetrics().width("123456 Hz") + sw + 2,
+                paint.fontMetrics().width("123456 Hz") + 2,
                 paint.fontMetrics().height());
     extents.push_back(label);
 
+    QRect pitch(sw, cursorPos.y() + 2,
+                paint.fontMetrics().width("C#10+50c") + 2,
+                paint.fontMetrics().height());
+    extents.push_back(pitch);
+
     return true;
 }
 
@@ -2493,7 +2498,21 @@
                        QString("%1 Hz").arg(fundamental),
                        View::OutlinedText);
 
-    //!!! and pitch label
+    if (Pitch::isFrequencyInMidiRange(fundamental)) {
+        QString pitchLabel = Pitch::getPitchLabelForFrequency(fundamental);
+        v->drawVisibleText(paint,
+                           sw + 2,
+                           cursorPos.y() + paint.fontMetrics().ascent() + 2,
+                           pitchLabel,
+                           View::OutlinedText);
+    }
+
+    /*!!!
+    long frame = getFrameForX(cursorPos.x());
+    RealTime rt = RealTime::frame2RealTime(frame, m_model->getSampleRate());
+    QString timeLabel = rt.toText(true).c_str();
+    ...
+    */
 
     int harmonic = 2;
 
--- a/view/View.cpp	Tue Jul 03 18:47:39 2007 +0000
+++ b/view/View.cpp	Tue Jul 03 18:56:27 2007 +0000
@@ -620,6 +620,19 @@
 {
     if (style == OutlinedText) {
 
+        paint.save();
+
+        QColor penColour, surroundColour;
+
+        if (hasLightBackground()) {
+            penColour = Qt::black;
+            surroundColour = Qt::white;
+        } else {
+            penColour = Qt::white;
+            surroundColour = Qt::black;
+        }            
+
+/*
 	QColor origPenColour = paint.pen().color();
 	QColor penColour = origPenColour;
 	QColor surroundColour = Qt::white;  //palette().background().color();
@@ -630,7 +643,7 @@
 	    penColour = QColor::fromHsv(h, s, 255 - v);
 	    surroundColour = Qt::black;
 	}
-
+*/
 	paint.setPen(surroundColour);
 
 	for (int dx = -1; dx <= 1; ++dx) {
@@ -643,8 +656,10 @@
 	paint.setPen(penColour);
 
 	paint.drawText(x, y, text);
-
+/*
 	paint.setPen(origPenColour);
+*/
+        paint.restore();
 
     } else {