From f505c622eda8cdd02da00742e794c9b940902a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Mon, 17 Apr 2017 11:23:09 +0200 Subject: Write knob value outside of the knob in the humanizer frame. --- plugingui/knob.cc | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'plugingui/knob.cc') diff --git a/plugingui/knob.cc b/plugingui/knob.cc index 0c7159f..7a5efc1 100644 --- a/plugingui/knob.cc +++ b/plugingui/knob.cc @@ -73,6 +73,11 @@ float Knob::value() return current_value * (maximum - minimum) + minimum; } +void Knob::showValue(bool show_value) +{ + this->show_value = show_value; +} + void Knob::scrollEvent(ScrollEvent* scrollEvent) { float value = (current_value - (scrollEvent->delta / 200.0)); @@ -168,22 +173,24 @@ void Knob::repaintEvent(RepaintEvent* repaintEvent) float range = maximum - minimum; - // Show 0, 1 or 2 decimal point depending on the size of the range - char buf[64]; - if(range> 100.0f) - { - sprintf(buf, "%.0f", current_value * range + minimum); - } - else if(range > 10.0f) - { - sprintf(buf, "%.1f", current_value * range + minimum); - } - else - { - sprintf(buf, "%.2f", current_value * range + minimum); + if (show_value) { + // Show 0, 1 or 2 decimal point depending on the size of the range + char buf[64]; + if(range> 100.0f) + { + sprintf(buf, "%.0f", current_value * range + minimum); + } + else if(range > 10.0f) + { + sprintf(buf, "%.1f", current_value * range + minimum); + } + else + { + sprintf(buf, "%.2f", current_value * range + minimum); + } + p.drawText(center_x - font.textWidth(buf) / 2 + 1, + center_y + font.textHeight(buf) / 2 + 1, font, buf); } - p.drawText(center_x - font.textWidth(buf) / 2 + 1, - center_y + font.textHeight(buf) / 2 + 1, font, buf); // Make it start from 20% and stop at 80% double padval = current_value * 0.8 + 0.1; -- cgit v1.2.3