159void PluginControlComponent::showParameterConfig()
161 if (m_selectedPluginDescription.name.isEmpty())
163 m_messageBox = std::make_unique<juce::AlertWindow>(
164 "Plug-in parameter setup not available",
165 "No plug-in selected.",
166 juce::MessageBoxIconType::WarningIcon);
167 m_messageBox->addButton(
"Ok", 1, juce::KeyPress(juce::KeyPress::returnKey));
168 m_messageBox->enterModalState(
true, juce::ModalCallbackFunction::create([=](
int returnValue) {
169 ignoreUnused(returnValue);
170 m_messageBox.reset();
173 else if (m_parameterInfos.empty())
175 m_messageBox = std::make_unique<juce::AlertWindow>(
176 "Plug-in parameter setup not available",
177 "No parameters detected.",
178 juce::MessageBoxIconType::WarningIcon);
179 m_messageBox->addButton(
"Ok", 1, juce::KeyPress(juce::KeyPress::returnKey));
180 m_messageBox->enterModalState(
true, juce::ModalCallbackFunction::create([=](
int returnValue) {
181 ignoreUnused(returnValue);
182 m_messageBox.reset();
187 m_messageBox = std::make_unique<juce::AlertWindow>(
188 "Plug-in parameter setup",
189 "Select which parameters should be remote-controllable and configure their control type.",
190 juce::MessageBoxIconType::NoIcon);
193 m_messageBoxParameterTogglesContainer = std::make_unique<juce::Component>();
196 const int rowHeight = 28;
197 const int margin = 2;
198 const int toggleWidth = 180;
199 const int comboWidth = 100;
200 const int stepsWidth = 50;
201 const int totalWidth = toggleWidth + comboWidth + stepsWidth + (margin * 4);
202 const int totalHeight = int(m_parameterInfos.size()) * rowHeight;
204 m_messageBoxParameterTogglesContainer->setSize(totalWidth, totalHeight);
208 grid.templateColumns = {
209 juce::Grid::TrackInfo(juce::Grid::Px(toggleWidth)),
210 juce::Grid::TrackInfo(juce::Grid::Px(comboWidth)),
211 juce::Grid::TrackInfo(juce::Grid::Px(stepsWidth))
213 for (
size_t i = 0; i < m_parameterInfos.size(); ++i)
214 grid.templateRows.add(juce::Grid::TrackInfo(juce::Grid::Px(rowHeight)));
217 for (
auto const& parameterKV : m_parameterInfos)
219 auto paramIndex = parameterKV.first;
220 auto const& paramInfo = parameterKV.second;
223 m_messageBoxParameterToggles[paramIndex] = std::make_unique<juce::ToggleButton>(paramInfo.name);
224 m_messageBoxParameterToggles[paramIndex]->setToggleState(paramInfo.isRemoteControllable, juce::dontSendNotification);
225 m_messageBoxParameterTogglesContainer->addAndMakeVisible(m_messageBoxParameterToggles[paramIndex].get());
227 grid.items.add(juce::GridItem(*m_messageBoxParameterToggles[paramIndex])
228 .withArea(gridRow, 1)
229 .withMargin(juce::GridItem::Margin(margin)));
232 m_messageBoxParameterCtrlTypess[paramIndex] = std::make_unique<juce::ComboBox>();
233 m_messageBoxParameterCtrlTypess[paramIndex]->addItem(
"Continuous",
static_cast<int>(ParameterControlType::Continuous) + 1);
234 m_messageBoxParameterCtrlTypess[paramIndex]->addItem(
"Discrete",
static_cast<int>(ParameterControlType::Discrete) + 1);
235 m_messageBoxParameterCtrlTypess[paramIndex]->addItem(
"Toggle",
static_cast<int>(ParameterControlType::Toggle) + 1);
236 m_messageBoxParameterCtrlTypess[paramIndex]->setSelectedId(
static_cast<int>(paramInfo.type) + 1, juce::dontSendNotification);
237 m_messageBoxParameterTogglesContainer->addAndMakeVisible(m_messageBoxParameterCtrlTypess[paramIndex].get());
239 grid.items.add(juce::GridItem(*m_messageBoxParameterCtrlTypess[paramIndex])
240 .withArea(gridRow, 2)
241 .withMargin(juce::GridItem::Margin(margin)));
244 m_messageBoxParameterCtrlStepsEdit[paramIndex] = std::make_unique<JUCEAppBasics::FixedFontTextEditor>();
245 m_messageBoxParameterCtrlStepsEdit[paramIndex]->setText(paramInfo.type == ParameterControlType::Toggle ? juce::String(2) : juce::String(paramInfo.stepCount), juce::dontSendNotification);
246 m_messageBoxParameterCtrlStepsEdit[paramIndex]->setEnabled(paramInfo.type != ParameterControlType::Toggle);
247 m_messageBoxParameterCtrlStepsEdit[paramIndex]->setInputRestrictions(3,
"0123456789");
248 m_messageBoxParameterTogglesContainer->addAndMakeVisible(m_messageBoxParameterCtrlStepsEdit[paramIndex].get());
250 grid.items.add(juce::GridItem(*m_messageBoxParameterCtrlStepsEdit[paramIndex])
251 .withArea(gridRow, 3)
252 .withMargin(juce::GridItem::Margin(margin)));
255 m_messageBoxParameterCtrlTypess[paramIndex]->onChange = [
this, paramIndex]() {
256 auto selectedType =
static_cast<ParameterControlType
>(m_messageBoxParameterCtrlTypess[paramIndex]->getSelectedId() - 1);
257 m_messageBoxParameterCtrlStepsEdit[paramIndex]->setEnabled(selectedType != ParameterControlType::Toggle);
258 if (selectedType == ParameterControlType::Toggle)
259 m_messageBoxParameterCtrlStepsEdit[paramIndex]->setText(juce::String(2), juce::dontSendNotification);
265 grid.performLayout(m_messageBoxParameterTogglesContainer->getLocalBounds());
268 m_messageBox->addCustomComponent(m_messageBoxParameterTogglesContainer.get());
270 m_messageBox->addButton(
"Cancel", 0, juce::KeyPress(juce::KeyPress::escapeKey));
271 m_messageBox->addButton(
"Ok", 1, juce::KeyPress(juce::KeyPress::returnKey));
273 m_messageBox->enterModalState(
true, juce::ModalCallbackFunction::create([=](
int returnValue) {
274 if (returnValue == 1)
276 auto changeDetected =
false;
278 for (
auto& parameterKV : m_parameterInfos)
280 auto paramIndex = parameterKV.first;
281 auto& paramInfo = parameterKV.second;
284 auto newRemoteControllable = m_messageBoxParameterToggles[paramIndex]->getToggleState();
285 if (newRemoteControllable != paramInfo.isRemoteControllable)
287 paramInfo.isRemoteControllable = newRemoteControllable;
288 changeDetected =
true;
292 auto newType =
static_cast<ParameterControlType
>(m_messageBoxParameterCtrlTypess[paramIndex]->getSelectedId() - 1);
293 if (newType != paramInfo.type)
295 paramInfo.type = newType;
296 if (newType == ParameterControlType::Toggle)
297 paramInfo.stepCount = 2;
298 changeDetected =
true;
302 if (newType != ParameterControlType::Toggle)
304 auto newStepCount = m_messageBoxParameterCtrlStepsEdit[paramIndex]->getText().getIntValue();
305 newStepCount = juce::jmax(2, newStepCount);
306 if (newStepCount != paramInfo.stepCount)
308 paramInfo.stepCount = newStepCount;
309 changeDetected =
true;
316 if (onPluginParametersStatusChanged)
317 onPluginParametersStatusChanged();
321 m_messageBoxParameterToggles.clear();
322 m_messageBoxParameterCtrlTypess.clear();
323 m_messageBoxParameterCtrlStepsEdit.clear();
324 m_messageBoxParameterTogglesContainer.reset();
325 m_messageBox.reset();