diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 54f7315..cb24ddf 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -112,7 +112,7 @@ MainComponent::MainComponent(OscirenderAudioProcessor& p, OscirenderAudioProcess } pluginEditor.addCodeEditor(audioProcessor.getCurrentFileIndex()); - pluginEditor.fileUpdated(fileName); + pluginEditor.fileUpdated(fileName, fileTypeText == ".lua" || fileTypeText == ".txt"); }; fileName.setFont(juce::Font(16.0f, juce::Font::plain)); diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index a3b0f5b..3758b0b 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -275,13 +275,15 @@ void OscirenderAudioProcessorEditor::removeCodeEditor(int index) { // parsersLock AND effectsLock must be locked before calling this function -void OscirenderAudioProcessorEditor::updateCodeEditor() { +void OscirenderAudioProcessorEditor::updateCodeEditor(bool shouldOpenEditor) { // check if any code editors are visible - bool visible = false; - for (int i = 0; i < codeEditors.size(); i++) { - if (codeEditors[i]->isVisible()) { - visible = true; - break; + bool visible = shouldOpenEditor; + if (!visible) { + for (int i = 0; i < codeEditors.size(); i++) { + if (codeEditors[i]->isVisible()) { + visible = true; + break; + } } } int originalIndex = audioProcessor.getCurrentFileIndex(); @@ -307,9 +309,9 @@ void OscirenderAudioProcessorEditor::updateCodeEditor() { } // parsersLock MUST be locked before calling this function -void OscirenderAudioProcessorEditor::fileUpdated(juce::String fileName) { +void OscirenderAudioProcessorEditor::fileUpdated(juce::String fileName, bool shouldOpenEditor) { settings.fileUpdated(fileName); - updateCodeEditor(); + updateCodeEditor(shouldOpenEditor); } void OscirenderAudioProcessorEditor::handleAsyncUpdate() { diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index b26dedd..e9e1497 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -21,7 +21,7 @@ public: void initialiseCodeEditors(); void addCodeEditor(int index); void removeCodeEditor(int index); - void fileUpdated(juce::String fileName); + void fileUpdated(juce::String fileName, bool shouldOpenEditor = false); void handleAsyncUpdate() override; void changeListenerCallback(juce::ChangeBroadcaster* source) override; void toggleLayout(juce::StretchableLayoutManager& layout, double prefSize); @@ -90,7 +90,7 @@ public: void codeDocumentTextInserted(const juce::String& newText, int insertIndex) override; void codeDocumentTextDeleted(int startIndex, int endIndex) override; void updateCodeDocument(); - void updateCodeEditor(); + void updateCodeEditor(bool shouldOpenEditor = false); bool keyPressed(const juce::KeyPress& key) override; void mouseDown(const juce::MouseEvent& event) override; diff --git a/Source/components/EffectComponent.cpp b/Source/components/EffectComponent.cpp index 8a2431a..0cda038 100644 --- a/Source/components/EffectComponent.cpp +++ b/Source/components/EffectComponent.cpp @@ -8,9 +8,9 @@ EffectComponent::EffectComponent(OscirenderAudioProcessor& p, Effect& effect, in addAndMakeVisible(label); addAndMakeVisible(rangeButton); - sidechainEnabled = effect.parameters[0]->sidechain != nullptr; + sidechainEnabled = effect.parameters[index]->sidechain != nullptr; if (sidechainEnabled) { - sidechainButton = std::make_unique(effect.parameters[0]->name, BinaryData::microphone_svg, juce::Colours::white, juce::Colours::red, effect.parameters[0]->sidechain); + sidechainButton = std::make_unique(effect.parameters[index]->name, BinaryData::microphone_svg, juce::Colours::white, juce::Colours::red, effect.parameters[index]->sidechain); sidechainButton->setTooltip("When enabled, the volume of the input audio controls the value of the slider, acting like a sidechain effect."); addAndMakeVisible(*sidechainButton); }