diff view/View.cpp @ 1402:b0eeec95ab5b

Handle integer pixel scaling as well
author Chris Cannam
date Thu, 15 Nov 2018 14:18:26 +0000
parents 28075cc658c9
children c8a6fd3f9dff d794630429a7
line wrap: on
line diff
--- a/view/View.cpp	Thu Nov 15 14:04:32 2018 +0000
+++ b/view/View.cpp	Thu Nov 15 14:18:26 2018 +0000
@@ -238,7 +238,7 @@
         }
     }
 
-    int y = scaleSize(15) + paint.fontMetrics().ascent();
+    int y = scalePixelSize(15) + paint.fontMetrics().ascent();
 
     for (std::map<int, Layer *>::const_iterator i = sortedLayers.begin();
          i != sortedLayers.end(); ++i) {
@@ -674,7 +674,7 @@
     QPushButton *cancel = new QPushButton(this);
     cancel->setIcon(IconLoader().load("cancel"));
     cancel->setFlat(true);
-    int scaled20 = scaleSize(20);
+    int scaled20 = scalePixelSize(20);
     cancel->setFixedSize(QSize(scaled20, scaled20));
     connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
     
@@ -1620,6 +1620,15 @@
     return size * ratio;
 }
 
+int
+View::scalePixelSize(int size) const
+{
+    double d = scaleSize(size);
+    int i = int(d + 0.5);
+    if (size != 0 && i == 0) i = 1;
+    return i;
+}
+
 double
 View::scalePenWidth(double width) const 
 {
@@ -1792,7 +1801,7 @@
                     timer->start();
                 }
 
-                int scaled20 = scaleSize(20);
+                int scaled20 = scalePixelSize(20);
 
                 cancel->move(0, ph - pb->height()/2 - scaled20/2);
                 cancel->show();