commit 7b155c8b212ffbd6ae0f805dbac11dda209aa03b
parent 605f42db48eacfce2d21f439d2a4aae6a6c71fdc
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Fri, 8 Nov 2024 18:23:06 +0100
fix VM map dots always displayed for slot A
Diffstat:
3 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/doc/changelog.txt b/doc/changelog.txt
@@ -19,6 +19,7 @@ Framework:
NodalRed2x:
- [Fix] LFO2 rate & range didn't have red VM map overlay dots
+- [Fix] VM Map overlay dots always displayed values for slot A
OsTIrus:
diff --git a/source/nord/n2x/n2xJucePlugin/n2xVmMap.cpp b/source/nord/n2x/n2xJucePlugin/n2xVmMap.cpp
@@ -35,40 +35,47 @@ namespace n2xJucePlugin
if(m_enabled == _enabled)
return;
+ const auto wasEnabled = m_enabled;
+
m_enabled = _enabled;
const auto& controller = m_editor.getN2xController();
- const auto part = controller.getCurrentPart();
+ // initial setup, collect all default-bound components. Only executed once and delayed
+ // because in our constructor the components might not be bound yet
+ if(m_boundComponents.empty())
+ {
+ for(const auto& name : m_paramNames)
+ {
+ const auto paramIdxDefault = controller.getParameterIndexByName(name);
+ const auto paramDefault = controller.getParameter(paramIdxDefault);
+
+ auto* comp = m_binding.getBoundComponent(paramDefault);
+
+ if(comp)
+ m_boundComponents.insert({name, comp});
+ }
+ }
for (const auto& paramName : m_paramNames)
{
const auto paramIdxDefault = controller.getParameterIndexByName(paramName);
const auto paramIdxVm = controller.getParameterIndexByName(paramName + g_postfix);
- const auto* paramDefault = controller.getParameter(paramName, part);
- const auto* paramVm = controller.getParameter(paramName + g_postfix, part);
+ auto it = m_boundComponents.find(paramName);
- auto* comp = m_binding.getBoundComponent(paramDefault);
+ if(it == m_boundComponents.end())
+ continue;
- if(comp == nullptr)
- comp = m_binding.getBoundComponent(paramVm);
+ auto* comp = it->second;
- if(comp != nullptr)
- {
- m_binding.unbind(comp);
- }
- else
- {
- assert(false && "bound component not found");
- return;
- }
-
- m_binding.unbind(paramDefault);
- m_binding.unbind(paramVm);
+ m_binding.unbind(comp);
+ m_boundComponents.erase(it);
m_binding.bind(*comp, _enabled ? paramIdxVm : paramIdxDefault, pluginLib::ParameterBinding::CurrentPart);
+ m_boundComponents.insert({paramName, comp});
+
comp->setAlpha(_enabled ? g_enabledAlpha : 1.0f);
}
}
diff --git a/source/nord/n2x/n2xJucePlugin/n2xVmMap.h b/source/nord/n2x/n2xJucePlugin/n2xVmMap.h
@@ -1,5 +1,6 @@
#pragma once
+#include <map>
#include <string>
#include <set>
@@ -10,6 +11,7 @@ namespace pluginLib
namespace juce
{
+ class Component;
class Button;
}
@@ -29,6 +31,7 @@ namespace n2xJucePlugin
pluginLib::ParameterBinding& m_binding;
std::set<std::string> m_paramNames;
+ std::map<std::string, juce::Component*> m_boundComponents;
juce::Button* m_btVmMap;
bool m_enabled = false;
};