From 94189402c22c67cff3bff7db640c6c4840bb66e7 Mon Sep 17 00:00:00 2001 From: cg2121 Date: Wed, 10 Aug 2022 11:08:00 -0500 Subject: [PATCH] UI: Fix padding with vertical volume meters Since Yami uses a different font, the 0 dB mark at the top of the vertical meters would be cut off. This adds a 1px padding to the top and bottom of the volume meters, when in vertical mode. --- UI/volume-control.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/UI/volume-control.cpp b/UI/volume-control.cpp index 67e128995..868bcf023 100644 --- a/UI/volume-control.cpp +++ b/UI/volume-control.cpp @@ -20,6 +20,9 @@ using namespace std; // Size of the audio indicator in pixels #define INDICATOR_THICKNESS 3 +// Padding on top and bottom of vertical meters +#define METER_PADDING 1 + QWeakPointer VolumeMeter::updateTimer; void VolControl::OBSVolumeChanged(void *data, float db) @@ -1035,7 +1038,7 @@ void VolumeMeter::paintVTicks(QPainter &painter, int x, int y, int height) // Draw major tick lines and numeric indicators. for (int i = 0; i >= minimumLevel; i -= 5) { - int position = y + int(i * scale); + int position = y + int(i * scale) + METER_PADDING; QString str = QString::number(i); // Center the number on the tick, but don't overflow @@ -1054,7 +1057,7 @@ void VolumeMeter::paintVTicks(QPainter &painter, int x, int y, int height) // Draw minor tick lines. painter.setPen(minorTickColor); for (int i = 0; i >= minimumLevel; i--) { - int position = y + int(i * scale); + int position = y + int(i * scale) + METER_PADDING; if (i % 5 != 0) painter.drawLine(x, position, x + 1, position); } @@ -1304,6 +1307,9 @@ void VolumeMeter::paintEvent(QPaintEvent *event) QPainter painter(this); + if (vertical) + height -= METER_PADDING * 2; + // timerEvent requests update of the bar(s) only, so we can avoid the // overhead of repainting the scale and labels. if (event->region().boundingRect() != getBarRect()) { @@ -1332,7 +1338,7 @@ void VolumeMeter::paintEvent(QPaintEvent *event) if (vertical) { // Invert the Y axis to ease the math - painter.translate(0, height); + painter.translate(0, height + METER_PADDING); painter.scale(1, -1); }