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/humanizerframecontent.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'plugingui/humanizerframecontent.h') diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h index 530742b..0196ea5 100644 --- a/plugingui/humanizerframecontent.h +++ b/plugingui/humanizerframecontent.h @@ -30,6 +30,9 @@ #include "label.h" #include "widget.h" +#include +#include + namespace GUI { @@ -41,6 +44,7 @@ public: { layout.setResizeChildren(false); layout.setHAlignment(HAlignment::center); + layout.setSpacing(2); caption.setText(name); caption.resize(100, 20); @@ -48,14 +52,28 @@ public: layout.addItem(&caption); } - void setControl(Widget* control) + void setControl(Knob* control) { layout.addItem(control); + + CONNECT(control, valueChangedNotifier, this, &LabeledControl::setValue); + setValue(control->value()); + value.resize(100, 20); + value.setAlignment(TextAlignment::center); + layout.addItem(&value); } private: VBoxLayout layout{this}; Label caption{this}; + Label value{this}; + + void setValue(float new_value) + { + std::stringstream stream; + stream << std::fixed << std::setprecision(2) << new_value; + value.setText(stream.str()); + } }; class HumanizerframeContent : public Widget -- cgit v1.2.3