summaryrefslogtreecommitdiff
path: root/plugingui/labeledcontrol.h
diff options
context:
space:
mode:
authorTheMarlboroMan <marlborometal@gmail.com>2020-11-15 16:50:27 +0100
committerTheMarlboroMan <marlborometal@gmail.com>2020-11-15 17:04:21 +0100
commiteb0a72576c71557c8bb64cfd319620f5ea7ba24c (patch)
treedf15c068870705d7c7847b8d98a760e058756f03 /plugingui/labeledcontrol.h
parentb0fa70c97c9b4886fb6e063664dc4d10daf12c1c (diff)
Implementation of the voice limiting feature.
Diffstat (limited to 'plugingui/labeledcontrol.h')
-rw-r--r--plugingui/labeledcontrol.h19
1 files changed, 19 insertions, 0 deletions
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 <iomanip>
#include <sstream>
+#include <functional>
namespace GUI
{
@@ -39,6 +40,10 @@ class LabeledControl
: public Widget
{
public:
+
+ using ValueTransformationFunction =
+ std::function<std::string(float, float, float)>;
+
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;