diff view/Pane.cpp @ 577:dc511d5fee75

* Display distance the selection has been dragged by, when moving it with the edit tool
author Chris Cannam
date Fri, 04 Feb 2011 14:30:51 +0000
parents c2ba2796cbee
children 1fe7951a61e8
line wrap: on
line diff
--- a/view/Pane.cpp	Mon Oct 25 21:52:38 2010 +0200
+++ b/view/Pane.cpp	Fri Feb 04 14:30:51 2011 +0000
@@ -917,17 +917,55 @@
 Pane::drawEditingSelection(QPainter &paint)
 {
     int offset = m_mousePos.x() - m_clickPos.x();
-    int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
+
+    long origStart = m_editingSelection.getStartFrame();
+
+    int p0 = getXForFrame(origStart) + offset;
     int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
-    
+
     if (m_editingSelectionEdge < 0) {
         p1 = getXForFrame(m_editingSelection.getEndFrame());
     } else if (m_editingSelectionEdge > 0) {
         p0 = getXForFrame(m_editingSelection.getStartFrame());
     }
     
+    long newStart = getFrameForX(p0);
+    long newEnd = getFrameForX(p1);
+    
     paint.save();
     paint.setPen(QPen(getForeground(), 2));
+
+    int fontHeight = paint.fontMetrics().height();
+    int fontAscent = paint.fontMetrics().ascent();
+    int sampleRate = getModelsSampleRate();
+    QString startText, endText, offsetText;
+    startText = QString("%1").arg(newStart);
+    endText = QString("%1").arg(newEnd);
+    offsetText = QString("%1").arg(newStart - origStart);
+    if (newStart >= origStart) {
+        offsetText = tr("+%1").arg(offsetText);
+    }
+    if (sampleRate) {
+        startText = QString("%1 / %2")
+            .arg(QString::fromStdString
+                 (RealTime::frame2RealTime(newStart, sampleRate).toText()))
+            .arg(startText);
+        endText = QString("%1 / %2")
+            .arg(QString::fromStdString
+                 (RealTime::frame2RealTime(newEnd, sampleRate).toText()))
+            .arg(endText);
+        offsetText = QString("%1 / %2")
+            .arg(QString::fromStdString
+                 (RealTime::frame2RealTime(newStart - origStart, sampleRate).toText()))
+            .arg(offsetText);
+        if (newStart >= origStart) {
+            offsetText = tr("+%1").arg(offsetText);
+        }
+    }
+    drawVisibleText(paint, p0 + 2, fontAscent + fontHeight + 4, startText, OutlinedText);
+    drawVisibleText(paint, p1 + 2, fontAscent + fontHeight + 4, endText, OutlinedText);
+    drawVisibleText(paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText);
+    drawVisibleText(paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText);
     
     //!!! duplicating display policy with View::drawSelections