comparison widgets/LevelPanWidget.cpp @ 1176:125748a569fa more-hidpi

Another use of WidgetScale
author Chris Cannam
date Mon, 05 Dec 2016 14:51:25 +0000
parents d6acb8e36605
children 916b62baf7ac
comparison
equal deleted inserted replaced
1175:a7df0d728020 1176:125748a569fa
19 #include <QWheelEvent> 19 #include <QWheelEvent>
20 20
21 #include "layer/ColourMapper.h" 21 #include "layer/ColourMapper.h"
22 #include "base/AudioLevel.h" 22 #include "base/AudioLevel.h"
23 23
24 #include "WidgetScale.h"
25
24 #include <iostream> 26 #include <iostream>
25 #include <cmath> 27 #include <cmath>
26 #include <cassert> 28 #include <cassert>
27 29
28 using std::cerr; 30 using std::cerr;
45 } 47 }
46 48
47 QSize 49 QSize
48 LevelPanWidget::sizeHint() const 50 LevelPanWidget::sizeHint() const
49 { 51 {
50 static double ratio = 0.0; 52 return WidgetScale::scaleQSize(QSize(40, 40));
51 if (ratio == 0.0) {
52 double baseEm;
53 #ifdef Q_OS_MAC
54 baseEm = 17.0;
55 #else
56 baseEm = 15.0;
57 #endif
58 double em = QFontMetrics(QFont()).height();
59 ratio = em / baseEm;
60 }
61
62 int pixels = 40;
63 int scaled = int(pixels * ratio + 0.5);
64 if (pixels != 0 && scaled == 0) scaled = 1;
65 return QSize(scaled, scaled);
66 } 53 }
67 54
68 static int 55 static int
69 db_to_level(double db) 56 db_to_level(double db)
70 { 57 {