diff options
author | André Nusser <andre.nusser@googlemail.com> | 2018-06-08 12:02:25 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2018-06-08 12:02:52 +0200 |
commit | 3eee5daaf9535f064d37c31c118ca93576571933 (patch) | |
tree | 50f34f57852ef41542ef7c7b34462af7c8d76d5b /plugingui/humanizerframecontent.h | |
parent | 7c14de074b3eee3ed283d0f92e67cd5ffbfb5658 (diff) |
Move LabeledControl to own file (finally).
Diffstat (limited to 'plugingui/humanizerframecontent.h')
-rw-r--r-- | plugingui/humanizerframecontent.h | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h index cb7a7f4..8286116 100644 --- a/plugingui/humanizerframecontent.h +++ b/plugingui/humanizerframecontent.h @@ -27,66 +27,16 @@ #pragma once #include "knob.h" -#include "label.h" +#include "labeledcontrol.h" #include "layout.h" #include "widget.h" -#include <iomanip> -#include <sstream> - struct Settings; class SettingsNotifier; namespace GUI { -// TODO move this to an own file? -class LabeledControl - : public Widget -{ -public: - LabeledControl(Widget* parent, const std::string& name) - : Widget(parent) - { - layout.setResizeChildren(false); - layout.setHAlignment(HAlignment::center); - layout.setSpacing(2); - - caption.setText(name); - caption.resize(100, 20); - caption.setAlignment(TextAlignment::center); - layout.addItem(&caption); - } - - 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); - } - - float offset{0.0f}; - float scale{1.0f}; - -private: - VBoxLayout layout{this}; - Label caption{this}; - Label value{this}; - - void setValue(float new_value) - { - new_value *= scale; - new_value += offset; - std::stringstream stream; - stream << std::fixed << std::setprecision(2) << new_value; - value.setText(stream.str()); - } -}; - class HumanizerframeContent : public Widget { |