Mercurial > hg > svgui
diff view/ViewManager.cpp @ 900:1fc4f29feb2e cxx11
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 03 Mar 2015 09:33:59 +0000 |
parents | 78e041e45ff0 |
children | a1226b3b7925 |
line wrap: on
line diff
--- a/view/ViewManager.cpp Mon Feb 09 10:31:07 2015 +0000 +++ b/view/ViewManager.cpp Tue Mar 03 09:33:59 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; +}