changeset 1345:3fa8cdbf362c zoom

Use more precise text rendering when zoomed in beyond the ms level
author Chris Cannam
date Fri, 28 Sep 2018 12:31:12 +0100
parents 13d03ae0c6e0
children 4c28e3302045
files layer/TimeRulerLayer.cpp
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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();
 }