From a340c3c27f038eabbf50eb37e0e37ec9815bf2d0 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Fri, 26 Jan 2024 23:06:12 +0800 Subject: [PATCH] Update PluginAutomationModel --- src/ui/component/PluginPropComponent.cpp | 1 + src/ui/dataModel/PluginAutomationModel.cpp | 27 ++++++++++++++++++++-- src/ui/misc/CoreActions.cpp | 16 +++++++++---- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/ui/component/PluginPropComponent.cpp b/src/ui/component/PluginPropComponent.cpp index b76f1f10..7e4c22ba 100644 --- a/src/ui/component/PluginPropComponent.cpp +++ b/src/ui/component/PluginPropComponent.cpp @@ -203,6 +203,7 @@ void PluginPropComponent::update() { this->automaticModel->update(); this->automaticList->updateContent(); + this->automaticList->repaint(); } } diff --git a/src/ui/dataModel/PluginAutomationModel.cpp b/src/ui/dataModel/PluginAutomationModel.cpp index 6f560fc2..984c9e46 100644 --- a/src/ui/dataModel/PluginAutomationModel.cpp +++ b/src/ui/dataModel/PluginAutomationModel.cpp @@ -125,11 +125,34 @@ void PluginAutomationModel::update() { } void PluginAutomationModel::addItem() { - /** TODO */ + if (!this->plugin) { return; } + + switch (this->type) { + case PluginType::Instr: { + CoreActions::addInstrParamCCLinkGUI(this->plugin); + break; + } + case PluginType::Effect: { + CoreActions::addEffectParamCCLinkGUI(this->plugin); + break; + } + } } void PluginAutomationModel::editItem(int itemIndex) { - /** TODO */ + if (!this->plugin) { return; } + auto& [param, paramName, cc, ccName] = this->listTemp.getReference(itemIndex); + + switch (this->type) { + case PluginType::Instr: { + CoreActions::editInstrParamCCLinkGUI(this->plugin, param, cc); + break; + } + case PluginType::Effect: { + CoreActions::editEffectParamCCLinkGUI(this->plugin, param, cc); + break; + } + } } void PluginAutomationModel::removeItem(int itemIndex) { diff --git a/src/ui/misc/CoreActions.cpp b/src/ui/misc/CoreActions.cpp index 3aec2e0b..7d3a44b8 100644 --- a/src/ui/misc/CoreActions.cpp +++ b/src/ui/misc/CoreActions.cpp @@ -574,20 +574,24 @@ void CoreActions::insertInstrGUI() { void CoreActions::editInstrParamCCLinkGUI(quickAPI::PluginHolder instr, int paramIndex, int defaultCC) { - /** TODO */ + auto callback = [instr, paramIndex](int cc) { CoreActions::setInstrParamCCLink(instr, paramIndex, cc); }; + CoreActions::askForPluginMIDICCGUIAsync(callback, instr, PluginType::Instr, defaultCC); } void CoreActions::addInstrParamCCLinkGUI(quickAPI::PluginHolder instr) { - /** TODO */ + auto callback = [instr](int param) { CoreActions::editInstrParamCCLinkGUI(instr, param); }; + CoreActions::askForPluginParamGUIAsync(callback, instr, PluginType::Instr); } void CoreActions::editEffectParamCCLinkGUI(quickAPI::PluginHolder effect, int paramIndex, int defaultCC) { - /** TODO */ + auto callback = [effect, paramIndex](int cc) { CoreActions::setEffectParamCCLink(effect, paramIndex, cc); }; + CoreActions::askForPluginMIDICCGUIAsync(callback, effect, PluginType::Effect, defaultCC); } void CoreActions::addEffectParamCCLinkGUI(quickAPI::PluginHolder effect) { - /** TODO */ + auto callback = [effect](int param) { CoreActions::editEffectParamCCLinkGUI(effect, param); }; + CoreActions::askForPluginParamGUIAsync(callback, effect, PluginType::Effect); } bool CoreActions::askForSaveGUI() { @@ -983,6 +987,7 @@ void CoreActions::askForPluginMIDICCGUIAsync( if (name.isNotEmpty()) { item += (" (" + name + ")"); } + ccItemList.add(item); } /** Create Selector */ @@ -999,6 +1004,9 @@ void CoreActions::askForPluginMIDICCGUIAsync( if (defaultCCChannel > -1) { combo->setSelectedItemIndex(defaultCCChannel); } + auto chooserSize = selectorWindow->getLocalBounds(); + combo->setBounds(0, 0, + chooserSize.getWidth() / 6 * 5, chooserSize.getHeight() / 5); selectorWindow->addCustomComponent(combo.get()); /** Show Selector Async */