commit cf7f6e1bc6172b709ad558a71bd2f820b5c055bf
parent 564d6074a9ffa0586d58b4c73eb3ca5a0606a8e9
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date: Tue, 7 Sep 2021 22:00:31 +0200
host now shows the value as text
Diffstat:
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/examples/host/plugin-host.cc b/examples/host/plugin-host.cc
@@ -1089,4 +1089,13 @@ bool PluginHost::isPluginActive() const {
bool PluginHost::isPluginProcessing() const { return _state == ActiveAndProcessing; }
-bool PluginHost::isPluginSleeping() const { return _state == ActiveAndSleeping; }
-\ No newline at end of file
+bool PluginHost::isPluginSleeping() const { return _state == ActiveAndSleeping; }
+
+QString PluginHost::paramValueToText(clap_id paramId, double value) {
+ std::array<char, 256> buffer;
+
+ if (_pluginParams->value_to_text(_plugin, paramId, value, buffer.data(), buffer.size()))
+ return buffer.data();
+
+ return QString::number(value);
+}
diff --git a/examples/host/plugin-host.hh b/examples/host/plugin-host.hh
@@ -71,6 +71,8 @@ public:
static void checkForMainThread();
static void checkForAudioThread();
+ QString paramValueToText(clap_id paramId, double value);
+
signals:
void paramsChanged();
void quickControlsPagesChanged();
diff --git a/examples/host/plugin-parameters-widget.cc b/examples/host/plugin-parameters-widget.cc
@@ -112,6 +112,7 @@ PluginParametersWidget::PluginParametersWidget(QWidget *parent, PluginHost &plug
_maxValueLabel = new QLabel;
_defaultValueLabel = new QLabel;
_isBeingAdjusted = new QLabel;
+ _valueLabel = new QLabel;
_valueSlider = new QSlider;
_valueSlider->setMinimum(0);
@@ -140,6 +141,7 @@ PluginParametersWidget::PluginParametersWidget(QWidget *parent, PluginHost &plug
formLayout->addRow(tr("max_value"), _maxValueLabel);
formLayout->addRow(tr("default_value"), _defaultValueLabel);
formLayout->addRow(tr("is_being_adjusted"), _isBeingAdjusted);
+ formLayout->addRow(tr("value"), _valueLabel);
formLayout->addRow(tr("value"), _valueSlider);
formLayout->addRow(tr("modulation"), _modulationSlider);
@@ -224,6 +226,8 @@ void PluginParametersWidget::disconnectFromParam() {
this,
&PluginParametersWidget::updateParamIsBeingAjustedChanged);
+ _currentParam = nullptr;
+
updateAll();
}
@@ -250,6 +254,7 @@ void PluginParametersWidget::updateParamInfo() {
_maxValueLabel->setText("-");
_defaultValueLabel->setText("-");
_isBeingAdjusted->setText("-");
+ _valueLabel->setText("-");
} else {
auto &p = *_currentParam;
auto &i = p.info();
@@ -290,6 +295,12 @@ void PluginParametersWidget::updateParamValue() {
auto info = _currentParam->info();
auto v = _currentParam->value();
_valueSlider->setValue(SLIDER_RANGE * (v - info.min_value) / (info.max_value - info.min_value));
+ updateParamValueText();
+}
+
+void PluginParametersWidget::updateParamValueText()
+{
+ _valueLabel->setText(_pluginHost.paramValueToText(_currentParam->info().id, _currentParam->value()));
}
void PluginParametersWidget::updateParamModulation() {
@@ -319,6 +330,7 @@ void PluginParametersWidget::sliderValueChanged(int newValue) {
double value = newValue * (info.max_value - info.min_value) / SLIDER_RANGE + info.min_value;
_pluginHost.setParamValueByHost(*_currentParam, value);
+ updateParamValueText();
}
void PluginParametersWidget::sliderModulationChanged(int newValue) {
diff --git a/examples/host/plugin-parameters-widget.hh b/examples/host/plugin-parameters-widget.hh
@@ -69,6 +69,7 @@ private:
void updateAll();
void updateParamInfo();
void updateParamValue();
+ void updateParamValueText();
void updateParamModulation();
void updateParamIsBeingAjustedChanged();
@@ -94,6 +95,7 @@ private:
QLabel *_maxValueLabel = nullptr;
QLabel *_defaultValueLabel = nullptr;
QLabel *_isBeingAdjusted = nullptr;
+ QLabel *_valueLabel = nullptr;
QSlider *_valueSlider = nullptr;
QSlider *_modulationSlider = nullptr;
};