# HG changeset patch # User Chris Cannam # Date 1539249345 -3600 # Node ID dddfd28e4f020b2e7c3c42c531ae4c4d32f9062b # Parent b9bfcb8cd5a1bfded9bf83a00a4c5f00dbdff770 Fix ugly text positioning/drawing on osx diff -r b9bfcb8cd5a1 -r dddfd28e4f02 layer/TimeRulerLayer.cpp --- 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;