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.
This commit is contained in:
parent
cdd3399286
commit
94189402c2
@ -20,6 +20,9 @@ using namespace std;
|
|||||||
// Size of the audio indicator in pixels
|
// Size of the audio indicator in pixels
|
||||||
#define INDICATOR_THICKNESS 3
|
#define INDICATOR_THICKNESS 3
|
||||||
|
|
||||||
|
// Padding on top and bottom of vertical meters
|
||||||
|
#define METER_PADDING 1
|
||||||
|
|
||||||
QWeakPointer<VolumeMeterTimer> VolumeMeter::updateTimer;
|
QWeakPointer<VolumeMeterTimer> VolumeMeter::updateTimer;
|
||||||
|
|
||||||
void VolControl::OBSVolumeChanged(void *data, float db)
|
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.
|
// Draw major tick lines and numeric indicators.
|
||||||
for (int i = 0; i >= minimumLevel; i -= 5) {
|
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);
|
QString str = QString::number(i);
|
||||||
|
|
||||||
// Center the number on the tick, but don't overflow
|
// 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.
|
// Draw minor tick lines.
|
||||||
painter.setPen(minorTickColor);
|
painter.setPen(minorTickColor);
|
||||||
for (int i = 0; i >= minimumLevel; i--) {
|
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)
|
if (i % 5 != 0)
|
||||||
painter.drawLine(x, position, x + 1, position);
|
painter.drawLine(x, position, x + 1, position);
|
||||||
}
|
}
|
||||||
@ -1304,6 +1307,9 @@ void VolumeMeter::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
|
if (vertical)
|
||||||
|
height -= METER_PADDING * 2;
|
||||||
|
|
||||||
// timerEvent requests update of the bar(s) only, so we can avoid the
|
// timerEvent requests update of the bar(s) only, so we can avoid the
|
||||||
// overhead of repainting the scale and labels.
|
// overhead of repainting the scale and labels.
|
||||||
if (event->region().boundingRect() != getBarRect()) {
|
if (event->region().boundingRect() != getBarRect()) {
|
||||||
@ -1332,7 +1338,7 @@ void VolumeMeter::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
// Invert the Y axis to ease the math
|
// Invert the Y axis to ease the math
|
||||||
painter.translate(0, height);
|
painter.translate(0, height + METER_PADDING);
|
||||||
painter.scale(1, -1);
|
painter.scale(1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user