diff layer/TimeValueLayer.cpp @ 701:084f65094203

Extend numerical and colour scales (and piano where applicable) to note and region layers
author Chris Cannam
date Wed, 04 Dec 2013 13:39:41 +0000
parents 7846175403f1
children ceb9a2992d96 88a16eed3338
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp	Wed Dec 04 13:12:09 2013 +0000
+++ b/layer/TimeValueLayer.cpp	Wed Dec 04 13:39:41 2013 +0000
@@ -28,6 +28,7 @@
 
 #include "widgets/ItemEditDialog.h"
 #include "widgets/ListInputDialog.h"
+#include "widgets/TextAbbrev.h"
 
 #include "ColourMapper.h"
 #include "PianoScale.h"
@@ -1209,8 +1210,9 @@
 int
 TimeValueLayer::getVerticalScaleWidth(View *v, bool, QPainter &paint) const
 {
-    if (!m_model || shouldAutoAlign()) return 0;
-    if (m_plotStyle == PlotSegmentation) {
+    if (!m_model || shouldAutoAlign()) {
+        return 0;
+    } else if (m_plotStyle == PlotSegmentation) {
         if (m_verticalScale == LogScale) {
             return LogColourScale().getWidth(v, paint);
         } else {
@@ -1268,8 +1270,12 @@
     }
         
     if (getScaleUnits() != "") {
-        paint.drawText(5, 5 + paint.fontMetrics().ascent(),
-                       getScaleUnits());
+        int mw = w - 5;
+        paint.drawText(5,
+                       5 + paint.fontMetrics().ascent(),
+                       TextAbbrev::abbreviate(getScaleUnits(),
+                                              paint.fontMetrics(),
+                                              mw));
     }
 }