# HG changeset patch # User Chris Cannam # Date 1421318520 0 # Node ID d4446f267e123215e72f42198b1043112056cc29 # Parent c0549bf1297385e84334bcc4a6ca9b5079f15fd6 Scale drag thresholds according to actual display resolution diff -r c0549bf12973 -r d4446f267e12 view/Pane.cpp --- a/view/Pane.cpp Fri Nov 21 14:50:27 2014 +0000 +++ b/view/Pane.cpp Thu Jan 15 10:42:00 2015 +0000 @@ -2028,6 +2028,11 @@ int smallThreshold = 10, bigThreshold = 80; + if (m_manager) { + smallThreshold = m_manager->scalePixelSize(smallThreshold); + bigThreshold = m_manager->scalePixelSize(bigThreshold); + } + // SVDEBUG << "Pane::updateDragMode: xdiff = " << xdiff << ", ydiff = " // << ydiff << ", canMoveVertical = " << canMoveVertical << ", drag mode = " << m_dragMode << endl; diff -r c0549bf12973 -r d4446f267e12 view/ViewManager.cpp --- a/view/ViewManager.cpp Fri Nov 21 14:50:27 2014 +0000 +++ b/view/ViewManager.cpp Thu Jan 15 10:42:00 2015 +0000 @@ -720,3 +720,23 @@ return dark; } +int +ViewManager::scalePixelSize(int pixels) +{ + static float ratio = 0.f; + if (ratio == 0.f) { + float baseEm; +#ifdef Q_OS_MAC + baseEm = 17.f; +#else + baseEm = 15.f; +#endif + float em = QFontMetrics(QFont()).height(); + ratio = em / baseEm; + } + + int scaled = int(pixels * ratio + 0.5); + cerr << "scaledSize: " << pixels << " -> " << scaled << " at ratio " << ratio << endl; + if (pixels != 0 && scaled == 0) scaled = 1; + return scaled; +} diff -r c0549bf12973 -r d4446f267e12 view/ViewManager.h --- a/view/ViewManager.h Fri Nov 21 14:50:27 2014 +0000 +++ b/view/ViewManager.h Thu Jan 15 10:42:00 2015 +0000 @@ -184,6 +184,13 @@ void setMainModelSampleRate(int sr) { m_mainModelSampleRate = sr; } + /** + * Take a "design pixel" size and scale it for the actual + * display. This is relevant to hi-dpi systems that do not do + * pixel doubling (i.e. Windows and Linux rather than OS/X). + */ + int scalePixelSize(int pixels); + enum OverlayMode { NoOverlays, GlobalOverlays,