diff options
-rw-r--r-- | plugingui/humanizerframecontent.h | 52 | ||||
-rw-r--r-- | plugingui/labeledcontrol.h | 84 | ||||
-rw-r--r-- | plugingui/timingframecontent.h | 2 |
3 files changed, 86 insertions, 52 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 { diff --git a/plugingui/labeledcontrol.h b/plugingui/labeledcontrol.h new file mode 100644 index 0000000..cf01b46 --- /dev/null +++ b/plugingui/labeledcontrol.h @@ -0,0 +1,84 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + * labeledcontrol.h + * + * Fri Jun 8 11:56:50 CEST 2018 + * Copyright 2018 André Nusser + * andre.nusser@googlemail.com + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DrumGizmo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#pragma once + +#include "label.h" +#include "widget.h" + +#include <iomanip> +#include <sstream> + +namespace GUI +{ + +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()); + } +}; + +} diff --git a/plugingui/timingframecontent.h b/plugingui/timingframecontent.h index 78fe5d6..6feeabe 100644 --- a/plugingui/timingframecontent.h +++ b/plugingui/timingframecontent.h @@ -31,7 +31,7 @@ #include "layout.h" #include "widget.h" -#include "humanizerframecontent.h" // For LabeledControl +#include "labeledcontrol.h" #include <iomanip> #include <sstream> |