From 8e6d1ac29ab6e4ac8cbf9386147ad01df2fd3d0b Mon Sep 17 00:00:00 2001 From: George Reales Date: Wed, 12 May 2021 18:47:15 +0200 Subject: [PATCH] Preset sync workaround and menu tweak --- Source/PluginEditor.cpp | 23 ++++++++++++++++------- Source/PluginEditor.h | 12 ++++++++++++ Source/PluginProcessor.cpp | 17 +++++++++++++++++ Source/PluginProcessor.h | 1 + 4 files changed, 46 insertions(+), 7 deletions(-) mode change 100644 => 100755 Source/PluginEditor.cpp mode change 100644 => 100755 Source/PluginProcessor.cpp diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp old mode 100644 new mode 100755 index d0c1483..89c275a --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -45,11 +45,9 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil getTopLevelComponent()->addKeyListener (commandManager.getKeyMappings()); //Timer::callAfterDelay (100, [this] { this->grabKeyboardFocus(); }); // ensure that key presses are sent to the KeyPressTarget object -#if JUCE_WINDOWS - // No run timer to grab component on window -#else + startTimer(100); // This will fix the issue -#endif + DBG("W: " <addSubMenu ("Themes", skinMenu); // About // menu.addItem(1, String("Release ") + String(JucePlugin_VersionString).dropLastCharacters(2), false); } - menu->addItem(progStart + 1000, "Preset Bar", true, false, Image()); + viewMenu.addItem(progStart + 1000, "Preset Bar", true, processor.showPresetBar); + menu->addSubMenu ("View", viewMenu); popupMenus.add (menu); } @@ -560,6 +560,7 @@ void ObxdAudioProcessorEditor::resultFromMenu (const Point pos) } else if (result == progStart + 1000){ processor.setShowPresetBar(!processor.getShowPresetBar()); + createMenu(); updatePresetBar(); } } @@ -753,7 +754,11 @@ void ObxdAudioProcessorEditor::nextProgram() { if (cur == processor.getNumPrograms()) { cur = 0; } - processor.setCurrentProgram (cur); + processor.setCurrentProgram (cur, false); + + needNotifytoHost = true; + countTimer = 0; + clean(); loadSkin (processor); } @@ -762,7 +767,11 @@ void ObxdAudioProcessorEditor::prevProgram() { if (cur < 0) { cur = processor.getNumPrograms() - 1; } - processor.setCurrentProgram (cur); + processor.setCurrentProgram (cur, false); + + needNotifytoHost = true; + countTimer = 0; + clean(); loadSkin (processor); } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 5571df5..fa1b9c5 100755 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -75,7 +75,17 @@ public: void buttonClicked (Button *) override; //bool keyPressed(const KeyPress & press) override; void timerCallback() override { +#if JUCE_WINDOWS || JUCE_LINUX + // No run timer to grab component on window +#else this->grabKeyboardFocus(); +#endif + countTimer ++; + if (countTimer == 4 && needNotifytoHost){ + countTimer = 0; + needNotifytoHost= false; + processor.updateHostDisplay(); + } } ApplicationCommandTarget* getNextCommandTarget() override { return nullptr; @@ -260,6 +270,8 @@ private: std::unique_ptr fileChooser; // Command manager ApplicationCommandManager commandManager; + int countTimer =0; + bool needNotifytoHost = false; }; #endif // PLUGINEDITOR_H_INCLUDED diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp old mode 100644 new mode 100755 index 18b88cd..e246672 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -167,6 +167,23 @@ int ObxdAudioProcessor::getCurrentProgram() return programs.currentProgram; } +void ObxdAudioProcessor::setCurrentProgram (int index, bool updateHost){ + programs.currentProgram = index; + programs.currentProgramPtr = programs.programs + programs.currentProgram; + isHostAutomatedChange = false; + + for (int i = 0; i < PARAM_COUNT; ++i) + setEngineParameterValue (i, programs.currentProgramPtr->values[i], true); + + isHostAutomatedChange = true; + + sendChangeMessage(); + // Will delay + if (updateHost) { + updateHostDisplay(); + } +} + void ObxdAudioProcessor::setCurrentProgram (int index) { programs.currentProgram = index; diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 1631a74..d24affe 100755 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -153,6 +153,7 @@ public: int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; + void setCurrentProgram (int index, bool updateHost); const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override;