# HG changeset patch # User Chris Cannam # Date 1542291506 0 # Node ID b0eeec95ab5b1d433f6d385d8095925cbb7f102f # Parent 28075cc658c94c8c314c97b349b59c18005e3c4e Handle integer pixel scaling as well diff -r 28075cc658c9 -r b0eeec95ab5b layer/LayerGeometryProvider.h --- a/layer/LayerGeometryProvider.h Thu Nov 15 14:04:32 2018 +0000 +++ b/layer/LayerGeometryProvider.h Thu Nov 15 14:18:26 2018 +0000 @@ -180,6 +180,7 @@ virtual void updatePaintRect(QRect r) = 0; virtual double scaleSize(double size) const = 0; + virtual int scalePixelSize(int size) const = 0; virtual double scalePenWidth(double width) const = 0; virtual QPen scalePen(QPen pen) const = 0; diff -r 28075cc658c9 -r b0eeec95ab5b layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Thu Nov 15 14:04:32 2018 +0000 +++ b/layer/TimeValueLayer.cpp Thu Nov 15 14:18:26 2018 +0000 @@ -565,7 +565,7 @@ } if (!usePoints.empty()) { - int fuzz = v->scaleSize(2); + double fuzz = v->scaleSize(2); int px = v->getXForFrame(usePoints.begin()->frame); if ((px > x && px - x > fuzz) || (px < x && x - px > fuzz + 3)) { diff -r 28075cc658c9 -r b0eeec95ab5b view/Pane.cpp --- a/view/Pane.cpp Thu Nov 15 14:04:32 2018 +0000 +++ b/view/Pane.cpp Thu Nov 15 14:18:26 2018 +0000 @@ -1173,7 +1173,7 @@ if (!m_manager) return Selection(); - sv_frame_t testFrame = getFrameForX(x - scaleSize(5)); + sv_frame_t testFrame = getFrameForX(x - scalePixelSize(5)); if (testFrame < 0) { testFrame = getFrameForX(x); if (testFrame < 0) return Selection(); @@ -1185,14 +1185,14 @@ int lx = getXForFrame(selection.getStartFrame()); int rx = getXForFrame(selection.getEndFrame()); - int fuzz = scaleSize(2); + int fuzz = scalePixelSize(2); if (x < lx - fuzz || x > rx + fuzz) return Selection(); int width = rx - lx; - fuzz = scaleSize(3); + fuzz = scalePixelSize(3); if (width < 12) fuzz = width / 4; - if (fuzz < scaleSize(1)) { - fuzz = scaleSize(1); + if (fuzz < scalePixelSize(1)) { + fuzz = scalePixelSize(1); } if (x < lx + fuzz) closeToLeftEdge = true; diff -r 28075cc658c9 -r b0eeec95ab5b view/View.cpp --- 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::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(); diff -r 28075cc658c9 -r b0eeec95ab5b view/View.h --- a/view/View.h Thu Nov 15 14:04:32 2018 +0000 +++ b/view/View.h Thu Nov 15 14:18:26 2018 +0000 @@ -377,6 +377,7 @@ int getPaintHeight() const { return getPaintRect().height(); } double scaleSize(double size) const; + int scalePixelSize(int size) const; double scalePenWidth(double width) const; QPen scalePen(QPen pen) const; diff -r 28075cc658c9 -r b0eeec95ab5b view/ViewProxy.h --- a/view/ViewProxy.h Thu Nov 15 14:04:32 2018 +0000 +++ b/view/ViewProxy.h Thu Nov 15 14:18:26 2018 +0000 @@ -156,6 +156,13 @@ } /** + * Integer version of scaleSize. + */ + virtual int scalePixelSize(int size) const { + return m_view->scalePixelSize(size * m_scaleFactor); + } + + /** * Scale up pen width for a hi-dpi display without pixel doubling. * This is like scaleSize except that it also scales the * zero-width case.