# HG changeset patch # User Chris Cannam # Date 1541424621 0 # Node ID cca66ce390e03d0ccdc536fb0a365ef3e1b80061 # Parent 2c01be83657045dc369d1cbd196bc423ddf78003 Scaling tweaks diff -r 2c01be836570 -r cca66ce390e0 layer/PaintAssistant.cpp --- a/layer/PaintAssistant.cpp Fri Nov 02 15:23:53 2018 +0000 +++ b/layer/PaintAssistant.cpp Mon Nov 05 13:30:21 2018 +0000 @@ -242,7 +242,7 @@ } double -PaintAssistant::scalePenWidth(double width) +PaintAssistant::scaleSize(double size) { static double ratio = 0.0; if (ratio == 0.0) { @@ -255,21 +255,28 @@ double em = QFontMetrics(QFont()).height(); ratio = em / baseEm; - SVDEBUG << "PaintAssistant::scalePenWidth: ratio is " << ratio + SVDEBUG << "PaintAssistant::scaleSize: ratio is " << ratio << " (em = " << em << ")" << endl; + + if (ratio < 1.0) { + SVDEBUG << "PaintAssistant::scaleSize: rounding ratio up to 1.0" + << endl; + ratio = 1.0; + } } - if (ratio <= 1.0) { - // we only ever scale up in this method - return width; + return size * ratio; +} + +double +PaintAssistant::scalePenWidth(double width) +{ + if (width <= 0) { + // zero-width pen, produce a scaled one-pixel pen + width = 1; } - if (width <= 0) { - // zero-width pen, produce a scaled one-pixel pen - return ratio; - } - - return width * ratio; + return scaleSize(width); } QPen diff -r 2c01be836570 -r cca66ce390e0 layer/PaintAssistant.h --- a/layer/PaintAssistant.h Fri Nov 02 15:23:53 2018 +0000 +++ b/layer/PaintAssistant.h Mon Nov 05 13:30:21 2018 +0000 @@ -49,9 +49,18 @@ QString text, TextStyle style); /** + * Scale up a size in pixels for a hi-dpi display without pixel + * doubling. This is like ViewManager::scalePixelSize, but taking + * and returning floating-point values rather than integer + * pixels. It is also a little more conservative - it never + * shrinks the size, it can only increase or leave it unchanged. + */ + static double scaleSize(double size); + + /** * Scale up pen width for a hi-dpi display without pixel doubling. - * Very similar to ViewManager::scalePixelSize, but a bit more - * conservative. + * This is like scaleSize except that it also scales the + * zero-width case. */ static double scalePenWidth(double width); diff -r 2c01be836570 -r cca66ce390e0 layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Fri Nov 02 15:23:53 2018 +0000 +++ b/layer/WaveformLayer.cpp Mon Nov 05 13:30:21 2018 +0000 @@ -1052,10 +1052,10 @@ } if (!individualSamplePoints.empty()) { - double sz = ViewManager::scalePixelSize(2.0); + double sz = PaintAssistant::scaleSize(2.0); if (v->getZoomLevel().zone == ZoomLevel::PixelsPerFrame) { if (v->getZoomLevel().level < 10) { - sz = 1.5; + sz = PaintAssistant::scaleSize(1.2); } } paint->save();