Skip to content

Commit

Permalink
UI: Fix vertical grayscale meters when volume is muted
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro authored and jp9000 committed Dec 31, 2021
1 parent 2f13d92 commit 1dd9612
Showing 1 changed file with 38 additions and 19 deletions.
57 changes: 38 additions & 19 deletions UI/volume-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,44 +1061,59 @@ void VolumeMeter::paintVMeter(QPainter &painter, int x, int y, int width,

if (peakPosition < minimumPosition) {
painter.fillRect(x, minimumPosition, width, nominalLength,
backgroundNominalColor);
muted ? backgroundNominalColorDisabled
: backgroundNominalColor);
painter.fillRect(x, warningPosition, width, warningLength,
backgroundWarningColor);
muted ? backgroundWarningColorDisabled
: backgroundWarningColor);
painter.fillRect(x, errorPosition, width, errorLength,
backgroundErrorColor);
muted ? backgroundErrorColorDisabled
: backgroundErrorColor);
} else if (peakPosition < warningPosition) {
painter.fillRect(x, minimumPosition, width,
peakPosition - minimumPosition,
foregroundNominalColor);
muted ? foregroundNominalColorDisabled
: foregroundNominalColor);
painter.fillRect(x, peakPosition, width,
warningPosition - peakPosition,
backgroundNominalColor);
muted ? backgroundNominalColorDisabled
: backgroundNominalColor);
painter.fillRect(x, warningPosition, width, warningLength,
backgroundWarningColor);
muted ? backgroundWarningColorDisabled
: backgroundWarningColor);
painter.fillRect(x, errorPosition, width, errorLength,
backgroundErrorColor);
muted ? backgroundErrorColorDisabled
: backgroundErrorColor);
} else if (peakPosition < errorPosition) {
painter.fillRect(x, minimumPosition, width, nominalLength,
foregroundNominalColor);
muted ? foregroundNominalColorDisabled
: foregroundNominalColor);
painter.fillRect(x, warningPosition, width,
peakPosition - warningPosition,
foregroundWarningColor);
muted ? foregroundWarningColorDisabled
: foregroundWarningColor);
painter.fillRect(x, peakPosition, width,
errorPosition - peakPosition,
backgroundWarningColor);
muted ? backgroundWarningColorDisabled
: backgroundWarningColor);
painter.fillRect(x, errorPosition, width, errorLength,
backgroundErrorColor);
muted ? backgroundErrorColorDisabled
: backgroundErrorColor);
} else if (peakPosition < maximumPosition) {
painter.fillRect(x, minimumPosition, width, nominalLength,
foregroundNominalColor);
muted ? foregroundNominalColorDisabled
: foregroundNominalColor);
painter.fillRect(x, warningPosition, width, warningLength,
foregroundWarningColor);
muted ? foregroundWarningColorDisabled
: foregroundWarningColor);
painter.fillRect(x, errorPosition, width,
peakPosition - errorPosition,
foregroundErrorColor);
muted ? foregroundErrorColorDisabled
: foregroundErrorColor);
painter.fillRect(x, peakPosition, width,
maximumPosition - peakPosition,
backgroundErrorColor);
muted ? backgroundErrorColorDisabled
: backgroundErrorColor);
} else {
if (!clipping) {
QTimer::singleShot(CLIP_FLASH_DURATION_MS, this,
Expand All @@ -1108,20 +1123,24 @@ void VolumeMeter::paintVMeter(QPainter &painter, int x, int y, int width,

int end = errorLength + warningLength + nominalLength;
painter.fillRect(x, minimumPosition, width, end,
QBrush(foregroundErrorColor));
QBrush(muted ? foregroundErrorColorDisabled
: foregroundErrorColor));
}

if (peakHoldPosition - 3 < minimumPosition)
; // Peak-hold below minimum, no drawing.
else if (peakHoldPosition < warningPosition)
painter.fillRect(x, peakHoldPosition - 3, width, 3,
foregroundNominalColor);
muted ? foregroundNominalColorDisabled
: foregroundNominalColor);
else if (peakHoldPosition < errorPosition)
painter.fillRect(x, peakHoldPosition - 3, width, 3,
foregroundWarningColor);
muted ? foregroundWarningColorDisabled
: foregroundWarningColor);
else
painter.fillRect(x, peakHoldPosition - 3, width, 3,
foregroundErrorColor);
muted ? foregroundErrorColorDisabled
: foregroundErrorColor);

if (magnitudePosition - 3 >= minimumPosition)
painter.fillRect(x, magnitudePosition - 3, width, 3,
Expand Down

0 comments on commit 1dd9612

Please sign in to comment.