commit 0bcebb9fa80ebe24e438b58feb62930df3ecd97f
parent 030abdef5658c5434c61963ff2339794ffc634ff
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Thu, 18 Apr 2024 22:01:51 +0200
add ability to overwrite how the focused parameter is applied
Diffstat:
2 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/source/jucePluginEditorLib/focusedParameter.cpp b/source/jucePluginEditorLib/focusedParameter.cpp
@@ -60,6 +60,34 @@ namespace jucePluginEditorLib
updateControlLabel(component);
}
+ void FocusedParameter::updateParameter(const std::string& _name, const std::string& _value)
+ {
+ if (m_focusedParameterName)
+ {
+ if(_name.empty())
+ {
+ m_focusedParameterName->setVisible(false);
+ }
+ else
+ {
+ m_focusedParameterName->setText(_name, juce::dontSendNotification);
+ m_focusedParameterName->setVisible(true);
+ }
+ }
+ if(m_focusedParameterValue)
+ {
+ if(_value.empty())
+ {
+ m_focusedParameterValue->setVisible(false);
+ }
+ else
+ {
+ m_focusedParameterValue->setText(_value, juce::dontSendNotification);
+ m_focusedParameterValue->setVisible(true);
+ }
+ }
+ }
+
void FocusedParameter::timerCallback()
{
updateControlLabel(nullptr);
@@ -78,10 +106,7 @@ namespace jucePluginEditorLib
if(!_component || !_component->getProperties().contains("parameter"))
{
- if (m_focusedParameterName)
- m_focusedParameterName->setVisible(false);
- if (m_focusedParameterValue)
- m_focusedParameterValue->setVisible(false);
+ updateParameter({}, {});
m_tooltip->setVisible(false);
return;
}
@@ -102,29 +127,16 @@ namespace jucePluginEditorLib
}
if(!p)
{
- if (m_focusedParameterName)
- m_focusedParameterName->setVisible(false);
- if (m_focusedParameterValue)
- m_focusedParameterValue->setVisible(false);
+ updateParameter({}, {});
m_tooltip->setVisible(false);
return;
}
- const auto value = p->getText(p->getValue(), 0);
+ const auto value = p->getText(p->getValue(), 0).toStdString();
const auto& desc = p->getDescription();
- if (m_focusedParameterName)
- {
- m_focusedParameterName->setText(desc.displayName, juce::dontSendNotification);
- m_focusedParameterName->setVisible(true);
- }
-
- if (m_focusedParameterValue)
- {
- m_focusedParameterValue->setText(value, juce::dontSendNotification);
- m_focusedParameterValue->setVisible(true);
- }
+ updateParameter(desc.displayName, value);
m_tooltip->initialize(_component, value);
diff --git a/source/jucePluginEditorLib/focusedParameter.h b/source/jucePluginEditorLib/focusedParameter.h
@@ -31,6 +31,8 @@ namespace jucePluginEditorLib
void onMouseEnter(const juce::MouseEvent& _event);
+ virtual void updateParameter(const std::string& _name, const std::string& _value);
+
private:
void timerCallback() override;
void updateControlLabel(juce::Component* _component);