# HG changeset patch # User Chris Cannam # Date 1477057248 -3600 # Node ID 07e8ac88bccefdf1a6d55e9c6ebb3fb8efb318ce # Parent c5a82068bd6083596328bf0694928247ec6ec258 Add out-of-process execution to prefs dialog Also, scale the window shape preview labels 'cos they look funny diff -r c5a82068bd60 -r 07e8ac88bcce widgets/WindowShapePreview.cpp --- a/widgets/WindowShapePreview.cpp Thu Oct 20 14:06:05 2016 +0100 +++ b/widgets/WindowShapePreview.cpp Fri Oct 21 14:40:48 2016 +0100 @@ -47,12 +47,17 @@ void WindowShapePreview::updateLabels() { - int step = 24; - float peak = 48; - int w = step * 4, h = 64; + float scaleRatio = QFontMetrics(font()).height() / 14.f; + if (scaleRatio < 1.f) scaleRatio = 1.f; + + int step = int(24 * scaleRatio); + float peak = int(48 * scaleRatio); + + int w = step * 4, h = (peak * 4) / 3; + WindowType type = m_windowType; Window windower = Window(type, step * 2); - + QPixmap timeLabel(w, h + 1); timeLabel.fill(Qt::white); QPainter timePainter(&timeLabel); @@ -105,7 +110,7 @@ timePainter.drawPath(path); QFont font; - font.setPixelSize(10); + font.setPixelSize(int(10 * scaleRatio)); font.setItalic(true); timePainter.setFont(font); QString label = tr("V / time"); @@ -114,9 +119,7 @@ m_windowTimeExampleLabel->setPixmap(timeLabel); - int fw = 100; - - QPixmap freqLabel(fw, h + 1); + QPixmap freqLabel(w, h + 1); freqLabel.fill(Qt::white); QPainter freqPainter(&freqLabel); path = QPainterPath(); @@ -161,7 +164,7 @@ // float ly = h - ((-80.f + -mindb) / maxval) * peak + 1; path.moveTo(0, float(h) - peak + 1); - path.lineTo(fw, float(h) - peak + 1); + path.lineTo(w, float(h) - peak + 1); freqPainter.setPen(Qt::gray); freqPainter.setRenderHint(QPainter::Antialiasing, true); @@ -178,14 +181,14 @@ float val = db + -mindb; if (val < 0) val = 0; float norm = val / maxval; - float x = (float(fw) / float(fftsize/2)) * float(i); + float x = (float(w) / float(fftsize/2)) * float(i); float y = float(h) - norm * peak + 1; if (i == 0) path.moveTo(x, y); else path.lineTo(x, y); } freqPainter.setRenderHint(QPainter::Antialiasing, true); - path.addRect(0, 0, fw, h + 1); + path.addRect(0, 0, w, h + 1); freqPainter.drawPath(path); fftf_free(input); @@ -193,7 +196,7 @@ freqPainter.setFont(font); label = tr("dB / freq"); - freqPainter.drawText(fw - freqPainter.fontMetrics().width(label) - 4, + freqPainter.drawText(w - freqPainter.fontMetrics().width(label) - 4, freqPainter.fontMetrics().ascent() + 1, label); m_windowFreqExampleLabel->setPixmap(freqLabel);