From eb0a72576c71557c8bb64cfd319620f5ea7ba24c Mon Sep 17 00:00:00 2001 From: TheMarlboroMan Date: Sun, 15 Nov 2020 16:50:27 +0100 Subject: Implementation of the voice limiting feature. --- plugingui/labeledcontrol.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'plugingui/labeledcontrol.h') diff --git a/plugingui/labeledcontrol.h b/plugingui/labeledcontrol.h index cf01b46..3cbae39 100644 --- a/plugingui/labeledcontrol.h +++ b/plugingui/labeledcontrol.h @@ -31,6 +31,7 @@ #include #include +#include namespace GUI { @@ -39,6 +40,10 @@ class LabeledControl : public Widget { public: + + using ValueTransformationFunction = + std::function; + LabeledControl(Widget* parent, const std::string& name) : Widget(parent) { @@ -63,6 +68,11 @@ public: layout.addItem(&value); } + void setValueTransformationFunction(ValueTransformationFunction function) + { + value_transformation_func = function; + } + float offset{0.0f}; float scale{1.0f}; @@ -71,8 +81,17 @@ private: Label caption{this}; Label value{this}; + ValueTransformationFunction value_transformation_func; + void setValue(float new_value) { + if(value_transformation_func) + { + value.setText(value_transformation_func(new_value, scale, offset)); + return; + } + + //TODO: Surely this could be the "default transformation function"? new_value *= scale; new_value += offset; std::stringstream stream; -- cgit v1.2.3