changeset 1356:dddfd28e4f02

Fix ugly text positioning/drawing on osx
author Chris Cannam
date Thu, 11 Oct 2018 10:15:45 +0100
parents b9bfcb8cd5a1
children 93eaff6f206d
files layer/TimeRulerLayer.cpp
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/layer/TimeRulerLayer.cpp	Wed Oct 10 14:50:47 2018 +0100
+++ b/layer/TimeRulerLayer.cpp	Thu Oct 11 10:15:45 2018 +0100
@@ -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;