mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-05 23:26:13 -05:00
UI: Hold the clip flash for at least one second
Holds the clipping flash for one second to better indicate that clipping is occurring. Closes obsproject/obs-studio#1201
This commit is contained in:
@@ -653,6 +653,13 @@ void VolumeMeter::paintTicks(QPainter &painter, int x, int y,
|
||||
}
|
||||
}
|
||||
|
||||
#define CLIP_FLASH_DURATION_MS 1000
|
||||
|
||||
void VolumeMeter::ClipEnding()
|
||||
{
|
||||
clipping = false;
|
||||
}
|
||||
|
||||
void VolumeMeter::paintMeter(QPainter &painter, int x, int y,
|
||||
int width, int height, float magnitude, float peak, float peakHold)
|
||||
{
|
||||
@@ -672,6 +679,10 @@ void VolumeMeter::paintMeter(QPainter &painter, int x, int y,
|
||||
int errorLength = maximumPosition - errorPosition;
|
||||
locker.unlock();
|
||||
|
||||
if (clipping) {
|
||||
peakPosition = maximumPosition;
|
||||
}
|
||||
|
||||
if (peakPosition < minimumPosition) {
|
||||
painter.fillRect(
|
||||
minimumPosition, y,
|
||||
@@ -740,6 +751,12 @@ void VolumeMeter::paintMeter(QPainter &painter, int x, int y,
|
||||
backgroundErrorColor);
|
||||
|
||||
} else {
|
||||
if (!clipping) {
|
||||
QTimer::singleShot(CLIP_FLASH_DURATION_MS, this,
|
||||
SLOT(ClipEnding()));
|
||||
clipping = true;
|
||||
}
|
||||
|
||||
qreal end = errorLength + warningLength + nominalLength;
|
||||
painter.fillRect(
|
||||
minimumPosition, y,
|
||||
|
||||
@@ -79,6 +79,9 @@ class VolumeMeter : public QWidget
|
||||
READ getInputPeakHoldDuration
|
||||
WRITE setInputPeakHoldDuration DESIGNABLE true)
|
||||
|
||||
private slots:
|
||||
void ClipEnding();
|
||||
|
||||
private:
|
||||
obs_volmeter_t *obs_volmeter;
|
||||
static QWeakPointer<VolumeMeterTimer> updateTimer;
|
||||
@@ -137,6 +140,7 @@ private:
|
||||
qreal inputPeakHoldDuration;
|
||||
|
||||
uint64_t lastRedrawTime = 0;
|
||||
bool clipping = false;
|
||||
|
||||
public:
|
||||
explicit VolumeMeter(QWidget *parent = 0,
|
||||
|
||||
Reference in New Issue
Block a user