Mercurial > hg > svgui
diff view/ViewManager.cpp @ 896:78e041e45ff0
Scale drag thresholds according to actual display resolution
author | Chris Cannam |
---|---|
date | Thu, 15 Jan 2015 10:42:00 +0000 (2015-01-15) |
parents | 8bb9320f78a4 |
children | a1226b3b7925 |
line wrap: on
line diff
--- a/view/ViewManager.cpp Mon Dec 15 16:08:26 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; +}