Automatically open code editor when a lua or txt file is created

macos-debug-fix v2.1.6
James Ball 2024-04-13 17:57:23 +01:00 zatwierdzone przez James H Ball
rodzic c259dbc27c
commit 4f390ae041
4 zmienionych plików z 15 dodań i 13 usunięć

Wyświetl plik

@ -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));

Wyświetl plik

@ -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() {

Wyświetl plik

@ -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;

Wyświetl plik

@ -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<SvgButton>(effect.parameters[0]->name, BinaryData::microphone_svg, juce::Colours::white, juce::Colours::red, effect.parameters[0]->sidechain);
sidechainButton = std::make_unique<SvgButton>(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);
}