# HG changeset patch # User Chris Cannam # Date 1538134272 -3600 # Node ID 3fa8cdbf362c967eac59475d4098b2249839d1f9 # Parent 13d03ae0c6e028e3aab11e1a2c71cd99ab083d91 Use more precise text rendering when zoomed in beyond the ms level diff -r 13d03ae0c6e0 -r 3fa8cdbf362c layer/TimeRulerLayer.cpp --- a/layer/TimeRulerLayer.cpp Fri Sep 28 09:12:54 2018 +0100 +++ b/layer/TimeRulerLayer.cpp Fri Sep 28 12:31:12 2018 +0100 @@ -19,6 +19,7 @@ #include "data/model/Model.h" #include "base/RealTime.h" +#include "base/Preferences.h" #include "view/View.h" #include "ColourDatabase.h" @@ -263,6 +264,15 @@ cerr << "start us = " << us << " at step " << incus << endl; #endif + Preferences *prefs = Preferences::getInstance(); + auto origTimeTextMode = prefs->getTimeToTextMode(); + if (incus < 1000) { + // Temporarily switch to usec display mode (if we aren't using + // it already) + prefs->blockSignals(true); + prefs->setTimeToTextMode(Preferences::TimeToTextUs); + } + // Calculate the number of ticks per increment -- approximate // values for x and frame counts here will do, no rounding issue. // We always use the exact incus in our calculations for where to @@ -311,6 +321,7 @@ #endif QString text(QString::fromStdString(rt.toText())); + QFontMetrics metrics = paint.fontMetrics(); int tw = metrics.width(text); @@ -389,6 +400,9 @@ us += incus; } + + prefs->setTimeToTextMode(origTimeTextMode); + prefs->blockSignals(false); paint.restore(); }