diff layer/TimeRulerLayer.cpp @ 1374:631897ba9fca zoom

Merge from default branch
author Chris Cannam
date Tue, 06 Nov 2018 08:59:03 +0000
parents dddfd28e4f02
children c39f2d439d59
line wrap: on
line diff
--- a/layer/TimeRulerLayer.cpp	Fri Oct 05 10:25:52 2018 +0100
+++ b/layer/TimeRulerLayer.cpp	Tue Nov 06 08:59:03 2018 +0000
@@ -154,8 +154,12 @@
 
     sv_frame_t startFrame = v->getStartFrame();
     sv_frame_t endFrame = v->getEndFrame();
+    if (endFrame == startFrame) {
+        endFrame = startFrame + 1;
+    }
 
-    int minPixelSpacing = ViewManager::scalePixelSize(50);
+    int exampleWidth = QFontMetrics(QFont()).width("10:42.987654");
+    int minPixelSpacing = v->getXForViewX(exampleWidth);
 
     RealTime rtStart = RealTime::frame2RealTime(startFrame, sampleRate);
     RealTime rtEnd = RealTime::frame2RealTime(endFrame, sampleRate);
@@ -164,6 +168,15 @@
     if (count < 1) count = 1;
     RealTime rtGap = (rtEnd - rtStart) / count;
 
+#ifdef DEBUG_TIME_RULER_LAYER
+    SVCERR << "zoomLevel = " << v->getZoomLevel()
+           << ", startFrame = " << startFrame << ", endFrame = " << endFrame
+           << ", rtStart = " << rtStart << ", rtEnd = " << rtEnd
+           << ", paint width = " << v->getPaintWidth()
+           << ", minPixelSpacing = " << minPixelSpacing
+           << ", count = " << count << ", rtGap = " << rtGap << endl;
+#endif
+
     int64_t incus;
     quarterTicks = false;
 
@@ -197,6 +210,10 @@
         if (us > 0) { incus *= 2; us /= 2; }
     }
 
+#ifdef DEBUG_TIME_RULER_LAYER
+    SVCERR << "getMajorTickUSec: returning incus = " << incus << endl;
+#endif
+
     return incus;
 }
 
@@ -277,7 +294,7 @@
     // We always use the exact incus in our calculations for where to
     // draw the actual ticks or lines.
 
-    int minPixelSpacing = 50;
+    int minPixelSpacing = v->getXForViewX(50);
     sv_frame_t incFrame = lrint((double(incus) * sampleRate) / 1000000);
     int incX = int(round(v->getZoomLevel().framesToPixels(double(incFrame))));
     int ticks = 10;