summaryrefslogtreecommitdiff
path: root/plugingui/knob.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-17 11:23:09 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-17 11:25:53 +0200
commitf505c622eda8cdd02da00742e794c9b940902a8d (patch)
tree2d194ad7c8f97ed0828178e86310ce6880a48b6d /plugingui/knob.cc
parenta36b20f60a33b04ec69b65cfce0dd0059ff9e382 (diff)
Write knob value outside of the knob in the humanizer frame.
Diffstat (limited to 'plugingui/knob.cc')
-rw-r--r--plugingui/knob.cc37
1 files changed, 22 insertions, 15 deletions
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;