Rate-limit volume meter updates
This commit is contained in:
parent
2724a3490c
commit
cbc7c912dd
2 changed files with 19 additions and 1 deletions
|
|
@ -991,7 +991,23 @@ void SLevelMeter::setValue(float value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
value_ = value;
|
value_ = value;
|
||||||
invalid();
|
|
||||||
|
// instantiate the timer lazily
|
||||||
|
if (!timer_) {
|
||||||
|
const uint32_t interval = 10;
|
||||||
|
timer_ = makeOwned<CVSTGUITimer>(
|
||||||
|
[this](CVSTGUITimer* timer) {
|
||||||
|
timer->stop();
|
||||||
|
timerArmed_ = false;
|
||||||
|
invalid();
|
||||||
|
}, interval, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// defer the update, but do not rearm the timer
|
||||||
|
if (!timerArmed_) {
|
||||||
|
timerArmed_ = true;
|
||||||
|
timer_->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SLevelMeter::draw(CDrawContext* dc)
|
void SLevelMeter::draw(CDrawContext* dc)
|
||||||
|
|
|
||||||
|
|
@ -402,6 +402,8 @@ private:
|
||||||
CColor dangerFillColor_;
|
CColor dangerFillColor_;
|
||||||
CColor backColor_;
|
CColor backColor_;
|
||||||
CCoord radius_ = 5.0;
|
CCoord radius_ = 5.0;
|
||||||
|
SharedPointer<CVSTGUITimer> timer_;
|
||||||
|
bool timerArmed_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue